Couldn't find "libjniopencv_core.so" - java

I'm developping an android app using opencv and i'm stuck with a problem ...
The error i'm having is :
FATAL EXCEPTION: AsyncTask #3
Process: com.sogeti.innovation.obcapture, PID: 29681
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
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)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sogeti.innovation.obcapture-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sogeti.innovation.obcapture-1/lib/arm, /data/app/com.sogeti.innovation.obcapture-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libjniopencv_core.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:804)
at org.bytedeco.javacpp.Loader.load(Loader.java:613)
at org.bytedeco.javacpp.Loader.load(Loader.java:530)
at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at org.bytedeco.javacpp.Loader.load(Loader.java:585)
at org.bytedeco.javacpp.Loader.load(Loader.java:530)
at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.<clinit>(opencv_core.java:109)
at com.sogeti.innovation.obcapture.bl.mobile.alg.ImageProcessingHelper.liveProcessImage(ImageProcessingHelper.java:46)
at com.sogeti.innovation.obcapture.bl.LiveProcessImage.doInBackground(LiveProcessImage.java:35)
at com.sogeti.innovation.obcapture.bl.LiveProcessImage.doInBackground(LiveProcessImage.java:21)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
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) 
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sogeti.innovation.obcapture-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sogeti.innovation.obcapture-1/lib/arm, /data/app/com.sogeti.innovation.obcapture-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libopencv_imgproc.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:804)
at org.bytedeco.javacpp.Loader.load(Loader.java:604)
at org.bytedeco.javacpp.Loader.load(Loader.java:530) 
at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10) 
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:324) 
at org.bytedeco.javacpp.Loader.load(Loader.java:585) 
at org.bytedeco.javacpp.Loader.load(Loader.java:530) 
at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.<clinit>(opencv_core.java:109) 
at com.sogeti.innovation.obcapture.bl.mobile.alg.ImageProcessingHelper.liveProcessImage(ImageProcessingHelper.java:46) 
at com.sogeti.innovation.obcapture.bl.LiveProcessImage.doInBackground(LiveProcessImage.java:35) 
at com.sogeti.innovation.obcapture.bl.LiveProcessImage.doInBackground(LiveProcessImage.java:21) 
at android.os.AsyncTask$2.call(AsyncTask.java:295) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
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)
Here is what the build.graddle file contains :
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.sogeti.innovation.obcapture"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled false
additionalParameters("jack.incremental" : "true")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/1.2/javacpp-presets-1.2.pom.xml'
pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/org.bytedeco.javacpp-presets-1.2.pom.xml'
}
}
dependencies {
compile files('libs/javacpp-1.3.jar')
compile files('libs/javacv-1.3.jar')
compile files('libs/opencv-3.1.0-1.3-android-arm.jar')
compile files('libs/opencv-3.1.0-1.3.jar')
compile files('libs/ffmpeg-3.2.1-1.3-android-arm.jar')
compile files('libs/ffmpeg-3.2.1-1.3.jar')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/maps.jar')
compile "com.android.support:appcompat-v7:24.1.1"
compile "com.android.support:cardview-v7:24.1.1"
compile "com.android.support:recyclerview-v7:24.1.1"
compile "com.android.support:design:24.1.1"
compile "com.android.support:support-v4:24.1.1"
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.github.bluejamesbond:textjustify-android:2.1.1'
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.android.support:multidex:1.0.0'
compile 'com.squareup.okio:okio:1.8.0'
compile 'commons-codec:commons-codec:1.9'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.android.support:multidex:1.0.1'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
compile project(':common')
compile project(':commonwidget')
compile project(':panowidget')
compile project(':base')
}
And here is the settings.graddle file :
include ':app', ":common", ":commonwidget", ":panowidget", ":base"
Everything was working fine until I added the package "base".
Thanks in advance for your help :D
EDIT : Thanks to #Prateek answer I created the JNILibs folder and then added the .so files needed. But there was a problem because I don't have all the versions needed (arm64-v8a, armeabi, armeabi-v7a ...) and especially the one concerning my phone. So I tried to download it from here but the files are not shared object .so but static .a so it doesn't work ... Could anyone help me on that ? :)
SOLUTION : I have only the 32 bit version of library files ".so". So what I did is, like #Prateek said, to place this files in the subfolders "armeabi", "armeabi-v7a", "mips" and "x86" of the folder "JNILibs". Then I forced the usage of the 32 bit files by adding the ndk specification in the "build.graddle" app file as below.
android {
compileSdkVersion 24
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.sogeti.innovation.obcapture"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled false
additionalParameters("jack.incremental" : "true")
}
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
}
Hope it can helps someone :)

