Discussion Forums  >  Maps, Device Location, Tracking

Replies: 23    Views: 660

fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
11/24/12 12:26 PM (11 years ago)

Getting Error in an XML file: aborting build after adding Maps API key to strings.xml

I've been working through the process of getting Maps to work on Android all day and finally got my Google Maps API key after generating a Release key and getting the MD5 fingerprint. I then opened the 'strings.xml' file in 'res' - 'values' and pasted in the API key. I then tried to run the app but got a message "Error in an XML file" aborting build" and red crosses all over the place. I tried to clean but that did nothing to help. Eventually I went back and removed the API key and reverted to the text that was there before and cleaned again but all the errors are still there. I'm losing the will to live with this but can't give up now. Any suggestions gratefully received.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/24/12 01:03 PM (11 years ago)
Even more bizarrely, to check I had put the bits I changed back to where I started I opened an earlier project that i hadn't tried this on to copy and past the original text. Now that project has the same "Error in XML file: aborting build" with red crossed everywhere and 100 'problems' despite doing nothing but opening the strings.xml file and copying a line of text. I am clearly doing something Eclipse really doesn't like but i have no idea what and now two projects are apparently seriously broken.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
11/24/12 01:19 PM (11 years ago)
Hi @fratony, Do a complete delete and x out all your windows...download your project again and restart eclipse. LA
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/24/12 01:25 PM (11 years ago)
Try looking you have set the google api level 8 instead of android. Right click project file---> properties---> android---> and select google api level 8 and click ok. If you have not downloaded it alreay then first download it from sdk manager and try these steps.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/24/12 01:34 PM (11 years ago)
Ok, I've done all that and got it working again although obviously back without the API key and presumably I have to do the key signing again now? Any idea what i did wrong and how I should use the API key correctly to avoid this happening again?
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/24/12 01:35 PM (11 years ago)
Hi Sandeep - yes, I do have the Google API on 8 so I don't think that is the issue.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/24/12 01:49 PM (11 years ago)
Its past 2 am here but if its possible to you we can have a teamviewer session after 8 hours from now. pm me your email address, i will get you back on email when i come online.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/24/12 01:55 PM (11 years ago)
Thanks Sandeep - it's getting late here too and I'm whacked so probably making mistakes. I'll look at everything again in the morning and pm you if I make no progress. Any other comments will be most welcome and I'll be back in the morning European time. Thanks all for continued help.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
11/24/12 10:44 PM (11 years ago)
One mistake that I've seen people make is how they put the key in their string file. Before you make a change, it should look something like this: <string name="googleMapsAPIKeyDebug">yourGoogleMapsKeyForDebug</string> <string name="googleMapsAPIKeyRelease">yourGoogleMapsKeyForRelease</string> After the change, it should look something like this: <string name="googleMapsAPIKeyDebug">0oYoJTnGQYNBciyMASfbutxEAZBqAsExxxxxxxx</string> <string name="googleMapsAPIKeyRelease">0oYoJTnGQYNDkg6D5uRu4ALMQyHLSHexxxxxxxx</string> If that's what you got, then there must be some other typo somewhere. Let us know! Mark
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/25/12 01:02 AM (11 years ago)
Ok, I've had another attempt from the fresh install. I wonder if I was creating problems trying to go straight to a release key so I have just created a maps API from the default debug key and pasted that into the strings.xml as described by GoWestNorth Mark above. That seems to have worked (at least no errors) and I have a map screen on emulator with a pin in the middle. There is no actual map - just the grey grid - but I understand that is normal on emulator? I have now packaged up the debug version for export and emailed it to a friend who has an Android phone to see if it works (I know, I need to get one myself if I'm going to do this but at the moment we're an iOS house and Google has sold out of the new Nexus 4!). I'll wait to hear back from my friend before attempting anything further at this stage and will update then.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
11/25/12 07:57 AM (11 years ago)
@GoNorthWest...great example. @fratony...normal for emulator not to show the tiles. LA
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
11/25/12 08:14 AM (11 years ago)
@fratony - You might be better off getting an old android phone for 25-30 quid just for testing. BT min sdk is level 8, so a 2.2 phone would be good. Newer phones can handle errors better than old phones, so an app may run well on a new phone but crash on an old phone and you'd be unaware of any problems.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/26/12 05:16 AM (11 years ago)
Ok - quick update... The app worked on the phone but the map is just showing the grid so I need to go back and work on that some more. I'll update if I solve it or get stuck! Thanks for the advice on the phone raveyd - I was waiting to get the Nexus but have instead just ordered a cheap older one to start testing on.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/27/12 09:05 AM (11 years ago)
I would appreciate anyone checking my planned next steps before I do anything stupid. Recap - here's where I am: - I have a debugged version of the app and it works on a device - I have a debugged Google Maps API key but the map is not showing on emulator or phone I have read that the map may not appear until I use a release version even if I have done everything right so far. Therefore I am planning the following: 1) Change the AndroidManifest.xml file to say "debuggable: false" 2) Create a release keystore by exporting application 3) Generate a new Google Maps API using the new release MD5 fingerprint 4) Add the new Google Maps API to res\values\string.xml file in: <string name="googleMapsAPIKeyRelease">yourGoogleMapsKeyForRelease</string> 5) Clean, run and re-export app 6) Test on device Does that seem right and have I missed anything obvious? Many thanks, Tony
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/27/12 09:31 AM (11 years ago)
Yes Tony, you are on the right track. But in addition to that you will have to edit the screen_map.java file as well if you want to show the users current location. Follow the link below for step by step guide by @Fred to set the map correctly in your android app. http://myskylla.wordpress.com/2012/04/18/buzztouch-google-maps/
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
11/27/12 09:34 AM (11 years ago)
Hi Tony, The plan looks good! Keep in mind that when you sign your app, be it with the debug or release key, it needs to be with the same keystore you used to generate the MD5 certificate and get the API Key. Also...I've been very unsuccessful, as have others, in getting map tiles to shop up in debug mode. Hardly ever happens. It's much more successful to sign your app with a release key, generate an apk, and load that into the emulator or device. That always works for me. Mark
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/27/12 09:39 AM (11 years ago)
Thanks Mark and Sandeep - I had missed that document so appreciate the link as it clarifies something else I had read on another thread. I'll keep going and report back in due course!
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/28/12 10:05 AM (11 years ago)
Ok - I can report back that's all worked and the map is now working on my phone. I just have to resolve an issue with the quiz not fitting the screen and I'm good to go. Thanks again for all your help.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/28/12 10:12 AM (11 years ago)
On which device are you testing your app? Quiz not showing at all or its cutting the lower view of the quiz screen?
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/28/12 10:28 AM (11 years ago)
I'm testing on a small screen - Galaxy Y - and it's cutting the bottom one and a half answers off.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/28/12 10:35 AM (11 years ago)
Galaxy Y is a 3.0 inches , 240 x 320 pixels phone which falls under ldpi category. Well while testing bt apps on phones with ldpi category even i faced the same issue and the only solution is to make some changes in the layout file by reducing the margin and layout height. But there is a risk associated with this. Your quiz might work proper on small devices but it will look messy on large devices like +4 inches phones and tablets.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/28/12 10:50 AM (11 years ago)
Yes - I've just seen how I can adjust sizes of the buttons but it is a shame it doesn't adjust to the different screen sizes. Currently the question takes a lot more vertical space than it needs to so I'll see if I can shave some height off this without having to squash the buttons too much. I would like to get it to fit but not at the expense of ruining it on larger devices - hopefully I can find a suitable compromise.
 
Sandeep
Android Fan
Profile
Posts: 1260
Reg: Feb 01, 2012
Miraj, India
25,250
like
11/28/12 10:52 AM (11 years ago)
I can understand the frustration but this is a big problem with the android since there are many devices with various sizes.
 
fratony
I hate code!
Profile
Posts: 77
Reg: Aug 14, 2012
Devon
5,370
like
11/28/12 11:04 AM (11 years ago)
Sorry - reposted when I refreshed page
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.