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.
Related
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
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?
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'
i'm newbie.
I use:
Android studio 2.2.3
Gradle: 2.14.1
Realm-plugin: "classpath "io.realm:realm-gradle-plugin:2.2.1""
But it throws an exception while I'm calling Realm.init(context); in the onCreate of my Activity.
Log:
12-14 16:40:51.096 3541-3541/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: *.demo, PID: 3541
java.lang.ExceptionInInitializerError: RealmTransformer doesn't seem to be applied. Please update the project configuration to use the Realm Gradle plugin. See https://realm.io/news/android-installation-change/
at io.realm.RealmConfiguration.<clinit>(RealmConfiguration.java:77)
at io.realm.RealmConfiguration$Builder.initializeBuilder(RealmConfiguration.java:414)
at io.realm.RealmConfiguration$Builder.<init>(RealmConfiguration.java:402)
at io.realm.Realm.init(Realm.java:188)
at *.demo.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
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:5417)
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)
My Class:
import io.realm.Realm;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Realm.init(this); //crashing line
}
}
Build.gradle module level:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "*.demo"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
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:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.pwittchen:reactivenetwork:0.7.0'
testCompile 'junit:junit:4.12'
}
thanks in advance for help.
Jack doesn't work with the Transform API in Gradle.
As a result, the Realm-Transformer, which relies on the Transform API, cannot be used with Jack.
Use Retrolambda instead of Jack for Java 8 feature support.
You need to add this to the your d build.gradle file. :
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:2.2.1"
}
Then do:
Once these two changes are made, simply refresh your gradle dependencies. If you are upgrading from a version prior to v0.88 you may also need to clean your gradle project (./gradlew clean) to remove any lingering previous installations.
Instructions can be found here, on the Realm website.
I am following a tutorial (link) to upload images to Firebase database but am getting the below error. I rechecked the gradle dependencies and also enabled multidex support but error still remains
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzab;
at com.google.firebase.storage.FirebaseStorage.getInstance(Unknown Source)
at com.paperwrrk.android.storageref.MainActivity.<init>(MainActivity.java:36)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
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)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzab" on path: DexPathList[[dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-tubesock-0.0.11_74622aa9da17bf60443b34c100000d076f6631ba-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-support-annotations-25.0.0_416ca7aea2b0e15fba678c97c0d71c330758ffee-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-jackson-databind-2.2.2_169f7b55dddecf9b169deccb0ac50ee124eda962-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-jackson-core-2.2.2_3ae6e87b0280ab52f712dfb927e3401fe25aa21c-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-jackson-annotations-2.2.2_dd21f43a23482b41eb5ed094fcce68c90eeb0ffd-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_e8156948d2eb9e5ed0b41cc1f9f830e7838bb3b5-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_9056040795c4cf170b00cbf021bf976514542498-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_79b2045e82b81d2f064515f884990a3d2a9f29af-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_2879b3ac18601405060244958a8db64bdb3655f9-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_1ce40cec84eadc9153f026cb869c8b1760c8461a-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-firebase-client-jvm-2.3.1_764f8006
Gradle.app
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.paperwrrk.android.storageref"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
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:appcompat-v7:25.0.0'
compile 'com.google.firebase:firebase-database:10.0.0'
testCompile 'junit:junit:4.12'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-storage:9.2.1'
compile 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
Please tell what I'm doing wrong here!
now here is the problem, you are using different versions in dependencies of gradle
So change this
compile 'com.google.firebase:firebase-database:10.0.0'
testCompile 'junit:junit:4.12'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-storage:9.2.1'
compile 'com.android.support:multidex:1.0.0'
to this
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.android.support:multidex:1.0.0'
one more thing is that now com.firebae:firebase-client-android is deprecated so you need to replace it with com.google.firebase:firebase-database:10.0.1 and here is the documentation for that https://firebase.google.com/support/guides/firebase-android
I have faced similar problem while implementing native ad and killed almost 4 hours...
At last i have figured out that there are different com.google.android.gms:play-services-ads version in different module('17.1.1' and '12.0.0').
After changing all version to 17.1.1 it solved my problem.
If you are seeking solution for react-native project, make sure there is same version used among different modules and replace "+" with some latest available version.
Most of the time the problem is in the gradle. I had a similar problem until I changed firebase-(storage/auth/database) build gradle for module app to be the same for e.g.
( com.google.firebase:firebase-storage:16.1.0,com.google.firebase:firebase-auth:16.1.0, com.google.firebase:firebase-database:16.1.0)