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
-
check your .xml resource file.you declare the some resource with - (hyphen) and android not allow a use of hyphen in resource file name of resource ids so check it oncesantoXme– santoXme2015-12-23 05:31:42 +00:00Commented Dec 23, 2015 at 5:31
-
see this code.google.com/p/android/issues/detail?id=31Aditya Vyas-Lakhan– Aditya Vyas-Lakhan2015-12-23 05:33:17 +00:00Commented Dec 23, 2015 at 5:33
-
The only hyphen I have in the .xml file is the hyphen in the API key, no other "-"s in the entire file.Stephanie Fu– Stephanie Fu2015-12-23 05:40:31 +00:00Commented Dec 23, 2015 at 5:40
-
I added a screenshot of Android Studio with the error.Stephanie Fu– Stephanie Fu2015-12-23 05:56:48 +00:00Commented Dec 23, 2015 at 5:56
-
issue in google_maps_api.xmlAditya Vyas-Lakhan– Aditya Vyas-Lakhan2015-12-23 05:57:16 +00:00Commented Dec 23, 2015 at 5:57
3 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>
Comments
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
type your package name and fingerprint certificate key and enter create you will get your correct key
Comments
You should put the key this way:
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">**YOUR_KEY**</string>
Not this way:
<string name="**YOUR_KEY**" templateMergeStrategy="preserve" translatable="false"></string>
1 Comment
Once you have your key (it starts with "AIza"), replace the "google_maps_key" string in this file.