No implementation found for com.djinnius.HelloWorld$CppProxy - android

I'm working on a React Native project that uses djinni to use cross platform native C++.
I already looked at this question, but it seems a different problem.
The project build successfully but fails almost immediately on run.
adb logcat shows the following exception:
No implementation found for com.djinnius.HelloWorld$CppProxy com.djinnius.HelloWorld.create(com.rushingvise.reactcpp.ReactBridge) (tried Java_com_djinnius_HelloWorld_create and Java_com_djinnius_HelloWorld_create__Lcom_rushingvise_reactcpp_ReactBridge_2)
I'm trying to understand what tried means in the message above. Is this because the corresponding native code is missing from the apk ? Or maybe another cause ?
Full logcat is following:
04-19 19:44:51.042 2354-2700/com.djinnius E/art: No implementation found for com.djinnius.HelloWorld$CppProxy com.djinnius.HelloWorld.create(com.rushingvise.reactcpp.ReactBridge) (tried Java_com_djinnius_HelloWorld_create and Java_com_djinnius_HelloWorld_create__Lcom_rushingvise_reactcpp_ReactBridge_2)
04-19 19:44:51.045 2354-2354/com.djinnius W/unknown:React: Caught exception after cancelling react context init
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.facebook.react.ReactInstanceManager$Result.get()' on a null object reference
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.onCancelled(ReactInstanceManager.java:247)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.onCancelled(ReactInstanceManager.java:197)
at android.os.AsyncTask.finish(AsyncTask.java:665)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
04-19 19:44:51.053 2354-2700/com.djinnius E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
Process: com.djinnius, PID: 2354
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.UnsatisfiedLinkError: No implementation found for com.djinnius.HelloWorld$CppProxy com.djinnius.HelloWorld.create(com.rushingvise.reactcpp.ReactBridge) (tried Java_com_djinnius_HelloWorld_create and Java_com_djinnius_HelloWorld_create__Lcom_rushingvise_reactcpp_ReactBridge_2)
at com.djinnius.HelloWorld.create(Native Method)
at com.djinnius.HelloWorld.<init>(HelloWorld.java:27)
at com.djinnius.HelloWorldPackage.createNativeModules(HelloWorldPackage.java:18)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:88)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:950)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:891)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:104)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:218)
at com.facebook.react.ReactInstanceManager$ReactContextInitAsyncTask.doInBackground(ReactInstanceManager.java:197)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 
Any help appreciated.

Found the problem.
It was indeed a missing System.LoadLibrary() Call in the Java Class extending ReactPackage.
This is working now with this class initializer
public class HelloWorldPackage implements ReactPackage {
static {
System.loadLibrary("native-lib");
}

Related

Problem starting DJI simulation [dji-sdk]

I'm trying to implement the sample code of dji developer for android but i can't start the app, i add my com.dji.sdk.API_KEY and when i launch the app i get this errors:
2020-04-03 19:44:10.734 5567-5607/com.dji.sdk.sample E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.dji.sdk.sample, PID: 5567
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString() (tried Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString and Java_dji_midware_natives_SDKRelativeJNI_native_1getUsbAccessoryAttachedString__)
at dji.midware.natives.SDKRelativeJNI.native_getUsbAccessoryAttachedString(Native Method)
at dji.sdk.sdkmanager.DJISDKManager.<clinit>(Unknown Source:32)
at dji.sdk.sdkmanager.DJISDKManager.getInstance(Unknown Source:0)
at com.dji.sdk.sample.internal.controller.MainActivity$5.run(:241)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
If you need code of any thing i can post it too. Thanks.
EDIT:
I can do it with an hardware Samsung, not in virtual device.
I'm using an emulator, but the MSDK doesn't support it.
It only works with a real device.

How to work with Splunk Mint and Facebook ads in same project

I've been trying to integrate Facebook ads in my app for Android with the audience-network-sdk:5.0.0 and Facebook sdk crashed with this error:
10-16 13:12:07.128 25301-25725/? D/ProxyCache: Open connection to http://127.0.0.1:43557/ping
10-16 13:12:08.318 25301-25586/? E/ProxyCache: Error pinging server [attempt: 2, timeout: 1200].
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:176)
at com.facebook.ads.internal.r.b.f.b(Unknown Source)
at com.facebook.ads.internal.r.b.f.<init>(Unknown Source)
at com.facebook.ads.internal.r.b.f.<init>(Unknown Source)
at com.facebook.ads.internal.f.d$1.a(Unknown Source)
at com.facebook.ads.internal.f.d$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Shutdown server... Error pinging server [attempts: 3, max timeout: 1200].
10-16 13:12:08.318 25301-25586/? I/ProxyCache: Shutdown proxy server
10-16 13:12:08.328 25301-25602/? W/System.err: java.lang.InterruptedException
10-16 13:12:08.348 25301-25602/? W/System.err: at java.lang.Thread.sleep(Native Method)
at java.lang.Thread.sleep(Thread.java:1031)
at java.lang.Thread.sleep(Thread.java:985)
at com.splunk.mint.ExceptionHandler.uncaughtException(ExceptionHandler.java:64)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
10-16 13:12:08.348 25301-25602/? E/AndroidRuntime: FATAL EXCEPTION: Thread-12294
PID: 25301
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.FileDescriptor.setInt$(int)' on a null object reference
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:93)
at java.net.ServerSocket.implAccept(ServerSocket.java:216)
at java.net.ServerSocket.accept(ServerSocket.java:140)
at com.facebook.ads.internal.r.b.f.e(Unknown Source)
at com.facebook.ads.internal.r.b.f.a(Unknown Source)
at com.facebook.ads.internal.r.b.f$e.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
As you can see the trace just tell you that the ping (and the connection to local host) failed but it doesn't tell you more. I am not solving it because it only happens in physical device and only with my app (the example app from Facebook runs great in the same device and same network).
I don't know why is happening and how to fix it.
So I finally found the error and the solution.
Let me explain the error:
Facebook ads SDK uses localhost Proxy cache to download the assets of the ads
I also use Splunk Mint to track errors of my app in production.
Splunk Mint library has issues with the http monitoring:
Disable network monitoring
The solution was to add this line before init Mint SDK:
Mint.disableNetworkMonitoring();

