mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 918 forks source link

error: package android.support.annotation does not exist #2855

Open ppetree opened 3 years ago

ppetree commented 3 years ago

I'm using a cloud build service and including cordova-plugin-googlemaps ver 2.7.1 and I'm getting several Androidx related errors.

I'm submitting a ... (check one with "x")

OS: (check one with "x")

cordova information: (run $> cordova plugin list)

Cordova Packages:
    cli: 10.0.0
        common: 4.0.2
        create: 3.0.0
        lib: 10.0.0
            common: 4.0.2
            fetch: 3.0.0
            serve: 4.0.0

Project Installed Platforms:

    android: 9.0.0

Project Installed Plugins:

    @havesource/cordova-plugin-push: 2.0.0
    call-number1: 1.0.4
    com.peerio.cordova.plugin.carrier: 1.0.1
    cordova-open-native-settings: 1.5.2
    cordova-plugin-compat: 1.2.0
    cordova-plugin-device: 2.0.3
    cordova-plugin-email-composer: 0.9.2
    cordova-plugin-geolocation: 4.0.2
    cordova-plugin-googlemaps: 2.7.1
    cordova-plugin-inappbrowser: 4.0.0
    cordova-plugin-network-information: 2.0.2
    cordova-plugin-splashscreen: 6.0.0
    cordova-plugin-statusbar: 2.4.3
    cordova-plugin-vibration: 3.1.1
    cordova-plugin-whitelist: 1.3.4
    cordova-plugin-wkkeyboardfix: 1.1.0
    cordova-sqlite-storage: 5.0.0
    cordova.plugins.diagnostic: 5.0.2

Environment:
    OS: macOS Catalina 10.15.7 (19H512) (darwin 19.6.0) x64
    Node: v14.15.0
    npm: 6.14.8

Current behavior: Build fails with the following errors:

symbol:   class EnvironmentCompat
  location: package android.support.v4.os
/platforms/android/app/src/main/java/plugin/google/maps/PluginLocationService.java:12: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
/platforms/android/app/src/main/java/plugin/google/maps/PluginLocationService.java:13: error: package android.support.v4.content does not exist
import android.support.v4.content.PermissionChecker;
                                 ^
/platforms/android/app/src/main/java/plugin/google/maps/PluginMap.java:19: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;

Expected behavior: app builds

xit0c commented 3 years ago

I'm facing the same issue. Why is this plugin still using the old (and deprecated) android.support library? It should be migrated to AndroidX

ndrake commented 3 years ago

I'm pretty sure the multiple_maps branch has AndroidX support.

https://github.com/mapsplugin/cordova-plugin-googlemaps/tree/multiple_maps

lucasgalli commented 3 years ago

Hi @ppetree Did you find a solution? I'm facing the same issue with Android.

My info project:

Cordova Packages:

cli: 10.0.0
    common: 4.0.2
    create: 3.0.0
    lib: 10.0.0
        common: 4.0.2
        fetch: 3.0.1
        serve: 4.0.0

Project Installed Platforms:

I changed the libraries to AndroidX version

"import android.support.annotation.NonNull" --> "import androidx.annotation.NonNull" and "import android.support.v4.content.PermissionChecker" --> "import androidx.core.content.PermissionChecker"

and app builds pretty well, but the map is blank and no errors.

Should this plugin work with Cordova platform 10 ?

I installed in Cordova platform 9 and it's work pretty well.

ppetree commented 3 years ago

Try this:

  <platform name="android">
    <preference name="android-minSdkVersion" value="22" />
    <preference name="android-targetSdkVersion" value="29" />
    <preference name="android-installLocation" value="auto" />
    <preference name="android-multiDexEnabled" value="true" />
    <preference name="AndroidXEnabled" value="true" />
    <preference name="JetifierEnabled" value="true" />
  </platform>
  <plugin name="cordova-plugin-androidx-adapter" spec="1.1.3" />
  <plugin name="@havesource/cordova-plugin-push" spec="1.0.0">
    <variable name="SENDER_ID" value="12345678901" />
    <variable name="FCM_VERSION" value="18.+" />
  </plugin>
lucasgalli commented 3 years ago

Thank you for the reply @ppetree, but this change didn't work, no solution yet.

timsar2 commented 3 years ago

npm i jetifier --save-dev npx jetify npx cap sync solve this error for me but after that map could'nt load and i got new error:

unhandled Promise rejection: Java exception was raised during method invocation ; Zone: <root> ; Task: Promise.then ; Value: Error: Java exception was raised during method invocation
    at capacitorExec (google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:1790)
    at execProxy (google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:1924)
    at Map.<anonymous> (google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:16126)
    at google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:6377
    at Array.forEach (<anonymous>)
    at Map.trigger (google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:6369)
    at Map.set (google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:6335)
    at google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:15695
    at Array.filter (<anonymous>)
    at CordovaGoogleMaps.putHtmlElements (google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:15675) Error: Java exception was raised during method invocation
    at capacitorExec (http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:1790:30)
    at execProxy (http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:1924:21)
    at Map.<anonymous> (http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:16126:7)
    at http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:6377:25
    at Array.forEach (<anonymous>)
    at Map.trigger (http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:6369:10)
    at Map.set (http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:6335:12)
    at http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:15695:11
    at Array.filter (<anonymous>)
    at CordovaGoogleMaps.putHtmlElements (http://192.168.43.105:8100/app/tabs/google-map?lat=35.76880066023837&lng=51.43880367279053&_url=%2Fapp%2Ftabs%2Fplace%2Foffice-management:15675:33)
jeuxdaily commented 2 years ago

so all cordova admob plugins not working

benmesza commented 2 years ago

ionic cordova plugin add cordova-plugin-androidx-adapter This work for me.