urbanairship / android-library

Urban Airship Android SDK
Other
112 stars 123 forks source link

Can not find com.urbanairship.UrbanAirshipProvider on Android version 19 and below. #35

Closed woxblom closed 7 years ago

woxblom commented 7 years ago

Using compile 'com.urbanairship.android:urbanairship-sdk:8.9.4'

It works fine in Android api 21 and above. But on 19 and below it crashes on start with below. I can see that the provider is declared in the xml in the apk, but the UrbanAirshipProvider class looks weird in the apk compared to the apk compiled with api 21. Any help would be appreciated. Thanks!

com.projectplace.octopi E/AndroidRuntime: FATAL EXCEPTION: main Process: com.projectplace.octopi, PID: 3335 java.lang.RuntimeException: Unable to get provider com.urbanairship.UrbanAirshipProvider: java.lang.ClassNotFoundException: Didn't find class "com.urbanairship.UrbanAirshipProvider" on path: DexPathList[[zip file "/data/app/com.projectplace.octopi-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.projectplace.octopi-1, /vendor/lib, /system/lib]] at android.app.ActivityThread.installProvider(ActivityThread.java:4793) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325) at android.app.ActivityThread.access$1500(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.urbanairship.UrbanAirshipProvider" on path: DexPathList[[zip file "/data/app/com.projectplace.octopi-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.projectplace.octopi-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at android.app.ActivityThread.installProvider(ActivityThread.java:4778) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)  at android.app.ActivityThread.access$1500(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5017)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  at dalvik.system.NativeStart.main(Native Method) 

rlepinski commented 7 years ago

@woxblom are you using multidex? You may need to declare the provider in the primary dex file: https://developer.android.com/studio/build/multidex.html#keep

woxblom commented 7 years ago

Yes, it was a multidex problem, however I fixed it by adding MultiDex.install(base); to the attachBaseContext method instead.

Thanks!