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

loading opencv error #20

Closed
heinhoang opened this issue May 13, 2020 · 17 comments
Closed

loading opencv error #20

heinhoang opened this issue May 13, 2020 · 17 comments

Comments

@heinhoang
Copy link

I do the similar to the example but it pulls out error:

I/Choreographer( 3440): Skipped 68 frames!  The application may be doing too much work on its main thread.
W/art     ( 3440): Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
I/art     ( 3440): Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
I/art     ( 3440):   at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2559)
I/art     ( 3440):   at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
I/art     ( 3440):   at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
I/art     ( 3440):   at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
I/art     ( 3440):   at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
I/art     ( 3440):   at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
I/art     ( 3440):   at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
I/art     ( 3440):   at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
I/art     ( 3440):   at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
I/art     ( 3440):   at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
I/art     ( 3440):   at void com.sample.edgedetection.base.BaseActivity.onCreate(android.os.Bundle) (BaseActivity.kt:13)
I/art     ( 3440):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6662)
I/art     ( 3440):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
I/art     ( 3440):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2599)
I/art     ( 3440):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2707)
I/art     ( 3440):   at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/art     ( 3440):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1460)
I/art     ( 3440):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
I/art     ( 3440):   at void android.os.Looper.loop() (Looper.java:154)
I/art     ( 3440):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
I/art     ( 3440):   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art     ( 3440):   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)
I/art     ( 3440):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)
I/art     ( 3440): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.tekree.scann-1/base.apk"],nativeLibraryDirectories=[/data/app/com.tekree.scann-1/lib/x86, /data/app/com.tekree.scann-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
I/art     ( 3440):   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
I/art     ( 3440):   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
I/art     ( 3440):   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
I/art     ( 3440):   at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2559)
I/art     ( 3440):   at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
I/art     ( 3440):   at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2)
I/art     ( 3440):   at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727)
I/art     ( 3440):   at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858)
I/art     ( 3440):   at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426)
I/art     ( 3440):   at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377)
I/art     ( 3440):   at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
I/art     ( 3440):   at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
I/art     ( 3440):   at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
I/art     ( 3440):   at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
I/art     ( 3440):   at void com.sample.edgedetection.base.BaseActivity.onCreate(android.os.Bundle) (BaseActivity.kt:13)
I/art     ( 3440):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6662)
I/art     ( 3440):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118)
I/art     ( 3440):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2599)
I/art     ( 3440):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2707)
I/art     ( 3440):   at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
I/art     ( 3440):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1460)
I/art     ( 3440):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
I/art     ( 3440):   at void android.os.Looper.loop() (Looper.java:154)
I/art     ( 3440):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
I/art     ( 3440):   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art     ( 3440):   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:866)
I/art     ( 3440):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:756)
I/art     ( 3440): 
D/OpenCV/StaticHelper( 3440): Trying to get library list
E/OpenCV/StaticHelper( 3440): OpenCV error: Cannot load info library for OpenCV
D/OpenCV/StaticHelper( 3440): Library list: ""
D/OpenCV/StaticHelper( 3440): First attempt to load libs
D/OpenCV/StaticHelper( 3440): Trying to init OpenCV libs
D/OpenCV/StaticHelper( 3440): Trying to load library opencv_java3
D/OpenCV/StaticHelper( 3440): Cannot load library "opencv_java3"
W/System.err( 3440): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.tekree.scann-1/base.apk"],nativeLibraryDirectories=[/data/app/com.tekree.scann-1/lib/x86, /data/app/com.tekree.scann-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libopencv_java3.so"
W/System.err( 3440): 	at java.lang.Runtime.loadLibrary0(Runtime.java:972)
W/System.err( 3440): 	at java.lang.System.loadLibrary(System.java:1530)
W/System.err( 3440): 	at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64)
W/System.err( 3440): 	at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95)
W/System.err( 3440): 	at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39)
W/System.err( 3440): 	at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:102)
W/System.err( 3440): 	at com.sample.edgedetection.scan.ScanActivity.prepare(ScanActivity.kt:36)
W/System.err( 3440): 	at com.sample.edgedetection.base.BaseActivity.onCreate(BaseActivity.kt:16)
W/System.err( 3440): 	at android.app.Activity.performCreate(Activity.java:6662)
W/System.err( 3440): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
W/System.err( 3440): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
W/System.err( 3440): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
W/System.err( 3440): 	at android.app.ActivityThread.-wrap12(ActivityThread.java)
W/System.err( 3440): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
W/System.err( 3440): 	at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 3440): 	at android.os.Looper.loop(Looper.java:154)
W/System.err( 3440): 	at android.app.ActivityThread.main(ActivityThread.java:6077)
W/System.err( 3440): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 3440): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
W/System.err( 3440): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
D/OpenCV/StaticHelper( 3440): First attempt to load libs fails
I/ScanActivity( 3440): loading opencv error, exit

@sawankumarbundelkhandi
Copy link
Owner

Make sure you have included the jnilibs folder. From the error, it seems that the code is not able to find OpenCV

@RobyFerro
Copy link

RobyFerro commented May 19, 2020

I've found the same error. Why should I include the jnilibs folder? This shouldn't be done automatically? Maybe you've missed something in the readme?

@AlirezaDaryani
Copy link

i have the same error, if we must add some code in android or ios side, you must write it in readme.

@sawankumarbundelkhandi
Copy link
Owner

I am not sure if you are running the example app or using the code from example app. If you are running the example app then it should work out of the box.

If you have installed the plugin from the pub.dev and the using the code from example then also it should work as the JNI files are already there in the pub.dev plugin.

@AlirezaDaryani
Copy link

I found the solvation.
this app doesn’t work on emulator bcz no arm detection.
run app in real device in release mode will solve issue.

@RobyFerro
Copy link

This is not a real "solution". How can you deploy something without testing it?

@sawankumarbundelkhandi
Copy link
Owner

@RobyFerro I have tested it on Nexus6p and iPhone6s and it's working fine. If for some reason it's not working on your device then use Device Logcat in android studio and then open the app. If it crashes or throws some error then it will be logged in the Logcat.

@RobyFerro
Copy link

@sawankumarbundelkhandi Ok but is tested only in a "demo" app. At the moment is not possible to implement this feature on a custom application.

@sawankumarbundelkhandi
Copy link
Owner

@RobyFerro I have installed it on a new application (flutter create test_app) from pub.dev and it works.

@AlirezaDaryani
Copy link

@sawankumarbundelkhandi Are u test it in emulator?

@Amitbhave
Copy link

This is the error that I am getting on emulator.

D/OpenCV/StaticHelper( 7463): Trying to get library list
E/OpenCV/StaticHelper( 7463): OpenCV error: Cannot load info library for OpenCV
D/OpenCV/StaticHelper( 7463): Library list: ""
D/OpenCV/StaticHelper( 7463): First attempt to load libs
D/OpenCV/StaticHelper( 7463): Trying to init OpenCV libs
D/OpenCV/StaticHelper( 7463): Trying to load library opencv_java3
D/OpenCV/StaticHelper( 7463): Cannot load library "opencv_java3"
W/System.err( 7463): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.DocScanner-C1yV27uln5lm8u3o7er-9w==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.DocScanner-C1yV27uln5lm8u3o7er-9w==/lib/x86, /data/app/com.example.DocScanner-C1yV27uln5lm8u3o7er-9w==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libopencv_java3.so"

@Hesamedin
Copy link

Hesamedin commented Oct 7, 2020

I have the same problem. I cannot test my app on emulators at all but I am able to test on a real device. So, I test it on my device always. I tested on a few emulators such as Pixel 2, Pixel 3, Pixel XL with no luck.

@sawankumarbundelkhandi
Copy link
Owner

sawankumarbundelkhandi commented Oct 7, 2020

@Amitbhave, @Hesamedin I have never tested this plugin on an android emulator or an ios simulator. I have always run it on a real device.

@sawankumarbundelkhandi
Copy link
Owner

@Amitbhave @AlirezaDaryani @heinhoang Can you please try it on an x86_64 emulator? I believe you are getting this error as the plugin doesn't include x86 openCV files.

image

@sawankumarbundelkhandi
Copy link
Owner

Here is the screenshot of the example app running on the Android SDK 30 x86_64 emulator. I have given my configuration screenshot as well

image

image

@sawankumarbundelkhandi
Copy link
Owner

sawankumarbundelkhandi commented May 15, 2021

I have added x86 files as well to the project. and It should work now. The files can't be published with a pub package as there is a limit of 100 MB for a package. So anyone who wants to run this package on an x86/x86_64 emulator/ device has to use the plugin from GitHub.

You can use it directly from Github in pubspec.yaml like
edge_detection:
git: https://github.com/sawankumarbundelkhandi/edge_detection.git

@jelenalecic
Copy link

I have added x86 files as well to the project. and It should work now. The files can't be published with a pub package as there is a limit of 100 MB for a package. So anyone who wants to run this package on an x86/x86_64 emulator/ device has to use the plugin from GitHub.

You can use it directly from Github in pubspec.yaml like edge_detection: git: https://github.com/sawankumarbundelkhandi/edge_detection.git

This worked for me!

edge_detection: git: url: https://github.com/sawankumarbundelkhandi/edge_detection.git

Thanks :) please put this in your readme!

@sawankumarbundelkhandi sawankumarbundelkhandi unpinned this issue Sep 27, 2023
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

7 participants