PackageManager$NameNotFoundException for rxAndroidBle - android

For version 1.12.1, I am getting a runtime exception after upgrading to this version from 1.10.5
2021-07-16 15:30:16.588 22665-22665/co.(appname).staging E/AndroidRuntime: FATAL EXCEPTION: main
Process: co.(appname).staging:svc, PID: 22665
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/jakewharton/rxrelay2/BehaviorRelay;
at com.polidea.rxandroidble2.internal.DeviceModule.provideConnectionStateRelay(DeviceModule.java:57)
at com.polidea.rxandroidble2.internal.DeviceModule_ProvideConnectionStateRelayFactory.get(DeviceModule_ProvideConnectionStateRelayFactory.java:17)
at com.polidea.rxandroidble2.internal.DeviceModule_ProvideConnectionStateRelayFactory.get(DeviceModule_ProvideConnectionStateRelayFactory.java:9)
at bleshadow.dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.polidea.rxandroidble2.internal.RxBleDeviceImpl_Factory.get(RxBleDeviceImpl_Factory.java:31)
at com.polidea.rxandroidble2.internal.RxBleDeviceImpl_Factory.get(RxBleDeviceImpl_Factory.java:11)
at bleshadow.dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.polidea.rxandroidble2.DaggerClientComponent$DeviceComponentImpl.provideDevice(DaggerClientComponent.java:509)
at com.polidea.rxandroidble2.internal.RxBleDeviceProvider.getBleDevice(RxBleDeviceProvider.java:43)
at com.polidea.rxandroidble2.internal.scan.InternalToExternalScanResultConverter.apply(InternalToExternalScanResultConverter.java:26)
at com.polidea.rxandroidble2.internal.scan.InternalToExternalScanResultConverter.apply(InternalToExternalScanResultConverter.java:13)
at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:57)
at io.reactivex.internal.operators.observable.ObservableUnsubscribeOn$UnsubscribeObserver.onNext(ObservableUnsubscribeOn.java:60)
at io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onNext(ObservableCreate.java:66)
at com.polidea.rxandroidble2.internal.serialization.FIFORunnableEntry$1$1.onNext(FIFORunnableEntry.java:68)
at io.reactivex.internal.operators.observable.ObservableUnsubscribeOn$UnsubscribeObserver.onNext(ObservableUnsubscribeOn.java:60)
at io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onNext(ObservableCreate.java:66)
at com.polidea.rxandroidble2.internal.operations.ScanOperationApi21$1.onScanResult(ScanOperationApi21.java:83)
at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper$1.run(BluetoothLeScanner.java:492)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7664)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.jakewharton.rxrelay2.BehaviorRelay" on path: DexPathList[[zip file "/data/app/~~azBMNu86abFT1X-EHOpB2A==/co.(appname).staging-eYQb5VbY1nmgyq2oa0oeWA==/base.apk"],nativeLibraryDirectories=[/data/app/~~azBMNu86abFT1X-EHOpB2A==/co.(appname).staging-eYQb5VbY1nmgyq2oa0oeWA==/lib/arm64, /data/app/~~azBMNu86abFT1X-EHOpB2A==/co.(appname).staging-eYQb5VbY1nmgyq2oa0oeWA==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.polidea.rxandroidble2.internal.DeviceModule.provideConnectionStateRelay(DeviceModule.java:57) 
at com.polidea.rxandroidble2.internal.DeviceModule_ProvideConnectionStateRelayFactory.get(DeviceModule_ProvideConnectionStateRelayFactory.java:17) 
at com.polidea.rxandroidble2.internal.DeviceModule_ProvideConnectionStateRelayFactory.get(DeviceModule_ProvideConnectionStateRelayFactory.java:9) 
at bleshadow.dagger.internal.DoubleCheck.get(DoubleCheck.java:47) 
at com.polidea.rxandroidble2.internal.RxBleDeviceImpl_Factory.get(RxBleDeviceImpl_Factory.java:31) 
at com.polidea.rxandroidble2.internal.RxBleDeviceImpl_Factory.get(RxBleDeviceImpl_Factory.java:11) 
at bleshadow.dagger.internal.DoubleCheck.get(DoubleCheck.java:47) 
at com.polidea.rxandroidble2.DaggerClientComponent$DeviceComponentImpl.provideDevice(DaggerClientComponent.java:509) 
at com.polidea.rxandroidble2.internal.RxBleDeviceProvider.getBleDevice(RxBleDeviceProvider.java:43) 
at com.polidea.rxandroidble2.internal.scan.InternalToExternalScanResultConverter.apply(InternalToExternalScanResultConverter.java:26) 
at com.polidea.rxandroidble2.internal.scan.InternalToExternalScanResultConverter.apply(InternalToExternalScanResultConverter.java:13) 
at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:57) 
at io.reactivex.internal.operators.observable.ObservableUnsubscribeOn$UnsubscribeObserver.onNext(ObservableUnsubscribeOn.java:60) 
at io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onNext(ObservableCreate.java:66) 
at com.polidea.rxandroidble2.internal.serialization.FIFORunnableEntry$1$1.onNext(FIFORunnableEntry.java:68) 
at io.reactivex.internal.operators.observable.ObservableUnsubscribeOn$UnsubscribeObserver.onNext(ObservableUnsubscribeOn.java:60) 
at io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onNext(ObservableCreate.java:66) 
at com.polidea.rxandroidble2.internal.operations.ScanOperationApi21$1.onScanResult(ScanOperationApi21.java:83) 
at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper$1.run(BluetoothLeScanner.java:492) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7664) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
The catch? I have forked the repo, made a couple very small changes (like small changes to timeouts for example), and created a build with Jitpack. I checked their Jitpack build log (https://jitpack.io/com/github/polidea/RxAndroidBle/release-1.12.1-rxjava2/build.log) against my own, and they are almost identical. I see the missing errors, I have the exact same ones. The difference is that if I use the official polidea rxAndroidBle gradle thing (which I believe is pulled from Jitpack), I do not get the same runtime issue.
I have been looking for hours and feel like I am at a dead-end. I wanted to create an issue against the repo, but I am not confident that it is their issue. Something specific with what I have done with the build, but I do not know where the difference could be.

I was able to solve the issue by adding again the missing libraries that are not resolved when publishing a version with JitPack.
android: 'io.reactivex.rxjava2:rxandroid:2.1.0',
java : 'io.reactivex.rxjava2:rxjava:2.2.2',
relay : 'com.jakewharton.rxrelay2:rxrelay:2.1.0'

Related

Connecting to Parrot Anafi drone from Unity

I'm try to connect my drone to my Unity project (I'm making custom UI interface)
After doing some readings, I built a small module in Android Studio and made connection with my unity project (sent and receieved basic messeges).
I tried the Anafi example project, seperatly, and it worked.
Then I proceeded to include the relevant libraries in my module and that's where the problems started.
Even thought I included in the dependencies
// GroundSdk dependencies
implementation ('com.parrot.drone.groundsdk:groundsdk:7.0.1'){transitive(true)}
runtimeOnly ('com.parrot.drone.groundsdk:arsdkengine:7.0.1'){transitive(true)}
When I try to obtain session with
mGroundSdk = ManagedGroundSdk.obtainSession(UnityPlayer.currentActivity);
My app crashes. I can see the problem in Android Studio's Logcat
2022-02-14 12:50:18.120 17879-17879/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.asgard.UnityInterface, PID: 17879
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/parrot/drone/groundsdk/ManagedGroundSdk;
at com.asgard.unityinterface.AnafiConnector.onCreate(AnafiConnector.java:62)
at android.app.Activity.performCreate(Activity.java:8159)
at android.app.Activity.performCreate(Activity.java:8131)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3512)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3699)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2135)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8056)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
Caused by: java.lang.ClassNotFoundException: com.parrot.drone.groundsdk.ManagedGroundSdk
at com.asgard.unityinterface.AnafiConnector.onCreate(AnafiConnector.java:62) 
at android.app.Activity.performCreate(Activity.java:8159) 
at android.app.Activity.performCreate(Activity.java:8131) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1310) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3512) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3699) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2135) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:236) 
at android.app.ActivityThread.main(ActivityThread.java:8056) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) 
After doing some more research I found out the my dependencies weren't included in the AAR module (?)
Is there a way to include the GroundSDK in my AAR? How do I do this manually?
Thanks in advance!
To people from the future facing the same problem,
The answer is to check the “custom main gradle” option in
Player Settings => Android => Build
and add the references there

