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

compile-android problem #9

Closed
LucaTrip opened this issue Nov 7, 2018 · 9 comments
Closed

compile-android problem #9

LucaTrip opened this issue Nov 7, 2018 · 9 comments

Comments

@LucaTrip
Copy link

LucaTrip commented Nov 7, 2018

Hello,
I'm editing the files .c and .h in the /src/common/ but when I go to run compile-android it just generates the .so for arm64-v8a, armeabi-v7a, x86 and x86_64 architectures, omitting armeabi, mips and mips64.
This is the output:

./compile-android
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.
[arm64-v8a] Compile : helloc <= hello.c
[arm64-v8a] Compile : helloc <= mycomponent.c
[arm64-v8a] Compile : helloc <= mylib.c
[arm64-v8a] Compile : helloc <= mypart.c
[arm64-v8a] SharedLibrary : libhelloc.so
[arm64-v8a] Install : libhelloc.so => libs/arm64-v8a/libhelloc.so
[armeabi-v7a] Compile thumb : helloc <= hello.c
[armeabi-v7a] Compile thumb : helloc <= mycomponent.c
[armeabi-v7a] Compile thumb : helloc <= mylib.c
[armeabi-v7a] Compile thumb : helloc <= mypart.c
[armeabi-v7a] SharedLibrary : libhelloc.so
[armeabi-v7a] Install : libhelloc.so => libs/armeabi-v7a/libhelloc.so
[x86] Compile : helloc <= hello.c
[x86] Compile : helloc <= mycomponent.c
[x86] Compile : helloc <= mylib.c
[x86] Compile : helloc <= mypart.c
[x86] SharedLibrary : libhelloc.so
[x86] Install : libhelloc.so => libs/x86/libhelloc.so
[x86_64] Compile : helloc <= hello.c
[x86_64] Compile : helloc <= mycomponent.c
[x86_64] Compile : helloc <= mylib.c
[x86_64] Compile : helloc <= mypart.c
[x86_64] SharedLibrary : libhelloc.so
[x86_64] Install : libhelloc.so => libs/x86_64/libhelloc.so

Once the lib.so is generated, I remove the android platform, re-add it and I get this error back

workspace/cordova-plugin-hello-c-test/plugins/cordova-plugin-hello-c/src/android/libs/armeabi/libhelloc.so" not found!

How do I generate the missing architectures? is my flow wrong?
 
Thanks

@dpa99c
Copy link
Owner

dpa99c commented Nov 8, 2018

https://developer.android.com/ndk/guides/abis

Looks like the armeabi, mips and mips64 ABIs have been removed from the NDK as they're no longer supported. I'll update the plugin to reflect these changes.

@LucaTrip
Copy link
Author

LucaTrip commented Nov 9, 2018

so it is correct that I generate the "wrong" .so files? Then I thought maybe I had to update the version of the NDK so I downloaded version 18, and during cordova run android I get back this error

A problem occurred configuring project ':CordovaLib'.
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

Thanks for the support.

@dpa99c
Copy link
Owner

dpa99c commented Nov 9, 2018

The NDK has been made several backwardly-incompatible changes since I created this plugin so I need to update the plugin to work with the new NDK versions - I'm working on it.

See google/filament#15 (comment) for a solution to the toolchain error.

@LucaTrip
Copy link
Author

LucaTrip commented Nov 9, 2018

Perfect thank you.

@LucaTrip
Copy link
Author

LucaTrip commented Nov 9, 2018

one last thing: which version of NDK did you used to compile to .so files?

@dpa99c
Copy link
Owner

dpa99c commented Nov 9, 2018

originally v11 (the .so files that are currently in this repo).

Now I've also upgraded to v18 but now having issues getting them to work - the JNI interface is not finding the native functions. Probably due to breaking changes between v11 and v18.
That's why I'm currently looking into.

@dpa99c
Copy link
Owner

dpa99c commented Nov 17, 2018

@LucaTrip I've finally managed to get Android building and working with NDK v18 - just pushed a commit containing the changes.
Tested with cordova-android@7.1.1 - the NDK compiles successfully and the C libraries are now correctly detected and used by Android at runtime.
Please give it a try and let me know if it works for you.

@dpa99c
Copy link
Owner

dpa99c commented Nov 17, 2018

Just tested with cordova-android@7.1.2 - installing the plugin into the platform fails with the following error:

$ cordova platform add android@7.1.2
Using cordova-fetch for cordova-android@7.1.2
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android target: android-27
Android project created with cordova-android@7.1.2
Android Studio project detected
Android Studio project detected
Installing "cordova-plugin-hello-c" for android
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-hello-c': TypeError: Uh oh!
Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.resolve (path.js:200:7)
    at copyNewFile (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\lib\pluginHandlers.js:258:28)
    at install (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\lib\pluginHandlers.js:43:17)
    at Object.process (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\node_modules\cordova-common\src\ActionStack.js:56:25)
    at PluginManager.doOperation (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:114:20)
    at PluginManager.addPlugin (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:144:17)
    at D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\Api.js:247:74
    at _fulfilled (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (D:\Git\3rd_party\cordova-plugin-hello-c-test\platforms\android\cordova\node_modules\q\q.js:863:30)
Uh oh!
Path must be a string. Received undefined

However, I believe this due to a bug (or bugs) in cordova-android@7.1.2, as discussed in this issue and seems to be fixed by this PR, since if I installed the cordova-android platform off the master branch (cordova platform add https://github.com/apache/cordova-android), it builds and runs successfully.

I understand there'll be a cordova-android@7.1.3 patch release soon containing these fixes.

@LucaTrip
Copy link
Author

great @dpa99c! Now it also works with cordova@7.1.0 and correctly generates the .so files. Thanks for the support.

@dpa99c dpa99c closed this as completed Nov 19, 2018
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

2 participants