GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
07/20/12 11:31 AM (13 years ago)

Five Minute Tutorial : Removing The Google API Dependency

Hello! I hope everybody is ready for a nice, restful weekend! A few weeks ago I did a tutorial called "Understanding Google and Android APIs," where I went over the differences between the two APIs, and why buzztouch apps require the Google API for compiling. You can find that thread here: http://www.buzztouch.com/forum/thread.php?tid=1C92466E729809D2192E05D In a nutshell, the only reason your app needs the Google APIs is because of the Google Maps feature that buzztouch provides. Get rid of that, and you are free to compile your app with any Android or Google API that you wish! So, I set about trying to figure out how to completely remove the maps dependency of my app. Turns out it's pretty easy! What follows are instructions for each version of buzztouch. NOTE : These procedures remove the ability to use Google Maps in your app (unless you do it via an HTML screen or something). This was largely an exercise to see how I could remove the Google API dependency. If you don't have a compelling reason to remove apps, or a huge need to use Android APIs only, then I would just use this as a learning exercise, and not actually modify your app. ** Before proceeding, please backup any files that you will modify. This protects you against mistakes, and allows you to recover things to normal. I can't be held responsible for accidental deletions or mistakes! ** buzztouch v1.5 * EDIT the AndroidManifest.xml file, found in the root folder of your source package. Remove the following lines, near line 65: - <!-- THE NEXT LINE IS ONLY USED IF MAPS ARE USED --> - <uses-library android:name="com.google.android.maps"/> * EDIT the strings.xml file found in res > values. Remove the following lines, near line 5: - <string name="googleMapsAPIKeyDebug">yourGoogleMapsKeyForDebug</string> - <string name="googleMapsAPIKeyRelease">yourGoogleMapsKeyForRelease</string> * EDIT the BT_item.java file, found in src > com > appname folder. - Line 38, delete : import com.google.android.maps.GeoPoint; - Line 55, delete : GeoPoint point; * DELETE BT_screen_map.java file from src > com > appname * DELETE screen_map.xml file from res > layout Test that your app will compile using the Android API by opening your package in Eclipse, highlighting the package in Package Explorer, choosing Properties...Android, and selecting your desired Android API. It should rebuild the workspace, and no errors should be present. If you get an error about the project not being able to be built after you switch from the Google APIs to the Android APIs, try right-clicking the project and doing Refresh. buzztouch v2.0 * EDIT the AndroidManifest.xml file, found in the root folder of your source package. Remove the following lines, near line 65: - <!-- THE NEXT LINE IS ONLY USED IF MAPS ARE USED --> - <uses-library android:name="com.google.android.maps"/> * EDIT the strings.xml file found in res > values. Remove the following lines, near line 5: - <string name="googleMapsAPIKeyDebug">yourGoogleMapsKeyForDebug</string> - <string name="googleMapsAPIKeyRelease">yourGoogleMapsKeyForRelease</string> * EDIT the BT_item.java file, found in src > com > appname folder. - Line 38, delete : import com.google.android.maps.GeoPoint; - Line 55, delete : GeoPoint point; * DELETE BT_screen_map.java file from src > com > appname * DELETE screen_map.xml file from res > layout Test that your app will compile using the Android API by opening your package in Eclipse, highlighting the package in Package Explorer, choosing Properties...Android, and selecting your desired Android API. It should rebuild the workspace, and no errors should be present. If you get an error about the project not being able to be built after you switch from the Google APIs to the Android APIs, try right-clicking the project and doing Refresh. buzztouch v1.4 * EDIT the AndroidManifest.xml file, found in the root folder of your source package. Remove the following lines, near line 45: - <uses-library android:name="com.google.android.maps"/> * EDIT the strings.xml file found in res > values. Remove the following lines, near line 4: - <string name="googleMapsAPIKeyDebug">yourGoogleMapsKeyForDebug</string> - <string name="googleMapsAPIKeyRelease">yourGoogleMapsKeyForRelease</string> * DELETE the Obj_MapLocation.java file found in src > com > v1_4 > appname > com * DELETE the Screen_LocationMap.java file found in src > com > v1_4 > appname > com * DELETE the menu_locationmap.xml file found in res > layout * DELETE the screen_locationmap.xml file found in res > layout * EDIT Act_ActivityBase.java found in src > com > v1_4 > appname > com and remove lines 286-296 //showLocationMap public void showLocationMap(){ Intent theIntent = new Intent(this, Screen_LocationMap.class); startActivity(theIntent); } * EDIT Act_ActivityBase.java found in src > com > v1_4 > appname > com and removed lines 115-117 if(theScreen.screenType.equals("screen_locationMap")) showLocationMap(); if(theScreen.screenType.equals("screen_multipleLocationMap")) showLocationMap(); if(theScreen.screenType.equals("screen_multiLocationMap")) showLocationMap(); Test that your app will compile using the Android API by opening your package in Eclipse, highlighting the package in Package Explorer, choosing Properties...Android, and selecting your desired Android API. It should rebuild the workspace, and no errors should be present. If you get an error about the project not being able to be built after you switch from the Google APIs to the Android APIs, try right-clicking the project and doing Refresh. So, that's pretty much it! There is no doubt some residual code lurking in the various files we download, but it doesn't affect your ability to compile using the Android API, and it doesn't appear to negatively affect your app. Again, this was largely an education exercise, so if you don't have a pressing need to actually remove the Google Maps feature, I'd just leave it alone! Thanks! Mark
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
07/20/12 01:51 PM (13 years ago)
Could you check the steps for editing the BT_item.java file Mark? After deleting the import, there's one other place to delete code, line 172ish: //only used for map location BT_items.. btw, whenever I don't use maps, I just delete the map.java and edit the item.java. That's the bare minimum to compile the project (v2.0) - but that's still using google api..
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
07/20/12 02:09 PM (13 years ago)
These lines: //only used for map location BT_items.. public boolean getIsDeviceLocation() { return isDeviceLocation; } It compiles fine leaving them in there, because it doesn't call anything that's already been removed (at least during compile time). I suspect you'd be safe removing those lines, but I haven't tried it. I know it works keeping them in. Mark
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
07/20/12 02:41 PM (13 years ago)
I don't bother looking now, but I'm reasonably sure the first time I did it, after removing the geopoint code, the last section of the file starting with that comment was littered with errors. It could easily have been associated with something else I was doing at the time though. Ever since then I've just deleted the lot and it compiles fine. (leaving the last closing brace of course!) This is what I strip out from the end of the file: //only used for map location BT_items.. public boolean getIsDeviceLocation() { return isDeviceLocation; } public void setIsDeviceLocation(boolean isDeviceLocation) { this.isDeviceLocation = isDeviceLocation; } public String getAnnotationTitle() { return annotationTitle; } public void setAnnotationTitle(String annotationTitle) { this.annotationTitle = annotationTitle; } public String getAnnotationSubTitle() { return annotationSubTitle; } public void setAnnotationSubTitle(String annotationSubTitle) { this.annotationSubTitle = annotationSubTitle; } public double getLatitude() { return latitude; } public void setLatitude(double latitude) { this.latitude = latitude; } public double getLongitude() { return longitude; } public void setLongitude(double longitude) { this.longitude = longitude; }
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
07/20/12 02:50 PM (13 years ago)
Yep, I think that falls under the "residual code" stuff I was talking about. I do know, because I tested it, that removing the items noted in the tutorial will allow you to compile and run your app with the Android APIs. Can't vouch for any additional code adds! Mark
 