Did you put libjniopencv_core.so file in JNI folder?

Related

java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found

I'm developing a face recognition application using android and openCV. My android studio version is 3.5.3 and openCV version is 3.4.10. The phone on which I'm running my application is arm64-v8a and I'm getting this error :
2020-04-15 15:00:40.425 15788-15788/com.example.opencvdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.opencvdemo, PID: 15788
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.opencvdemo-o8BNe1NoZik-avIk3otJaw==/lib/arm64/libjniopencv_contrib.so" is 32-bit instead of 64-bit
at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:586)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.opencv_contrib.<clinit>(opencv_contrib.java:97)
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
at com.example.opencvdemo.CtrRecognizer.<init>(CtrRecognizer.java:40)
at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94)
at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1956)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1988)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.opencvdemo-o8BNe1NoZik-avIk3otJaw==/lib/arm64/libopencv_contrib.so" is 32-bit instead of 64-bit
at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:577)
at com.googlecode.javacpp.Loader.load(Loader.java:540) 
at com.googlecode.javacv.cpp.opencv_contrib.<clinit>(opencv_contrib.java:97) 
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method) 
at com.example.opencvdemo.CtrRecognizer.<init>(CtrRecognizer.java:40) 
at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94) 
at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319) 
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1956) 
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1988) 
at android.os.Handler.handleCallback(Handler.java:883) 
at android.os.Handler.dispatchMessage(Handler.java:100) 
at android.os.Looper.loop(Looper.java:224) 
at android.app.ActivityThread.main(ActivityThread.java:7520) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
2020-04-15 15:00:40.427 15788-15788/com.example.opencvdemo E/MQSEventManagerDelegate: failed to get MQSService.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
//buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.opencvdemo"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = ['src/main/jniLibs']
jniLibs.srcDir 'src/main/libs'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.so'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.github.markushi:circlebutton:1.1'
implementation project(path: ':openCV3410')
}
For removing this error I made changes to my build.gradle as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
//buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.opencvdemo"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
}
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = ['src/main/jniLibs']
jniLibs.srcDir 'src/main/libs'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar','*.so'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.github.markushi:circlebutton:1.1'
implementation project(path: ':openCV3410')
}
Now I'm getting this error :
2020-04-15 15:11:19.353 17892-17892/com.example.opencvdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.opencvdemo, PID: 17892
java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:586)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.opencv_contrib.<clinit>(opencv_contrib.java:97)
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
at com.example.opencvdemo.CtrRecognizer.<init>(CtrRecognizer.java:40)
at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94)
at com.example.opencvdemo.MainActivity.onResume(MainActivity.java:233)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
at android.app.Activity.performResume(Activity.java:8050)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4236)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4278)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:577)
at com.googlecode.javacpp.Loader.load(Loader.java:540) 
at com.googlecode.javacv.cpp.opencv_contrib.<clinit>(opencv_contrib.java:97) 
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method) 
at com.example.opencvdemo.CtrRecognizer.<init>(CtrRecognizer.java:40) 
at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94) 
at com.example.opencvdemo.MainActivity.onResume(MainActivity.java:233) 
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454) 
at android.app.Activity.performResume(Activity.java:8050) 
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4236) 
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4278) 
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:224) 
at android.app.ActivityThread.main(ActivityThread.java:7520) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
2020-04-15 15:11:19.361 17892-17892/com.example.opencvdemo E/MQSEventManagerDelegate: failed to get MQSService.
According to the stack trace: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.opencvdemo-o8BNe1NoZik-avIk3otJaw==/lib/arm64/libjniopencv_contrib.so" is 32-bit instead of 64-bit
So I suppose that your library doesn't have resources for arm64-v8a, to solve this problem you must add to your project opencv .so files for arm64-v8a arch
Follow these steps if you are getting .so file not found in jniLibs folder
1- add source path in android in buildgradle file below defaultConfig
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
2- add ndk in defaultConfig in buildgradle file. abifilters can be found in jniLibs folders containing missing files.
ndk{
abiFilters 'armeabi-v7a'
}
if not resolved then visit this link https://blog.csdn.net/u010920692/article/details/114476490

