You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joe Bowser (JIRA)" <ji...@apache.org> on 2018/03/14 19:50:00 UTC

[jira] [Commented] (CB-13974) With cordova-android 7.x plugins with jni libraries are not backwards compatible

    [ https://issues.apache.org/jira/browse/CB-13974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16399201#comment-16399201 ] 

Joe Bowser commented on CB-13974:
---------------------------------

I'm not at all surprised that this is breaking, since we've asked on Cordova list as well as in the Cordova Slack for people to test JNI and had zero responses last year.  There probably should be something re-mapping the JNI plugins to the new location like what we do with all our legacy plugins using Java.  I don't want to add custom path directives, since that's what we've been doing for the past three years keeping the old project structure that keeps breaking in Android Studio.

I can't really give an ETA on this, but you may have to publish a hook, or two versions of the plugin.  Realistically, I don't see much support for Cordova-Android 6.x happening beyond security fixes in the near term.

> With cordova-android 7.x plugins with jni libraries are not backwards compatible
> --------------------------------------------------------------------------------
>
>                 Key: CB-13974
>                 URL: https://issues.apache.org/jira/browse/CB-13974
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-android
>    Affects Versions: cordova-android-7.0.0
>            Reporter: Doug Davies
>            Assignee: Joe Bowser
>            Priority: Major
>         Attachments: image1.png, image2.png, image3.png
>
>
> Pull down my project on GitHub
> [https://github.com/funkyvisions/manatee-tester.git]
> It uses the 3rd party plugin (manateeworks-barcodescanner-v3) which IS compatible with cordova-android 6.4.0.
> Execute the following:
> {code:java}
>     cordova prepare
>     cordova build android{code}
> You'll see everything prepares and builds fine and you can see the libraries (.so files and jar) end up in the correct directories in the APK (view through Android Studio - Build -> Analyze APK). See image1.
> Now we are going to switch to cordova-android 7.1.0.
> Execute the following: 
> {code:java}
>     cp package.7.json package.json
>     cp config.7.xml config.xml
>     rm -rf platforms plugins
>     cordova prepare
>     cordova build android
> {code}
> Notice it fails. This is because the plugin.xml is incorrect (although the error would never lead you to discover this). So let's fix it. Unfortunately, I tried to fork the project and apply a patch, but there seems to be a bug with cordova-fetch (https://issues.apache.org/jira/browse/CB-13973), so instead I included it locally in this project along with the patch to plugin.xml.
> I changed these lines in plugin.xml:
> {code:java}
>  <source-file src="src/android/libs/mwbscanner.jar" target-dir="libs" framework="true" />
>  <source-file src="src/android/src/com/manateeworks/BarcodeScannerPlugin.java" target-dir="src/com/manateeworks" />
>  <source-file src="src/android/src/com/manateeworks/ScannerActivity.java" target-dir="src/com/manateeworks" />
>  <source-file src="src/android/res/layout/scanner.xml" target-dir="res/layout" />
>  <source-file src="src/android/res/drawable/overlay_mw.png" target-dir="res/drawable" />
>  <source-file src="src/android/res/drawable-hdpi/overlay_mw.png" target-dir="res/drawable-hdpi" />
>  <source-file src="src/android/res/drawable/flashbuttonoff.png" target-dir="res/drawable" />
>  <source-file src="src/android/res/drawable/flashbuttonon.png" target-dir="res/drawable" />
>  <source-file src="src/android/res/drawable/zoom.png" target-dir="res/drawable" />
>  <source-file src="src/android/libs/armeabi/libBarcodeScannerLib.so" target-dir="libs/armeabi" />
>  <source-file src="src/android/libs/x86/libBarcodeScannerLib.so" target-dir="libs/x86" />
>  <source-file src="src/android/libs/armeabi-v7a/libBarcodeScannerLib.so" target-dir="libs/armeabi-v7a" />
>  <source-file src="src/android/libs/arm64-v8a/libBarcodeScannerLib.so" target-dir="libs/arm64-v8a" />
>  <source-file src="src/android/libs/mips/libBarcodeScannerLib.so" target-dir="libs/mips" />
> {code}
> to this:
> {code:java}
>  <!-- For cordova-android 7 it seems I to have to put the jar file in libs for compile time and jniLibs for runtime -->
>  <!-- Changed to lib-file -->
>  <lib-file src="src/android/libs/mwbscanner.jar" />
>  <resource-file src="src/android/libs/mwbscanner.jar" target="jniLibs/mwbscanner.jar" />
>  <!-- no change -->
>  <source-file src="src/android/src/com/manateeworks/BarcodeScannerPlugin.java" target-dir="src/com/manateeworks" />
>  <source-file src="src/android/src/com/manateeworks/ScannerActivity.java" target-dir="src/com/manateeworks" />
>  <!-- Changed to resource-file and used target instead of target-dir -->
>  <resource-file src="src/android/res/layout/scanner.xml" target="res/layout/scanner.xml" />
>  <resource-file src="src/android/res/drawable/overlay_mw.png" target="res/drawable/overlay_mw.png" />
>  <resource-file src="src/android/res/drawable-hdpi/overlay_mw.png" target="res/drawable-hdpi/overlay_mw.png" />
>  <resource-file src="src/android/res/drawable/flashbuttonoff.png" target="res/drawable/flashbuttonoff.png" />
>  <resource-file src="src/android/res/drawable/flashbuttonon.png" target="res/drawable/flashbuttonon.png" />
>  <resource-file src="src/android/res/drawable/zoom.png" target="res/drawable/zoom.png" />
>  <!-- Changed to resource-file and used target instead of target-dir (and changed to jniLibs) -->
>  <resource-file src="src/android/libs/armeabi/libBarcodeScannerLib.so" target="jniLibs/armeabi/libBarcodeScannerLib.so" />
>  <resource-file src="src/android/libs/x86/libBarcodeScannerLib.so" target="jniLibs/x86/libBarcodeScannerLib.so" />
>  <resource-file src="src/android/libs/armeabi-v7a/libBarcodeScannerLib.so" target="jniLibs/armeabi-v7a/libBarcodeScannerLib.so" />
>  <resource-file src="src/android/libs/arm64-v8a/libBarcodeScannerLib.so" target="jniLibs/arm64-v8a/libBarcodeScannerLib.so" />
>  <resource-file src="src/android/libs/mips/libBarcodeScannerLib.so" target="jniLibs/mips/libBarcodeScannerLib.so" />
> {code}
> Now let's switch to the forked version of the plugin and see if it works.
> Execute the following:
> {code:java}
>     cp package.fork.json package.json
>     cp config.fork.xml config.xml
>     rm -rf platforms plugins
>     cordova prepare
>     cordova build android{code}
> Now you see it builds once again and the APK is correct. See image2.
> However, the directives I put in plugin.xml are not backwards compatible with 6.4.0. We can prove this by now switch back to cordova-android 6.4.0 and trying to build.
> {code:java}
>     cp package.6.json package.json
>     cp config.6.xml config.xml
>     rm -rf platforms plugins
>     cordova prepare
>     cordova build android{code}
> Now look at the APK and you will see the libraries are missing. See image3.
> In order to fix this, I have to create a mix on the old config plus the new.
> See [https://github.com/funkyvisions/phonegap-manateeworks-v3/commit/9f3b165832141e45fa2c2e92dbf62b2300f0caf2#diff-53f390d375398624afe1cfe1125f42bf]
> I don't think this is a very good solution.
> There needs to be an approach that works with both. I wonder if this (https://issues.apache.org/jira/browse/CB-8781) is missing from cordova-android 7.1.0:
> {code:java}
> jniLibs.srcDirs = ['libs']{code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org