SandroMachado / openalpr-android

Android Automatic License Plate Recognition library (http://www.openalpr.com) ported for android.
Apache License 2.0
770 stars 272 forks source link

Crash caused by missing libopenalpr-native.so #1

Closed ZKjellberg closed 8 years ago

ZKjellberg commented 8 years ago

Testing your application and I am receiving a crash when submitting the image. This was tested using the Sample app source code from this repository on a Nexus 6 running Android 6.0.1.

FATAL EXCEPTION: AsyncTask #1
Process: com.sandro.openalprsample, PID: 12850
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sandro.openalprsample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sandro.openalprsample-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libopenalpr-native.so"
    at java.lang.Runtime.loadLibrary(Runtime.java:367)
    at java.lang.System.loadLibrary(System.java:1076)
    at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9)
    at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78)
    at com.sandro.openalprsample.MainActivity$2.run(MainActivity.java:87)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
    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)
Force finishing activity com.sandro.openalprsample/.MainActivity
Screenshot max retries 4 of Token{5009e4b ActivityRecord{537f31a u0 com.sandro.openalprsample/.MainActivity t5613 f}} appWin=Window{73392ed u0 com.sandro.openalprsample/com.sandro.openalprsample.MainActivity} drawState=3
Process com.sandro.openalprsample (pid 12850) has died
ZKjellberg commented 8 years ago

This error occurs when depending on the source within Android Studio, which is very awkward as the repo is structured as two seperate Android Studio projects with relative path references that didn't seem to work for me until I merged them into one project.

I also tested using the JitPack release and received the same error. I did have issues with the JitPack dependency as Android Studio could not resolve the suggested aar with the transitive flag, but using the reference: compile 'com.github.SandroMachado:openalpr-android:1.0.0' compiled.

ZKjellberg commented 8 years ago

Sample image used: https://commons.wikimedia.org/wiki/File:AZ_1950_license_plate.JPG

It appears the issue is related to how I am handling the dependency for the project with the missing libopenalpr-native.so binary.

SandroMachado commented 8 years ago

Hey @ZKjellberg

About the jitpack import error. With the transitve syntax it should work... but looks like it is not working, so I updated the README of the project with your suggestion. Thanks

Can you please confirm that merging the project you didn't miss the assets folder in the sample application?

I also generated an apkapp-debug.apk.zip, can you also please test with it and verify if the problem persists?

I also updated the master with a fix to the sample project be able to compile out of the box. Can you please fetch the lastest master commits and try to open the sample project with Android Studio from this folder.

Bryanli910 commented 8 years ago

Hi @SandroMachado

I just tried importing it straight from your master and the sample project you provided, I receive similar errors:

20187-22048/com.sandro.openalprsample E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1 Process: com.sandro.openalprsample, PID: 20187 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sandro.openalprsample-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]] couldn't find "libopenalpr-native.so"

ZKjellberg commented 8 years ago

@SandroMachado I tested using your app-debug-apk.zip install. When I submit my picture, the application gets stuck on Parsing Result. In the logs, it appears there is an error.

12-16 09:55:42.180: I/ActivityManager(615): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.sandro.openalprsample/.MainActivity bnds=[800,760][1000,1036] (has extras)} from uid 10026 on display 0
12-16 09:55:42.223: I/ActivityManager(615): Start proc 17962:com.sandro.openalprsample/u0a88 for activity com.sandro.openalprsample/.MainActivity
12-16 09:55:42.589: I/ActivityManager(615): Displayed com.sandro.openalprsample/.MainActivity: +377ms
12-16 09:55:48.548: W/System.err(17962):    at com.sandro.openalprsample.MainActivity.onActivityResult(MainActivity.java:77)

Line 77 is the below item, oddly the variable in is labeled as never used.

FileInputStream in = new FileInputStream(destination);

Reviewing the application permissions, it appears the issue is you never ask the user for permission to use their storage. When the user manually enables this from the Settings page, the application successfully runs.

ZKjellberg commented 8 years ago

When compiling from the latest source code, I am still experiencing a crash searching for the binary:

Displayed com.sandro.openalprsample/.MainActivity: +369ms
FATAL EXCEPTION: AsyncTask #1
Process: com.sandro.openalprsample, PID: 21666
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sandro.openalprsample-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sandro.openalprsample-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libopenalpr-native.so"
   at java.lang.Runtime.loadLibrary(Runtime.java:367)
   at java.lang.System.loadLibrary(System.java:1076)
   at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9)
   at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78)
   at com.sandro.openalprsample.MainActivity$2.run(MainActivity.java:86)
   at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
   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)
ZKjellberg commented 8 years ago

Regarding the APK you released, the failure for Parsing Result to advance is because you target SDK 23 which assumes you implement the new Android 6.0's permission system. I am pushing up code which should resolve this issue. Feel free to change the workflow.

SandroMachado commented 8 years ago

Hey @ZKjellberg and @Bryanli910

I think I have finally found the issue. Can you please try again with the master latest code?

ZKjellberg commented 8 years ago

