Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: '-' is not a valid resource name character in Android Studio

I created a new Google Maps Activity, and the only thing I did was stick my API key into the .xml file. When I run the project, I get an: "Error: '-' is not a valid resource name character" in the .xml file. What is wrong with the project, and how can I fix the error? .xml file error

like image 427
Stephanie Fu Avatar asked Sep 03 '25 04:09

Stephanie Fu


2 Answers

i had this error, mainly it is where you place the key... Replace the YOUR_KEY in the code with your API key that start with Alza

from

 <string name="google_maps_key"
    templateMergeStrategy="preserve"
    translatable="false">YOUR_KEY</string>

to

 <string name="google_maps_key"
    templateMergeStrategy="preserve"
    translatable="false">AIzaSyBs8wUvJW-zOZixEiPmedagyrW8Y7VcW4I</string>
like image 189
X-Black... Avatar answered Sep 05 '25 01:09

X-Black...


in your android studio on google_maps_api.xml there will something like this :

You can also add your credentials to an existing key, using this line: 47:2A:E4:BC:00:1D:21:E2:FA:20:B9:AB:70:FB:75:E7:23:16:37:C1;com.example.radio.demomap

notice that it is separated by a semicolon

47:2A:E4:BC:00:1D:21:E2:FA:20:B9:AB:70:FB:75:E7:23:16:37:C1 ; com.example.radio.demomap

now when you go to google console developer to create credentials

example

type your package name and fingerprint certificate key and enter create you will get your correct key

like image 20
Sachin Singh Avatar answered Sep 04 '25 23:09

Sachin Singh