I have the following code in xml file:
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id = "#+id/buttonsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity = "center"
app:columnCount="4"
app:rowCount="4"
app:useDefaultMargins="false"
>
</android.support.v7.widget.GridLayout>
and I'm filling this GridLayout dynamicly so I'm trying to get the object with:
android.support.v7.widget.GridLayout gl =
(android.support.v7.widget.GridLayout)findViewById(R.id.buttonsLayout);
Which gives me the following error:
Caused by: java.lang.ClassCastException: android.support.v7.internal.widget.TintButton cannot be cast to android.support.v7.widget.GridLayout at com.education4all.mathcoach.TaskActivity.onCreate(TaskActivity.java:134)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4575)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
This is very strange because this code used to work and suddenly this error appears. Why could that be?
build_gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.education4all.mathcoach"
minSdkVersion 10
targetSdkVersion 22
versionName '1.0.2'
versionCode 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:gridlayout-v7:18.0.+'
}
Try to use a higher version of the support library, i.e.: com.android.support:appcompat-v7:22.+, clean and try to run the project.
You can also use the latest version of the GridLayout as well.
Related
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
I've added the my Connector/j 8.0 mysql-connector-java-8.0.16.jar file to my libs folder and added an entry in my app module build.gradle file.
But I get a java.lang.NoSuchMethodError exception when i try to Class.forName("com.mysql.cj.jdbc.Driver").newInstance() which is below:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.testmate.hscmate, PID: 10196
java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.<clinit>(AbandonedConnectionCleanupThread.java:58)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.mysql.cj.jdbc.NonRegisteringDriver.<clinit>(NonRegisteringDriver.java:99)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at com.testmate.hscmate.MainActivity$onNavigationItemSelectedListener$1.onNavigationItemSelected(MainActivity.kt:24)
at com.google.android.material.bottomnavigation.BottomNavigationView$1.onMenuItemSelected(BottomNavigationView.java:204)
at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:840)
at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158)
at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)
at com.google.android.material.bottomnavigation.BottomNavigationMenuView$1.onClick(BottomNavigationMenuView.java:115)
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3400(View.java:801)
at android.view.View$PerformClick.run(View.java:27301)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7319)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)
here is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.testmate.hscmate"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation files('libs/mysql-connector-java-8.0.16.jar')
}
As far as I can tell, kotlin is finding the .jar, because otherwise it would be a ClassNotFoundException but it seems my SDK or JRE is missing this "static method metafactory" or something.
Connector/j 8.0 requires java 1.8.x which I believe I'm running with my compileSdkVersion and targetSdkVersion. I tried downloading sdkVersion 27 to build the app in a lower version but the app doesn't build.
I have no idea why my driver can't seem to find the things it needs.
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?
I tried to run the sample of this library :
https://github.com/mxn21/FlowingDrawer
it works fine with this outdated build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.mt.stackoverflow"
minSdkVersion 9
targetSdkVersion 22
versionCode 120
versionName "1.2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.+'
compile 'com.android.support:design:22.2.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.android.support:cardview-v7:22.+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.mxn.soul:flowingdrawer-core:1.2.2'
}
but it fails with this updated build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mt.stackoverflow"
minSdkVersion 9
targetSdkVersion 23
versionCode 120
versionName "1.2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.mxn.soul:flowingdrawer-core:1.2.2'
}
FATAL EXCEPTION: main
Process: com.mt.stackoverflow, PID: 31453
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.mt.stackoverflow/com.mt.stackoverflow.MainActivity}:
java.lang.IllegalArgumentException: Target must not be null.
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Target must not be
null.
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:607)
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:590)
at
com.mt.stackoverflow.MyMenuFragment.setupHeader(MyMenuFragment.java:44)
at
com.mt.stackoverflow.MyMenuFragment.onCreateView(MyMenuFragment.java:31)
at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at
android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:339)
at
android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:602)
at
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6268)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Any ideas how I can run the sample with the moste recent build.gradle dependencies ?
The project is trying to access the ImageView in the header of the NavigationView in fragment_menu.xml in a way that is not compatible with the newer version of the support library. You can find the details in this post.
The ImageView is used as the target in a Picasso call and since the ImageView can no longer be found it is null and that is the cause of the IllegalArgumentException: Target must not be null error.
To fix it open the class MyMenuFragment and replace onCreateView(...) with the following:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_menu, container, false);
View header = ((NavigationView) view.findViewById(R.id.vNavigation)).getHeaderView(0);
ivMenuUserProfilePhoto = (ImageView) header.findViewById(R.id.ivMenuUserProfilePhoto);
setupHeader();
return setupReveal(view) ;
}
Basically you can no longer find ivMenuUserProfilePhoto directly from view. You first need to get the header view from the NavigationView and then find the ImageView using the header.
I am Using docx4j to read Docx file from sd card. I have problem with org.apache.log4j.Logger library. I have even tried to add it externally. but it is still giving me same problem.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.shvet.pdfreaders"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:23.1.1'
// compile('org.docx4j:docx4j:2.8.0') {
// transitive = false
// }
compile 'org.apache.logging.log4j:log4j-core:2.5'
compile files('libs/docx4j-2.8.0.jar')
}
Logcat
02-16 16:15:48.025 24912-24912/com.shvet.pdfreaders E/AndroidRuntime:
FATAL EXCEPTION: main
Process: com.shvet.pdfreaders, PID: 24912
java.lang.NoClassDefFoundError: Failed resolution of:
Lorg/apache/log4j/Logger;
at org.docx4j.openpackaging.Base.(Base.java:42)
at
com.shvet.pdfreaders.fragments.PdfViewFragment$6.fileSelected(PdfViewFragment.java:205)
at
com.shvet.pdfreaders.extra.FileChooser$1.onItemClick(FileChooser.java:59)
at android.widget.AdapterView.performItemClick(AdapterView.java:305)
at android.widget.AbsListView.performItemClick(AbsListView.java:1146)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3057)
at android.widget.AbsListView$3.run(AbsListView.java:3864)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"org.apache.log4j.Logger" on path: DexPathList[[zip file
"/data/app/com.shvet.pdfreaders-1/base.apk"],nativeLibraryDirectories=[/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 org.docx4j.openpackaging.Base.(Base.java:42)
at
com.shvet.pdfreaders.fragments.PdfViewFragment$6.fileSelected(PdfViewFragment.java:205)
at
com.shvet.pdfreaders.extra.FileChooser$1.onItemClick(FileChooser.java:59)
at android.widget.AdapterView.performItemClick(AdapterView.java:305)
at android.widget.AbsListView.performItemClick(AbsListView.java:1146)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3057)
at android.widget.AbsListView$3.run(AbsListView.java:3864)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:139)
at android.app.ActivityThread.main(ActivityThread.java:5298)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
Suppressed: java.lang.ClassNotFoundException: org.apache.log4j.Logger
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)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the
boot class loader; no stack available
What I have done till now: I tried with jar file and external log4j and used gradle url with and without log4j library.