Xamarin.Android release build crash on startup with r8

Edit:
Please note the following issue does not occur when using Proguard, or in debug. Only issue with R8 in release
Step to reproduce:
Create a new blank Xamarin.Android application
Without making any change, simply run in debug make sure the project compile and run
Enable r8 and multi-dex:
Create release APK
When running the release APK, it will crash on startup with error:
2021-06-04 11:35:01.818 20194-20194/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.companyname.app1, PID: 20194
java.lang.RuntimeException: Unable to instantiate application androidx.multidex.MultiDexApplication: java.lang.ClassNotFoundException: Didn't find class "androidx.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.companyname.app1-S2R0G2ABxfLbmKhyk54SLg==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.app1-S2R0G2ABxfLbmKhyk54SLg==/lib/x86, /data/app/com.companyname.app1-S2R0G2ABxfLbmKhyk54SLg==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1226)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.multidex.MultiDexApplication" on path: DexPathList[[zip file "/data/app/com.companyname.app1-S2R0G2ABxfLbmKhyk54SLg==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.app1-S2R0G2ABxfLbmKhyk54SLg==/lib/x86, /data/app/com.companyname.app1-S2R0G2ABxfLbmKhyk54SLg==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at android.app.Instrumentation.newApplication(Instrumentation.java:1148)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1218)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431) 
at android.app.ActivityThread.access$1300(ActivityThread.java:219) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
I've played around with Linking options, but they all result in the same result.
A simple project can be found here:
https://drive.google.com/file/d/1oihKvJnRjxGiOaa2JS0FYKlQYI615p91/view?usp=sharing
Any help is highly appreciated!
When enabling multidex the correct multidex library (either com.android.support:multidex:1.0.3 or androidx.multidex:multidex:2.0.1) has to be used. As class androidx.multidex.MultiDexApplication is missing use androidx.multidex:multidex:2.0.1. Could be that the project template in Xamarin defailts to com.android.support:multidex:1.0.3.
See Multidex support prior to Android 5.0 for details.

