Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems when run on cordova-android@7 #8

Closed
LucaTrip opened this issue Nov 6, 2018 · 13 comments
Closed

Problems when run on cordova-android@7 #8

LucaTrip opened this issue Nov 6, 2018 · 13 comments

Comments

@LucaTrip
Copy link

LucaTrip commented Nov 6, 2018

hi,
I'm trying to make the test project work with [email protected] but when I run on Android device, the test app starts but outputs only deviceready.
In the Android Studio Logcat this warn comes back:

Rejecting re-init on previously-failed class java.lang.Class<com.example.HelloCJni>: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/io.cordova.hellocordova-uUJEPTqhZpGH28gw-fLRPg==/base.apk"],nativeLibraryDirectories=[/data/app/io.cordova.hellocordova-uUJEPTqhZpGH28gw-fLRPg==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libhelloc.so"
java.lang.NoClassDefFoundError: com.example.HelloCJni
at com.example.HelloCJni.calculate(Native Method)
at com.example.HelloCPlugin.execute(HelloCPlugin.java:35)
at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/io.cordova.hellocordova-uUJEPTqhZpGH28gw-fLRPg==/base.apk"],nativeLibraryDirectories=[/data/app/io.cordova.hellocordova-uUJEPTqhZpGH28gw-fLRPg==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libhelloc.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
at java.lang.System.loadLibrary(System.java:1657)
at com.example.HelloCJni.(HelloCJni.java:12)
at com.example.HelloCJni.getArch(Native Method)
at com.example.HelloCPlugin.execute(HelloCPlugin.java:28)

I do not know if this is the problem but before the support at cordova-android@7, the test app worked with cordova-platform@6.

Thanks

@dpa99c
Copy link
Owner

dpa99c commented Nov 6, 2018

Looks like the shared object libraries didn't get deployed to the Android project.
Try updating you CLI to cordova@8.

@LucaTrip
Copy link
Author

LucaTrip commented Nov 6, 2018

I updated the Cordova CLI to the latest version (8.1.2) and re-added the cordova-android@7 but the situation is the same.

@dpa99c
Copy link
Owner

dpa99c commented Nov 6, 2018

OK, I'll take a look. Maybe the SO's are not getting deployed into the right place for cordova-android@7 since I updated the platform version...

@dpa99c dpa99c closed this as completed in b5f4d9c Nov 6, 2018
@dpa99c
Copy link
Owner

dpa99c commented Nov 6, 2018

The Android libs path has changed in cordova-android@7 - the above commit updates this plugin to use the new path so it should now run OK with cordova-android@7

@LucaTrip
Copy link
Author

LucaTrip commented Nov 6, 2018

Yeah now work! Thank you!

@brody4hire
Copy link

I think this needs a major version increase (breaking change), right?

@dpa99c
Copy link
Owner

dpa99c commented Nov 6, 2018

@brodybits yeah, in a "real" plugin it would - cordova-android@7 has caused some really breaking changes.

But since this one is just an example plugin and isn't published to npm, the semantic versioning is redundant so I won't bother here.

BTW nice idea though to workaround it by wrapping all the .so files in a .jar

@LucaTrip
Copy link
Author

LucaTrip commented Nov 6, 2018

One more thing that is not clear to me. I would like to add my .c and .h files and the general flow would be:

  • replace by adding the C source codes to src/common/
  • adapt the HelloCPlugin.java and HelloCJni.java files
  • and recompile the new libraries plugins/cordova-plugin-hello-c/compile-android
    It's correct?

@dpa99c
Copy link
Owner

dpa99c commented Nov 6, 2018

yep, but if you're doing this with the plugin in-place inside an app project (i.e. myapp/plugins/cordova-plugin-hello-c), then you'll need to remove/re-add the platform to make the changes take effect:

cordova platform rm android --nosave && cordova platform add android --nosave

Otherwise, if your plugin lives outside of the your app directory, you can do:

cordova plugin rm cordova-plugin-hello-c --nosave && cordova plugin add /local/path/to/cordova-plugin-hello-c --nosave

@LucaTrip
Copy link
Author

LucaTrip commented Nov 6, 2018

Okay thank you

@brody4hire
Copy link

I just raised apache/cordova-docs#902 to get this documented properly.

@brody4hire
Copy link

FYI I just raised apache/cordova-android#547 to deal with the large number of plugins not working on cordova-android@7.

@dpa99c
Copy link
Owner

dpa99c commented Nov 12, 2018

@brodybits thanks, I have had compatibility problems reported against [email protected] which appears to make some breaking changes, e.g dpa99c/cordova-android-support-gradle-release#32 (comment)

I've worked around that particular issue (change in deployment location of Gradle files) in a new plugin version.

As for this example plugin, it's now the new version 18 of the Android NDK which is causing me issues - although I've updated the plugin to deploy the so files to the new location used by cordova-android@7 the C implementations of the JNI interface functions are not being found at runtime. Hopefully it's just a question of updating the C function signatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants