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

Android Crash - 64 bit architecture missing #8

Closed
dylanvdmerwe opened this issue May 8, 2018 · 29 comments
Closed

Android Crash - 64 bit architecture missing #8

dylanvdmerwe opened this issue May 8, 2018 · 29 comments
Assignees
Labels
bug Something isn't working change documentation enhancement New feature or request

Comments

@dylanvdmerwe
Copy link

document-scanner version 1.1.1

Crashing in an app with the following code:

  scanDocument() {
    // scan document using document-scanner from the camera
    scan.scanDoc(1, (imgUri) => {
      this.claimDocImage.imagePath = normalizeURL(imgUri);
    }, (err) => {
      console.error(err);
    });
  }
    --------- beginning of crash
05-08 14:01:23.852 28011-28011/com.eightysixdegrees.antellogistics E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.eightysixdegrees.antellogistics, PID: 28011
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.eightysixdegrees.antellogistics-h9hhwnZVYDRxsfP_9H8p1g==/base.apk"],nativeLibraryDirectories=[/data/app/com.eightysixdegrees.antellogistics-h9hhwnZVYDRxsfP_9H8p1g==/lib/arm64, /data/app/com.eightysixdegrees.antellogistics-h9hhwnZVYDRxsfP_9H8p1g==/base.apk!/lib/arm64-v8a, /system/lib64]]] couldn't find "libopencv_java3.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
        at java.lang.System.loadLibrary(System.java:1657)
        at com.scanlibrary.Loader.load(Loader.java:14)
        at com.scanlibrary.ScanActivity.<clinit>(ScanActivity.java:125)
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Info:

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.1.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2
    ios-sim    : 6.1.2
    Node       : v8.11.1
    npm        : 5.8.0
    OS         : macOS High Sierra
    Xcode      : Xcode 9.3 Build version 9E145
@dylanvdmerwe
Copy link
Author

Why would it not find "libopencv_java3.so"?

@ChrisTomAlx
Copy link
Collaborator

I am looking into this issue right now. I will let you know when I have something. The android version of the plugin did work for you when using the scan.scanDoc(1 code provided in readme right ?

@dylanvdmerwe
Copy link
Author

This crash is on Android in an existing project where I added the plugin.

Other plugins used in this project:

code-push 2.0.4 "CodePushAcquisition"
cordova-plugin-appcenter-analytics 0.1.4 "App Center Analytics for Cordova"
cordova-plugin-appcenter-crashes 0.1.4 "App Center Crashes for Cordova"
cordova-plugin-appcenter-shared 0.1.3 "App Center shared code for Cordova"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-code-push 1.11.10 "CodePush"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-document-scanner 1.1.1 "Scan"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-storage 2.3.1 "Cordova sqlite storage plugin"
phonegap-plugin-barcodescanner 7.1.2 "BarcodeScanner"

@dylanvdmerwe
Copy link
Author

This one is concerning as I have no way to include this plugin to test in an existing project. What could be causing the exception? Is the plugin not installed correctly (i.e. libopencv_java3.so)?

@Varun-garg
Copy link

I have same issue, maybe this can fix it

@ChrisTomAlx
Copy link
Collaborator

Currently the scan library does not support 64 bit builds. This is most likely the cause. It says libopencv_java3.so is missing because it is looking within the 64 bit folder which does not exist. There must be a way to force a 32 bit build (Temporary solution). Looking into this right now. Will try and add 64 bit support as well.

@Varun-garg
Copy link

Varun-garg commented May 21, 2018

Thanks, @ChrisTomAlx for quickly investigating the issue.

@ChrisTomAlx
Copy link
Collaborator

This should work. Will be adding this to the plugin soon. In the meantime, if possible do let me know if this solution works in your apps. If it doesn't, I will try another route.

@ChrisTomAlx
Copy link
Collaborator

ChrisTomAlx commented May 21, 2018

For some reason, I can't seem to recreate this issue on my end. Tested on quiet a few devices. Trying to succeed at failure is harder than I thought it would be.

@Varun-garg @dylanvdmerwe Do let me know if you guys are having any luck at your end.

@Varun-garg
Copy link

Hi I am not good at gradle, and this config didn't work for me. Could you check it out.

allprojects {
	repositories {
		maven { 
			url 'https://jitpack.io' 
		}
	}
	
	defaultConfig {
	    
	    ndk {
		abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
	    }
	    android.useDeprecatedNdk=true
	}
}

dependencies {
	compile 'com.github.NeutrinosPlatform:scanlibrary:master-SNAPSHOT'
}

Could not including the line be the cause?

compile project(':scanlibrary')

@dylanvdmerwe
Copy link
Author

dylanvdmerwe commented May 21, 2018

I added the ndk stuff from the link above to my build.gradle file and the app no longer crashes which is very promising!

    defaultConfig {
        versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
        applicationId privateHelpers.extractStringFromManifest("package")

        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }

        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }
    }

System info

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.1.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2
    ios-sim    : 6.1.2
    Node       : v8.11.1
    npm        : 5.8.0
    OS         : macOS High Sierra
    Xcode      : Xcode 9.3.1 Build version 9E501

@Varun-garg
Copy link

hey @dylanvdmerwe could you send your full build.gradle?

@dylanvdmerwe
Copy link
Author

image

Here it is as a text file. Not sure if it helps or not.
build.gradle.txt

@Varun-garg
Copy link

Varun-garg commented May 21, 2018