React Native app crashing at startup on Android: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl"

I am using React Native v 0.62.2 and I am trying to get my project running on Android as well. Up until now, I had focussed development on iOS and therefore did never run the Android app. Now I wanted to run the android app but the app crashes on startup right after the splash screen was shown with the following stacktrace:
java.lang.RuntimeException: Unable to create application com.myapp.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6612)
at android.app.ActivityThread.access$1300(ActivityThread.java:233)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
at com.facebook.react.devsupport.a.a(:90)
at com.facebook.react.q.<init>(:238)
at com.facebook.react.r.b(:281)
at com.facebook.react.t.a(:87)
at com.facebook.react.t.h(:39)
at com.myapp.MainApplication.onCreate(:48)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607)
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
Caused by: java.lang.ClassNotFoundException: com.facebook.react.devsupport.DevSupportManagerImpl
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.facebook.react.devsupport.a.a(:68)
at com.facebook.react.q.<init>(:238) 
at com.facebook.react.r.b(:281) 
at com.facebook.react.t.a(:87) 
at com.facebook.react.t.h(:39) 
at com.myapp.MainApplication.onCreate(:48) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607) 
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.devsupport.DevSupportManagerImpl" on path: DexPathList[[zip file "/data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/base.apk"],nativeLibraryDirectories=[/data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/lib/x86, /data/app/~~WocKG3K03wTNVqsJq3z5Xg==/com.myapp-F972FEHz8FF4xF-BTG7qlg==/base.apk!/lib/x86, /system/lib, /system_ext/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:454) 
at java.lang.Class.forName(Class.java:379) 
at com.facebook.react.devsupport.a.a(:68) 
at com.facebook.react.q.<init>(:238) 
at com.facebook.react.r.b(:281) 
at com.facebook.react.t.a(:87) 
at com.facebook.react.t.h(:39) 
at com.myapp.MainApplication.onCreate(:48) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6607) 
at android.app.ActivityThread.access$1300(ActivityThread.java:233) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1896) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7523) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 
I searched the web for solutions or at least hints but did unfortunately not find any solution or even any idea of what could be done to fix this issue.
Does anyone have any idea? Also please let me know if you need any further information in order to be able to answer the question.
Thanks a lot!
For all who are struggling with this issue as well - after a long period of research plus try and error, I got it finally fixed.
It seems that this issue actually is correlated to OK HTTP. The steps that made me get it running were the following:
Enable MultiDex but also keep attention on going for the AndroidX solution (as I use the latest version of React Native which already leverages AndroidX) as stated in the following answer:
https://stackoverflow.com/a/56875424/9055450
Follow the instructions given in the following comment adding ProGuard files: https://github.com/facebook/react-native/issues/9043#issuecomment-298832659

