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
Related
I have integrated an SDK .aar which contains packages for slf4j library and already have one library which is using different artifacts.Therefore app code is calling to library and library not considering it artefact packages and call it from SDK due to that app is crashing. crash logs are as follows.
java.lang.ExceptionInInitializerError
at template_engine.TemplateEngine.<init>(TemplateEngine.kt:84)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.NullPointerException: throw with null exception
** at org.slf4j.impl.Log4jLoggerFactory.getLogger(Unknown Source:1) ** // it is calling from SDK
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at com.github.jknack.handlebars.Handlebars.<clinit>(Handlebars.java:251)
at template_engine.TemplateEngine.<init>(TemplateEngine.kt:84)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Please Help me with these i have already tried exclude it from Gradle SDK .aar but it is not working. Thanks in advance.
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'
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
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.
I was using Android Studio to create an app using Java, Kotlin and C++.
Yesterday, I upgraded the Android NDK from version 20.1 to version 21.0, and then the android studio keeps crash if I connect to my android phone and run.
The piece of crash log in Logcat is as below.
--------- beginning of crash
2020-01-17 15:46:15.737 13606-13606/com.blinkai.Video_2020_Debugging E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.blinkai.Video_2020_Debugging, PID: 13606
java.lang.UnsatisfiedLinkError: dlopen failed: library "libomp.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.blinkai.blinkai.MainActivity.<clinit>(MainActivity.kt:395)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
at android.app.Instrumentation.newActivity(Instrumentation.java:1251)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3328)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3594)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
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:2146)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
The code in MainActivity.kt:395 is:
// Used to load the 'native-lib' library on application startup.
init {
System.loadLibrary("native-lib")
}
Thank you very much for your help!
https://github.com/android/ndk/issues/1028
That problem mentioned in ndk repo. They suggests to use flag -static-openmp.
I put the flag in my CMakeLists.txt like:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp -static-openmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -static-openmp")
and that's do the job.