Tested, application is now working. Thanks for the fix.

SandroMachado commented 8 years ago

Great! Thanks for the help! I will make a release with this fix.

SandroMachado commented 8 years ago

Closed by 1.0.1.

christophermaster commented 6 years ago

Hey @SandroMachado I have a problem with the last version of your example project, it shows me the following error.

couldn't find "libopenalpr-native.so"

How can I solve this error?

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.sandro.openalprsample, PID: 3068 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sandro.openalprsample-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopenalpr-native.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:989) at org.openalpr.AlprJNIWrapper.<clinit>(AlprJNIWrapper.java:9) at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:78) at com.sandro.openalprsample.MainActivity$2.run(MainActivity.java:83) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

AmritanshuAVerma commented 5 years ago

hi, The project compiled successfully but run i get the following error,

OpenALPR: Couldn't create instance of OpenALPRFactory because of following error: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.github.Lildan.openalpr-4o1CQODavsPU9KY6jOwpcA==/base.apk"],nativeLibraryDirectories=[/data/app/com.github.Lildan.openalpr-4o1CQODavsPU9KY6jOwpcA==/lib/x86, /system/fake-libs, /data/app/com.github.Lildan.openalpr-4o1CQODavsPU9KY6jOwpcA==/base.apk!/lib/x86, /system/lib]]] couldn't find "libopenalpr-native.so", at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x00069] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0 at Android.Runtime.JNIEnv.CallStaticObjectMethod (System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue parms) [0x00000] in /Users/builder/jenkins/workspace/monodroid-multibranch_d16-1/monodroid/external/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:562 at Org.Openalpr.OpenALPRFactory.Create (Android.Content.Context context, System.String androidDataDir) [0x00060] in C:\Users\Amritanshu.Verma\Source\Repos\alpr-xamarin\OpenALPR Xamarin.Android Binding\obj\Debug\generated\src\Org.Openalpr.IOpenALPR.cs:40 at OpenALPR_Xamarin.Android_Library.OpenALPR..ctor (Android.Content.Context context, System.String androidDataDirPath, System.String openAlprConfigFilePath, System.String country, System.String region) [0x00027] in C:\Users\Amritanshu.Verma\Source\Repos\alpr-xamarin\OpenALPR Xamarin.Android Library\OpenALPR.cs:40 --- End of managed Java.Lang.UnsatisfiedLinkError stack trace --- java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.github.Lildan.openalpr-4o1CQODavsPU9KY6jOwpcA==/base.apk"],nativeLibraryDirectories=[/data/app/com.github.Lildan.openalpr-4o1CQODavsPU9KY6jOwpcA==/lib/x86, /system/fake-libs, /data/app/com.github.Lildan.openalpr-4o1CQODavsPU9KY6jOwpcA==/base.apk!/lib/x86, /system/lib]]] couldn't find "libopenalpr-native.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1012) at java.lang.System.loadLibrary(System.java:1669) at org.openalpr.AlprJNIWrapper.(AlprJNIWrapper.java:9) at org.openalpr.OpenALPR$Factory.create(OpenALPR.java:80) at md54530389541a05e758392af3892755e5e.Camera2BasicFragment.n_onCreate(Native Method) at md54530389541a05e758392af3892755e5e.Camera2BasicFragment.onCreate(Camera2BasicFragment.java:38) at android.app.Fragment.performCreate(Fragment.java:2503) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1256) at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1576) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1637) at android.app.BackStackRecord.executeOps(BackStackRecord.java:807) at android.app.FragmentManagerImpl.executeOps(FragmentManager.java:2405) at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200) at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2155) at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2062) at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3051) at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2998) at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:182) at android.app.Activity.performCreate(Activity.java:7143) at android.app.Activity.performCreate(Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

spalanci commented 4 years ago

Maybe it's late. Let me write it anyway.

I think it gives error for 64 bit. So add defaultconfig to build.gradle -> ndk {abiFilters "armeabi-v7a"}

But you will only get a 32 bit apk

AmritanshuAVerma commented 4 years ago

Thanks for the reply,

You did good work on the library ,I appreciate it.

Regards, Amritanshu.Verma

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: Soner PALANCImailto:notifications@github.com Sent: 16 July 2020 18:20 To: SandroMachado/openalpr-androidmailto:openalpr-android@noreply.github.com Cc: Amritanshu Vermamailto:amritanshu.verma@outlook.com; Commentmailto:comment@noreply.github.com Subject: Re: [SandroMachado/openalpr-android] Crash caused by missing libopenalpr-native.so (#1)

Maybe it's late. Let me write it anyway.

I think it gives error for 64 bit. So add defaultconfig to build.gradle -> ndk {abiFilters "armeabi-v7a"}

But you will only get a 32 bit apk

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/SandroMachado/openalpr-android/issues/1#issuecomment-659389425, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJULRIUCNMFK23WGMIG42BTR33ZQ7ANCNFSM4BWWJWMQ.

alitele commented 3 years ago

Anyone successfully generated 64bit APK yet? Please help . Thanks