DeepSpeechDemo App works with Gradle cli but crashes when built with Android Studio

The android-mic-streaming demo works off-the-shelf using ./gradlew installDebug, but when the play button in Android Studio is used to compile and install the exact same project it crashes with the following after tapping record:
2020-08-19 00:44:24.862 12872-12872/org.deepspeechdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.deepspeechdemo, PID: 12872
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28296)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:7448) 
at android.view.View.performClickInternal(View.java:7425) 
at android.view.View.access$3600(View.java:810) 
at android.view.View$PerformClick.run(View.java:28296) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libdeepspeech-jni.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at org.mozilla.deepspeech.libdeepspeech.DeepSpeechModel.<clinit>(DeepSpeechModel.java:9)
at org.deepspeechdemo.MainActivity.createModel(MainActivity.kt:90)
at org.deepspeechdemo.MainActivity.onRecordClick(MainActivity.kt:120)
at java.lang.reflect.Method.invoke(Native Method) 
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) 
at android.view.View.performClick(View.java:7448) 
at android.view.View.performClickInternal(View.java:7425) 
at android.view.View.access$3600(View.java:810) 
at android.view.View$PerformClick.run(View.java:28296) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
The issue seems to be related to libdeepspeech-jni.so not being included when Android Studio is used. I am completely new to Android development (I'm building a Mozilla-STT React Native module and only supporting iOS is useless) so this is especially confusing.
Thanks!
EDIT:
Hours of random trial and error later: Changing this option from "Default APK" to "APK from app bundle" in Android Studio made the demo start working
However, doing the same on my example app for the React Native module (which has a dependency android project which finally depends on the actual libdeepspeech) didn't work. It started working when using x86_64, so there must be no libdeepspeech x86 binary.
Hours of random trial and error later: Changing this option from "Default APK" to "APK from app bundle" in Android Studio made the demo start working
However, doing the same on my example app for the React Native module (which has a dependency android project which finally depends on the actual libdeepspeech) didn't work. It started working when using x86_64, so there must be no libdeepspeech x86 (32 bit) binary.

How to resolve ClassNotFoundException in Android Studio

I have recently migrated my project from Eclipse to Android Studio. Earlier everything was working perfectly, but recently when I started working on it again I am not able to launch the application. Its always showing me the same error. I haven't changed anything on application level, still getting the same result. Here is the log I am getting
FATAL EXCEPTION: main
Process: com.example.android, PID: 6977
java.lang.RuntimeException: Unable to instantiate application com.example.android.MobApplication: java.lang.ClassNotFoundException: Didn't find class "com.example.android.MobApplication" on path: DexPathList[[zip file "/data/app/com.example.android-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:601)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4919)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5721)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.MobApplication" on path: DexPathList[[zip file "/data/app/com.example.android-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newApplication(Instrumentation.java:986)
at android.app.LoadedApk.makeApplication(LoadedApk.java:587)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4919)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5721)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Suppressed: java.lang.ClassNotFoundException: com.example.android.MobApplication
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
As I have recently switched my IDE I am facing problems to solve this one. I have also tried the other answers but still unable to solve this error. Kindly help me with this so I can proceed with my project.
Any help would be appreciable.
Thanks
This might be the 65k methods limit. Try to use the solutions in the link.
Edit: For others who stumble this issue - #Salman Khan added multiDexEnabled true to the gradle file (as written in the link) and it solved the problem. It would be still better to read the whole article and follow the steps there.
Replaced lambda with anonymous class:
java.lang.ClassNotFoundException happened in my android studio project in two classes – in both of them there was lambda expressions. After I replaced lambda with anonymous class – the build was successful.
In my case, I needed to edit from:
String id = MyClass.class.toString();
Into:
String id = MyClass.class.getName();
Because .toString() returns something like "class mypackage.MyClass" (instead of "mypackage.MyClass").

Categories

Resources