Caused by: java.lang.NoSuchMethodError: No static method newFactory()

I'm building an Android application and facing a no static method exception when trying to read the XLSX files.
Tried all possibilities like updating dependencies in app/build.gradle, but no avail.
Kindly help me to resolve this issue.
Exception causing line in code: XSSFWorkbook myWorkBook = new XSSFWorkbook(fis);
08-07 12:37:05.828 16406-16511/droidmentor.tabwithviewpager E/AndroidRuntime:
FATAL EXCEPTION: AsyncTask #1
Process: droidmentor.tabwithviewpager, PID: 16406
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.NoSuchMethodError: No static method newFactory()Ljavax/xml/stream/XMLEventFactory; in class Ljavax/xml/stream/XMLEventFactory; or its super classes (declaration of 'javax.xml.stream.XMLEventFactory' appears in /data/app/droidmentor.tabwithviewpager-2/split_lib_dependencies_apk.apk)
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:87)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:254)
at droidmentor.tabwithviewpager.Fragment.ChatFragment$LongOperation.readXLSX(ChatFragment.java:191)
at droidmentor.tabwithviewpager.Fragment.ChatFragment$LongOperation.doInBackground(ChatFragment.java:112)
at droidmentor.tabwithviewpager.Fragment.ChatFragment$LongOperation.doInBackground(ChatFragment.java:88)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
I'm adding app.gradle file. The other codes are basic XLSX file reading using XSSF. When I tried to run this java snippet in Spring Suite Tool, it runs properly. However, When I integrate those java snippets into the Android app, it causing this runtime exception.
App.Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "droidmentor.tabwithviewpager"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:25.0.0'
//noinspection GradleCompatible
compile 'com.android.support:design:25.0.+'
compile 'org.apache.poi:poi:3.10-FINAL'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.poi:poi:3.11-beta2'
compile 'org.apache.poi:poi-ooxml:3.11-beta2'
compile 'javax.inject:javax.inject:1'
compile 'javax.servlet:servlet-api:2.5'
compile 'javax.servlet.jsp:jsp-api:2.1'
compile 'javax.servlet:jstl:1.2'
compile 'junit:junit:4.7'
compile 'net.sf.opencsv:opencsv:2.3'
compile 'org.apache.poi:poi-ooxml:2.3'
compile 'org.apache.poi:poi-ooxml-schemas:3.8'
compile 'org.apache.xmlbeans:xmlbeans:2.3.0'
compile 'dom4j:dom4j:1.6.1'
}
Check if you are applying any obfuscation on your apk, if yes, you need to -keep those packages and classes so that they won't be stripped by proguard.

Getting no class def error when using a specific library

