2

I have an app which is published on both Google Play and Amazon AppStore. I recently added map API features to this app, so I had to use the Google APIs SDK to build it. I have successfully published my new version on Google Play, but having problems on Amazon.

The app was rejected by Amazon AppStore because they said the Kindle line of devices would not support it. After further research I downloaded the new Kindle emulators and found that they do not support the Google APIs. Since Kindle Fire tablets seem to be the primary devices for people purchasing apps through Amazon AppStore, I realized that I need to submit a version of my app which does not include the map features, but otherwise is the same app.

So my question is: how do I create a second version of the App which is based on the standard Android SDK and does not include the mapping API, but uses the same Java source files? As a long-time C++ programmer I could easily do this in C++ using conditional compile flags, but I've come to realize that Java does not support conditional compilation. And I certainly don't know how to exclude libraries from one Android Eclipse build and include them in another build.

Can anyone give me some tips on how to achieve my desired result in Android? I know I could create two separate apps but there would be a lot of code overlap which would be a lot more work for me when I have to do updates, I really don't want to have to maintain two separate codebases just to support Kindle Fires!

Marcelo
  • 9,387
  • 3
  • 35
  • 40
Alan Moore
  • 6,525
  • 6
  • 55
  • 68
  • I think this would probably work well as a library project. Move all your common code into a library, and you can create two projects which both inherit the library, and you can conditionally include/exclude code based on which project you're compiling. I put a reasonably detailed explanation of how to do this [in this answer](http://stackoverflow.com/questions/12963369/creating-demo-and-full-version-app-based-on-one-code-base-project/12963665#12963665). – Tim Nov 06 '12 at 04:31
  • Thanks Tim, I had been toying with this idea. I see you have fully developed it in your answer so I'll try that out -- looks very promising! – Alan Moore Nov 06 '12 at 04:43
  • @AlanMoore What did you end up doing? I am in a very similar situation. – theblang Jan 07 '14 at 16:46
  • @mattblang -- I ended up building a version of my app without the mapping features, someday I'm planning to learn the Amazon API but I haven't had the time so far! – Alan Moore Jan 08 '14 at 03:32

1 Answers1

2

You could either check for the Build.Manufacturer being equal to "Amazon" or check to see if the app was installed from the Amazon AppStore (eg on a Fire device or now on Blackberry) and if it was don't initialize or call the Google Maps functionality (doesn't seem to hurt if the libraries are there, as long as they're not active)

boolean isAmazonDevice = Build.MANUFACTURER.equalsIgnoreCase("amazon");

final Application application = getApplication();
String installerName = application.getPackageManager().getInstallerPackageName(application.getPackageName());
boolean fromAmazonStore = installerName != null && installerName.equalsIgnoreCase("com.amazon.venezia");

and then checking the value for:

isAmazonDevice || fromAmazonStore
Offbeatmammal
  • 7,970
  • 2
  • 33
  • 52