Thanks @dylanvdmerwe , actually I was trying on build.gradle inside the plugin :p . With your help, following build.gradle now works.

allprojects {
	repositories {
		maven { 
			url 'https://jitpack.io' 
		}
	}	
}

android {
	defaultConfig {
		versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
		applicationId privateHelpers.extractStringFromManifest("package")

		if (cdvMinSdkVersion != null) {
		    minSdkVersion cdvMinSdkVersion
		}

		ndk {
		    abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
		}
	}
}

dependencies {
	// compile 'com.github.andrejlukasevic:document-scanner:4.0.0'
	compile 'com.github.NeutrinosPlatform:scanlibrary:master-SNAPSHOT'
}

@dylanvdmerwe
Copy link
Author

Awesome news. @ChrisTomAlx how do we get this change into the plugin so it's setup on adding of the plugin?

@ChrisTomAlx
Copy link
Collaborator

@dylanvdmerwe @Varun-garg Awesome!! Thanks for the help guys. I will implement this into the plugin now. Will get back to you once its done.

@ChrisTomAlx
Copy link
Collaborator

I have made changes to the library, but like I said, I wasn't able to test it. If you guys get the time please do test it out and let me know.

@ChrisTomAlx ChrisTomAlx self-assigned this May 22, 2018
@ChrisTomAlx ChrisTomAlx added the bug Something isn't working label May 22, 2018
@dylanvdmerwe
Copy link
Author

Let me know when I can test @ChrisTomAlx. I'm not seeing any commits.

@ChrisTomAlx
Copy link
Collaborator

@dylanvdmerwe I am making edits to the library. It did not work and so will be reverting back and looking for a new route to add this to the plugin. If all else fails will update documentation.

@ChrisTomAlx
Copy link
Collaborator

ChrisTomAlx commented May 23, 2018

@dylanvdmerwe I have made the necessary edits to the library, allowing it to use 32 bit builds. You won't see commits in the plugin. The plugin has the library as a dependency. I tested it out on my end with no problems. But I don't think it helps since my device is not using a 64 bit build. Please feel free to test it on your 64 bit device when you get the time.

If you run into issues, i will see what else can be done.

Thank you for taking the time to help us. Really appreciate it.

Oh here is the link to the library we are using in the plugin, if you guys need it. I have credited the original authors in my readme (You can get the link to the original library there).

@dylanvdmerwe
Copy link
Author

dylanvdmerwe commented May 23, 2018

I have just removed my platform and plugins folder and readded android@7.1.0.

The app crashes with the following error:

05-23 15:48:19.048 26908-26908/com.eightysixdegrees.antellogistics E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.eightysixdegrees.antellogistics, PID: 26908
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/base.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/lib/arm64, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/base.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.eightysixdegrees.antellogistics-7zZ3PioI3GBjlWh0dOJ6Yw==/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64]]] couldn't find "libopencv_java3.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
        at java.lang.System.loadLibrary(System.java:1657)
        at com.scanlibrary.Loader.load(Loader.java:14)
        at com.scanlibrary.ScanActivity.<clinit>(ScanActivity.java:125)
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

I checked the build.gradle file and it did not have the ndk stuff in.

        ndk {
            abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
        }

I added it manually in Android Studio as described above and the app ran properly and did not crash.

@Varun-garg
Copy link

Varun-garg commented May 24, 2018

Yup, It crashed!

@ChrisTomAlx This library could be very useful in an app that we are building, and we also appreciate the effort you are putting in it. Great work guys!

@Varun-garg
Copy link

Again, adding the following in plugins build.gradle fixed it.


android {
	defaultConfig {
		versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
		applicationId privateHelpers.extractStringFromManifest("package")

		if (cdvMinSdkVersion != null) {
		    minSdkVersion cdvMinSdkVersion
		}

		ndk {
		    abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
		}
	}
}

@ChrisTomAlx
Copy link
Collaborator

I guess a 64 bit build is the way to go now. Will be closing this issue after adding this info to the documentation and a 64 bit build will be added to the future enhancement plans.

Thank you guys for all the help!

@ChrisTomAlx
Copy link
Collaborator

Hey guys just letting you know this issue has been permanently fixed as of #24 . No workaround is required now. Please let me know if you run into any other troubles or if the fix doesn't work for you.

Cheers and have a nice day :)
Chris
Neutrinos

@dylanvdmerwe
Copy link
Author

Note that I still have to edit the gradle file otherwise this crashes. Retested on version 2.0.1.

@ChrisTomAlx ChrisTomAlx reopened this Oct 31, 2018
@ChrisTomAlx
Copy link
Collaborator

Added 64 bit architectures to the scan library. Should be permanently fixed now!

Cheers,
Chris
Neutrinos

@dylanvdmerwe
Copy link
Author

@ChrisTomAlx I have just cloned one of my projects and added android as a platform from scratch (deleted plugins folder) and when I run ionic cordova run android on a device, the crash still persists. Version 2.0.1 of the cordova-plugin-document-scanner plugin.

In Android Studio you still need to edit the gradle file as per my instructions above to prevent the crash.

Maybe I am missing something?

@ChrisTomAlx
Copy link
Collaborator

Released version 2.0.2. Could you let me know if you are still facing this issue in this version?

Cheers,
Chris
Neutrinos

@ChrisTomAlx ChrisTomAlx changed the title Android Crash Android Crash - 64 bit architecture missing Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working change documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants