Search code examples
androidandroid-studiogoogle-maps-android-api-2android-maps

Including Google API (maps) in non Gradle Android Studio project


I have a legacy Android project (for Android API version 8 to 17) and I am struggling to get it to build correctly. It is a non-gradle project, and I can not convert it to gradle just yet (there is a build server that will fail then). It has already been edited in Android Studio before me by a person no longer here, and it landed on my desk. I have it all building now, but one problem remains. The project has a activity that extends "com.google.android.maps.MapActivity", but I could not get the project in Android Studio to be able to see that class, I could not find a way to make it depend on Google API's, so I ended up making the project depend on the maps.jar file from the Google API's version 17. Now the project compiles, but at runtime I get this error:

java.lang.IncompatibleClassChangeError: dk.some.domain.ui.branchinfo.BranchViewController

My guess is that it is compiled with one version of the Google API's (maps) version, but the phone has a different version or something. How do I fix this problem?

Thank you
Søren


Solution

  • I found my answer in this post:

    Android Gradle How to build for Android Google APIs 4.2.2 not for Android 4.2.2

    The funny thing was that I also had to set my module SDK to be the Google API and not the Android SDK, but it works.