Malformed exception in fabric library

Recently I see an exception in my log that fabric (Beta) tries to check for updates and this is the error:
E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=
I don't know why fabric tries to check for updates with a null URL, but I really want to remove that error.
Verbose stack trace:
E/Beta: Error while checking for updates from null
io.fabric.sdk.android.services.network.HttpRequest$HttpRequestException: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:722)
at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865)
at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85)
at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137)
at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139)
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78)
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63)
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28)
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.MalformedURLException: Protocol not found: null?instance=7f856ab5-12f8-4723-9e84-569dab8e9760&build_version=1030300&display_version=1.3.3&source=3
at java.net.URL.<init>(URL.java:176)
at java.net.URL.<init>(URL.java:125)
at io.fabric.sdk.android.services.network.HttpRequest.encode(HttpRequest.java:720)
at io.fabric.sdk.android.services.network.HttpRequest.get(HttpRequest.java:865) 
at io.fabric.sdk.android.services.network.DefaultHttpRequestFactory.buildHttpRequest(DefaultHttpRequestFactory.java:85) 
at io.fabric.sdk.android.services.common.AbstractSpiCall.getHttpRequest(AbstractSpiCall.java:137) 
at com.crashlytics.android.beta.CheckForUpdatesRequest.invoke(CheckForUpdatesRequest.java:48) 
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.performUpdateCheck(AbstractCheckForUpdatesController.java:166) 
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.checkForUpdates(AbstractCheckForUpdatesController.java:139) 
at com.crashlytics.android.beta.AbstractCheckForUpdatesController.initialize(AbstractCheckForUpdatesController.java:91) 
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:78) 
at com.crashlytics.android.beta.Beta.doInBackground(Beta.java:30) 
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:63) 
at io.fabric.sdk.android.InitializationTask.doInBackground(InitializationTask.java:28) 
at io.fabric.sdk.android.services.concurrency.AsyncTask$2.call(AsyncTask.java:311) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
I solved a lot of errors logs and the exception above by updating the crashlytics library version.
I also have solved this issue updating Crashlytics version in /app/build.gradle file.
I leave here the code of the fix for convenienece:
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}

upgrading OkHttp3 library

I'm using Okhttp:3.4.1 . Using this, all the https calls were giving
java.net.protocolexception: expected ':status' header not present.
Some of blogs advised to update Okhttp. When I update from 3.4.1 to 3.10.0, I'm getting
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NoSuchMethodError: No virtual method setCallWebSocket(Lokhttp3/Call;)V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/com.XXXXXX.android-1/split_lib_dependencies_apk.apk:classes85.dex)
at okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108)
at com.facebook.react.devsupport.InspectorPackagerConnection$Connection.connect(InspectorPackagerConnection.java:243)
at com.facebook.react.devsupport.InspectorPackagerConnection.connect(InspectorPackagerConnection.java:44)
at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:204)
at com.facebook.react.devsupport.DevServerHelper$3.doInBackground(DevServerHelper.java:200)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 
I'm using react-native:0.45.1
React native use okhttp as a dependency, upgrade okhttp may result in some compatibility issue. Currently it's using okhttp 3.6.0 (https://github.com/facebook/react-native/blob/8466db0fd355aea778ff71cfb10c927cfd18a551/ReactAndroid/build.gradle#L288). So my advice is that just leave it be.

Olingo OData 2.0 for Android - Dependency to javax.xml.stream.XMLInputFactory

I tried to implement an OData V2 Client using Apache Olingo OData 2.0 in Android.
Executing the client class as java class works fine, but I cannot run the Android App using the same code in an AsyncTask:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.my.app.appname, PID: 2521
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.conurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
java.util.conurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory;
at org.apache.olingo.odata2.core.commons.XmlHelper.createStreamReader(XmlHelper.java:41)
org.apache.olingo.odata2.core.edm.provider.EdmxProvider.parse(EdmxProvider.java:50)
org.apache.olingo.odata2.core.ep.ProviderFacadeImpl.readMetadata(ProviderFacadeImpl.java:224)
org.apache.olingo.odata2.api.ep.EntityProvider.readMetadata(EntityProvider.java:844)
at connectivity.MyClass.doInBackground(MyClass.java:153)
at connectivity.MyClass.doInBackground(MyClass.java:38)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237) <4 more...>
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLInputFactory" on path: DexPathList[[zip file "/data/app/com.my.app.appname-2/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) <12 more...>
Suppressed: java.lang.ClassNotFoundException: javax.xml.stream.XmlInputFactory
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.findClass(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
My questions are:
(How) Can I fix this issue?
(I read somewhere that the missing class might not be supported by Android?)
Would it help to switch to Apache Olingo OData 4.0?
(I need to consume an OData V2 service and if Olingo V4 would suport this on Android, I might try to migrate my client...)
Thanks in advance!
You have to repackage the javax.xml.stream classes yourself since Android does not support XML. Olingo V4 has a special android packaged client for that on the V4 dowload page: http://olingo.apache.org/doc/odata4/download.html
Olingo V2 does not have this feature because when the V2 library was created the main focus was on server side implementations. This is why a lot of convenience on client side is missing.

Categories

Resources