1

I have a project using the long since deprecated Maps V1 API, on which I have put in a lot of work and I need it.

I have just upgraded Studio to 3.5 and my current version for which I accepted the recommendations to upgrade the gradle plugin and gradle to versions 3.5.0 and 5.4.1 can't find the maps package on line such as:

import com.google.android.maps.GeoPoint;

Fortunately I have a previous version which barely differs and I didn't accept the upgrade recommendations for the plugin and gradle. The versions are 3.4..2 and 5.1.1. It builds successfully.

The relevant parts of my build.gradle (which is the same for both projects) are:

apply plugin: 'com.android.application'
android {
    signingConfigs {
  ...
    }
    compileSdkVersion 'Google Inc.:Google APIs:15'
    //compileSdkVersion 15
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "uk.co.secret.gridmaps"
        minSdkVersion 8
        targetSdkVersion 10
    }
}

dependencies {
     implementation 'org.osmdroid:osmdroid-android:5.2@aar'
    // NBT TRY 26 AUGUST 2019
    //implementation 'com.google.android.gms:play-services.maps:15.0.0'
}

Uncommenting the last line (as suggested in similar questions) doesn't help either:

ERROR: Failed to resolve: com.google.android.gms:play-services.maps:15.0.0

All suggestions will be gratefully received.

UPDATE 19:00 GMT I can fix this in a very dirty hard-coded way by adding the line

implementation files ('libs/googleapi21maps.jar')

to the dependencies section of build.gradle. That jar file is just a renamed version of C:\dev\tools\android-sdk-windows5.0\add-ons\addon-google_apis-google-21\lib\maps.jar from my old Windows eclipse project

Given that maps API V1 is dead, it does no harm but it's not elegant at all.

Also given that gradle 5.1.1 can find the package without resorting to this inelegant method, why can't gradle 5.4.1?

Update 2

It builds OK but when I invoke an activity that uses the android.maps, it crashes with an IncompatibleClassChangeError. I changed the version of the libs.jar to 15 with no improvement.

I need to make the latest gradle have backward compatibility with legacy code, even if I have to give an explicit reference to the library that gradle 5.1.1 retrieved.

NickT
  • 23,844
  • 11
  • 78
  • 121

1 Answers1

0

The compileSdkVersion looks stange, that should be eg. 28 (or 29).

And the current play-services-maps version is 17.0.0:

implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.gms:play-services-maps:17.0.0"

mavenCentral() also has a newer version of osmdroid-android:

// https://mvnrepository.com/artifact/org.osmdroid/osmdroid-android
implementation "org.osmdroid:osmdroid-android:6.1.0"
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • You have entirely missed my point with this answer. I know what the latest versions of SDK etc are. This is legacy code - I wouldn't start a project with maps V1 (even if I could get a key). I want to maintain backward compatibility with the latest build tools/gradle.If gradle 5.1.1 can find the necessary library, then I think 5.4.1 should be able to do the same, even if I have to give it an explicit reference. – NickT Aug 28 '19 at 07:01