RB
Aspiring developer
Profile
Posts: 150
Reg: Jun 29, 2011
BR
6,150
like
07/29/12 10:10 AM (13 years ago)
Very usefull tutorial. Would be interesting if there was a specific topic for publishing tutorials produced by Mark and other users, preferably without interaction.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
07/29/12 10:50 AM (13 years ago)
Hey Mark, I found out why I have to delete all that extra code further down the file. You just delete this bit? - Line 55, delete : GeoPoint point; I delete the whole section that's commented, which highlights the errors further down. Just deleting the single GeoPoint line doesn't bring up the further errors and builds ok. Glad I found that out, it was bugging me!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
07/29/12 11:32 AM (13 years ago)
Yep, I just delete the GeoPoint point; part. That, I think, prevents any further related code from ever being invoked. Mark
 
shennis90
I hate code!
Profile
Posts: 5
Reg: Sep 15, 2012
Dublin
150
like
09/17/12 09:36 AM (13 years ago)
Hi Mark, I followed these steps after I was getting errors in eclipse and it fixed them up. However, when I took the app for a trial run on the emulator and on my own android device after export - the app just loads a black screen and doesn't do anything. Would this be related? Thanks, Shane (ultra-newby)
 
shennis90
I hate code!
Profile
Posts: 5
Reg: Sep 15, 2012
Dublin
150
like
09/17/12 09:42 AM (13 years ago)
Hi Mark, I followed these steps after I was getting errors in eclipse and it fixed them up. However, when I took the app for a trial run on the emulator and on my own android device after export - the app just loads a black screen and doesn't do anything. Would this be related? Thanks, Shane (ultra-newby)
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
09/17/12 09:44 AM (13 years ago)
Hi Shane, Welcome to buzztouch! So, first question I have is did you remove the dependency on the Google APIs to try and get rid of the errors in Eclipse? Because if so, depending on the errors, there are easier ways to take care of those. And, if you are going to be doing any mapping, then you'll need the Google APIs. Otherwise, the black screen probably doesn't have anything to do with it (though I'd need to see the LogCat output at the time you try and load the screen to be sure). One thing you can do is try and sync your configuration data file between the copy on buzztouch.com and your local one. Once you've done that, you should see everything you have configured on the app. Here is a video that shows how to sync them up: http://www.youtube.com/watch?v=Sp2vL1XCPC0 Give this a shot and let me know if it helps. Mark
 
shennis90
I hate code!
Profile
Posts: 5
Reg: Sep 15, 2012
Dublin
150
like
09/17/12 01:18 PM (13 years ago)
Hi Mark, Yes I followed all of the steps in your parent post above in relation to fixing errors in v2.0 - including removing API dependencies. I have downloaded my BT package again without making any changes in eclipse and my take on this now (as a novice) is that I cannot follow the steps listed in these docs you wrote... - http://www.buzztouch.com/files/howtos/Obtaining_a_Google_Maps_API_Key_v1.0.pdf - http://dl.dropbox.com/u/4993711/Signing_Android_Apps_v1.0.pdf ...because of the errors that are the main, unmodified file. Can you advise me on where to go from here? Is following the steps listed for v2.0 above, but leaving in the API dependencies going to work? Thanks for your help. Shane
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
09/17/12 01:26 PM (13 years ago)
Hi Shane, Here's a much better document that should help. It's more complete and up to date: https://www.buzztouch.com/files/howtos/buzztouch_For_Android-A_Users_Guide.pdf Bottom line is to leave the map stuff in there, make sure you have Google API 8 selected for your project, and that should take care of those particular errors. Mark
 
shennis90
I hate code!
Profile
Posts: 5
Reg: Sep 15, 2012
Dublin
150
like
09/17/12 01:26 PM (13 years ago)
Hi Mark, Yes I followed all of the steps in your parent post above in relation to fixing errors in v2.0 - including removing API dependencies. I have downloaded my BT package again without making any changes in eclipse and my take on this now (as a novice) is that I cannot follow the steps listed in these docs you wrote... - http://www.buzztouch.com/files/howtos/Obtaining_a_Google_Maps_API_Key_v1.0.pdf - http://dl.dropbox.com/u/4993711/Signing_Android_Apps_v1.0.pdf ...because of the errors that are the main, unmodified file. Can you advise me on where to go from here? Is following the steps listed for v2.0 above, but leaving in the API dependencies going to work? Thanks for your help. Shane
 
shennis90
I hate code!
Profile
Posts: 5
Reg: Sep 15, 2012
Dublin
150
like
09/17/12 04:21 PM (13 years ago)
Hi Mark, Thanks very much for your help with this. I got the app exported and running to a certain extent which is great! :) I've hit a bit of a roadblock in terms of the app finding the users location on launch however. http://www.buzztouch.com/forum/thread.php?tid=A5C73DA3D26B8099C3E1E76&fid=0B19EC7C02CBDD92F12FD08&sortColumn=FT.id&sortUpDown=DESC&currentPage=1 I had a read through the above and had a look at the bt_config.txt - everything looked ok to me so I just did a quick sync between the file on buzztouch and the file on my computer. Unfortunately still no change - any ideas? Thanks again, Shane
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
09/17/12 04:26 PM (13 years ago)
Hi Shane, Do you have Turn on GPS set in the Core Settings section of the control panel for your app? It sounds like it's not. If it is, look through the LogCat output when the app starts and make sure it reports that GPS is turned on. If you are testing this in an emulator, the GPS function won't work because...well...it's not a real device! ;-) Mark
 
techdesigner
Apple Fan
Profile
Posts: 77
Reg: Jun 22, 2012
Cleveland
10,870
like
01/24/13 02:36 PM (13 years ago)
Mark, In case you didn't know you have been hard at work again... I tried installing the apk on a Kindle Fire and true to form it didn't work. It did not install. A little Googleing and I figured out Google and Fire don't mix. Of course you helped out with your ten minute tutorial of how to strip out Google. I rebuilt the app as a third version for Kindle and cleaned out everything Google and it installed on the Kindle like a charm! Thanks for the tutorial!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
01/24/13 02:41 PM (13 years ago)
Awesome! Same method works for Blackberry. Good to know it does the trick for Kindle as well! Mark
 

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.