I am getting a NoClassDefFoundError only when I use a specific library along with the adobe aviary library.
Gradle and error are shown below Code seem to be working when I don't use that crop library. I really want to use that library as all of my code is configured according to it. Please give me a solution for this
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.jetslice.retroart1"
manifestPlaceholders = [appPackageName: "com.jetslice.retroart1"]
minSdkVersion 19
targetSdkVersion 26
renderscriptTargetApi 21
renderscriptSupportModeEnabled true
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
jumboMode true
}
dexOptions {
javaMaxHeapSize "64k"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.clans:fab:1.6.4'
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:3.8.0'
compile 'com.adobe.creativesdk.foundation:assetux:0.9.1251'
compile 'com.adobe.creativesdk.foundation:assetcore:0.9.1251'
compile 'com.android.support:multidex:1.0.1'
compile 'com.ms.square:glassview:0.1.0'
compile 'com.android.support:support-v4:26.+'
compile 'com.jpeng:jpspringmenu:1.0.1'
compile 'com.github.mzelzoghbi:zgallery:0.3'
compile 'com.github.doctoror.particlesdrawable:library:1.0.8'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'hanks.xyz:htextview-library:0.1.5'
compile 'com.github.MorochoRochaDarwin:HorizontalScrollMenu:2.0.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
testCompile 'junit:junit:4.12'
}
Error:
02-19 18:55:48.042 25223-25223/com.jetslice.retroart1 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jetslice.retroart1, PID: 25223
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/AsyncTaskCompat;
at com.adobe.creativesdk.aviary.AdobeImageEditorActivityAbstract.loadTools(AdobeImageEditorActivityAbstract.java:760)
at com.adobe.creativesdk.aviary.AdobeImageEditorActivityAbstract.onPostCreate(AdobeImageEditorActivityAbstract.java:579)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1195)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2542)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.os.AsyncTaskCompat" on path: DexPathList[[zip file "/data/app/com.jetslice.retroart1-1/base.apk"],nativeLibraryDirectories=[/data/app/com.jetslice.retroart1-1/lib/arm, /data/app/com.jetslice.retroart1-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.adobe.creativesdk.aviary.AdobeImageEditorActivityAbstract.loadTools(AdobeImageEditorActivityAbstract.java:760)
at com.adobe.creativesdk.aviary.AdobeImageEditorActivityAbstract.onPostCreate(AdobeImageEditorActivityAbstract.java:579)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1195)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2542)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Suppressed: java.lang.ClassNotFoundException: android.support.v4.os.AsyncTaskCompat
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Android Studio 2.3 update error on jdbc connector

my app has mysql-connector-java-5.1.34.jar in libs folder and it was working fine. Now after yesterday's update to android studio 2.3, I start getting error
Suppressed: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.Class.classForName(Native Method)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-05 15:25:22.696 17274-17618/jss.smartapp W/System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
I tried to change MySQL connector with 6.0.5 the latest downloaded and try to compile, it is giving another error
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
How to fix it. though I tried to find some information on above here
Android: Dex cannot parse version 52 byte code
but nothing worked for me, below is my updated gradle.
compileSdkVersion 25
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "jss.smartapp"
minSdkVersion 19
targetSdkVersion 25
versionCode 12
versionName "1.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.SigningInfo
}
debug {
signingConfig signingConfigs.SigningInfo
}
}
productFlavors {
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def A_FIELD = "A_FIELD"
internal {
buildConfigField BOOLEAN, A_FIELD, FALSE
}
official {
buildConfigField BOOLEAN, A_FIELD, TRUE
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
//For Instamojo.
compile 'com.instamojo:android-sdk:+'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
//Apache IO
compile files('libs/commons-io-2.5.jar')
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'

Dex Exception - I can't resolve

I have this error and I can't resolve it, I looking for interhet but not working...
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzzf;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "sk.tipos.paradox02.citaj"
minSdkVersion 11
targetSdkVersion 23
versionCode 26
versionName '2.0021'
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
// signingConfig signingConfigs.release
}
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.firebase:firebase-ads:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.google.firebase:firebase-crash:9.0.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.android.support:design:23.0.0'
}
Error shown if I launch app. If rebuild project everything OK but when run project..
you are have several duplicate versions of library, keep only what you need nothing extra, Even after removing the duplicate libraries you are facing this error then try enabling multidex
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
in manifest inside application tag
<application
android:name="android.support.multidex.MultiDexApplication">
</application>
refer this
You've got both version 10.0.1 and 9.0.0 of 'com.google.firebase:firebase-ads'.
Remove the 10.0.1 version, as everything else is 9.0.0 and they should always have the same version.
This can be a lot of problems, but I believe this one is related to multidexing. You are enabling multidexing for the project and that's ok but this needs the multidex support library to be able to work on pre-Lolliopop.
Please add this to your dependencies
compile 'com.android.support:multidex:1.0.1'

Categories