Because of my large application, i have to use MultiDex to split my app for pre Lollipop devices.
When debugging my app on my Nexus 4 (ICS 4.3), i get the following errors.
Why were my classes not found?
defaultConfig {
applicationId "de.itout.bring.handsoffme"
minSdkVersion 17
targetSdkVersion 23
versionCode 6
versionName "1.2"
multiDexEnabled true
}
buildTypes {
release {
//signingConfig signingConfigs.debug
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
//javaMaxHeapSize "512m"
//preDexLibraries = false
javaMaxHeapSize "4g"
incremental true
}
dependencies {
compile project(':emoji')
provided fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.twitter.sdk.android:twitter:1.12.0'
//compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.crashlytics.sdk.android:crashlytics:2.5.5'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.github.satyan:sugar:1.4'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.path:android-priority-jobqueue:1.1.2'
compile 'com.anjlab.android.iab.v3:library:1.0.30'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:facebook-android-sdk:4.9.0'
}
public class MyApplikation extends SugarApp {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
//MultiDex.install(getApplicationContext());
//MultiDex.install(getBaseContext());
MultiDex.install(this);
}
(Edit)
<application
android:name=".MyApplikation"
android:allowBackup="true"
android:icon="#mipmap/my_icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:icon" >
Proguard-rules.pro
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontoptimize
-verbose
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/de.itout.bring.handsoffme-2.apk"],nativeLibraryDirectories=[/data/app-lib/de.itout.bring.handsoffme-2, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4417)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.tools.fd.runtime.BootstrapApplication" on path: DexPathList[[zip file "/data/app/de.itout.bring.handsoffme-2.apk"],nativeLibraryDirectories=[/data/app-lib/de.itout.bring.handsoffme-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4417)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
To avoid having to MultiDex at all, I suggest you use individual Google Play Services module depending upon your exact requirements as outlined here.
Set minifyEnabled to true and make adjustments to your ProGuard entries.
Using Instant Run also has problems for now. It has been reported in this link.
#razzledazzle: Thanks a lot. These tips are very helpful.
After that, I´ve the next problems. In my apk-file missing classes respectively classdefinitions. SOME sugarmodels-classes was missing (NOT ALL). The little tool classyshark and the sugarlog help me!
So I compare the classes and found a solution!
For all Sugar-ORM-Users with multiDex problems. I put the "ignore"-Annotation for a debugvariable in all my sugarclasses and now they are in the dexfile.
I don´t know how or why, but it works...
#Ignore
public boolean multiDex;
Maybe there is better solution, but I don´t know... Possibly the RetentionPolicy of the Ignore-annotation do the trick.
Next thing for possible Sugar-Orm problems could be the proguardtool. It is important to keep the classnames of your models.
-keep class com.package.example.models.* {*;}
these rule keep the complete class for proguard. I hope it help.
Happy coding...
Related
Does anyone understand this error message Help Plz
11/28 03:56:03: Launching 'app' on Pixel 3a API 29.
$ adb shell am start -n "com.example.tastebuds/com.example.tastebuds.MainActivity"
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 15076 on device 'emulator-5554'.
Capturing and displaying logcat messages from application.
This behavior can be disabled in the "Logcat output" section of the "Debugger"
settings page.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tastebuds, PID: 15076
java.lang.RuntimeException: Unable to instantiate application
androidx.multidex.MultiDexApplication: java.lang.ClassNotFoundException:
Didn't find class "androidx.multidex.MultiDexApplication" on path: DexPathList[[zip file
"/data/app/com.example.tastebuds-
MuVNPt6cV8GXPEwZSlpcDg==/base.apk"],nativeLibraryDirectories=
[/data/app/com.example.tastebuds-MuVNPt6cV8GXPEwZSlpcDg==/lib/x86, /system/lib,
/system/product/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1226)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
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:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"androidx.multidex.MultiDexApplication" on path:
DexPathList[[zip file "/data/app/com.example.tastebuds-
MuVNPt6cV8GXPEwZSlpcDg==/base.apk"],nativeLibraryDirectories=
[/data/app/com.example.tastebuds-MuVNPt6cV8GXPEwZSlpcDg==/lib/x86, /system/lib,
/system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at
androidx.core.app.CoreComponentFactory.instantiateApplication
(CoreComponentFactory.java:49)
at android.app.Instrumentation.newApplication(Instrumentation.java:1148)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1218)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6431)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
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:930)
Process 15076 terminated.
this is my build.gradle file (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.tastebuds"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-firestore:21.3.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
From the documentation
try adding
<application
android:name="androidx.multidex.MultiDexApplication" >
...
</application>
in your manifest because you are using androidx. But if you finished adding it to your manifest, try to clean project or Invalidate caches and restart your project
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 am using Android studio 2.3.1 on windows 10. When I tried to run the app on device, when my device is connected to android studio, then I am able to run the app. But when I tried to install its debug or release apk on android phone then it is getting installed but while opening the app it gives following error:
04-27 10:06:31.675 30541-30541/package name E/AndroidRuntime: FATAL EXCEPTION: main
Process: package_Name, PID: 30541
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{package Name/package_Name.SplashActivity}: java.lang.ClassNotFoundException: Didn't find class "package_Name.SplashActivity" on path: DexPathList[[zip file "/data/app/package_Name-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2227)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
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:900)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Caused by: java.lang.ClassNotFoundException: Didn't find class "package_Name.SplashActivity" on path: DexPathList[[zip file "/data/app/package_Name-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 android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2217)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
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:900)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)
Suppressed: java.lang.ClassNotFoundException: package Name.SplashActivity
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)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Any help will be appreciated.
My gradle code
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "package_Name"
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'
}
}
}
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
}
You can solve this with just "Build (tab) / Build APK" instead of Run 'app'
#ASK could you please clean your project and rebuild it. This is the error mostly obtained when your apk is not properly created
Your package name should not contain space as from your code their is space in the package name
Please change it to like package.name
The problem might have occurred because you have you might have exceeded the 64k method limit.
You should consider enabling multidex in your app.
defaultConfig {
...
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Also add this to manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Uncheck Instant Run..
How to do this:
Open the Settings or Preferences dialog: On Windows or Linux, select File > Settings from the menu bar. On Mac OSX, select Android Studio > Preferences from the menu bar.
Navigate to Build, Execution, Deployment > Instant Run.
Uncheck the box next to Restart activity on code changes.
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.
This is what my build.gradle(Module:app) file looks like
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
defaultConfig {
applicationId "com.ryde.chris.ryde"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.firebase:firebase-client-android:2.0.3+'
}
When I tried building the app and deploying it to a GenyMotion emulator, I get this exception(with stack trace)
java.lang.NoClassDefFoundError: com.google.android.gms.R$string
at com.google.android.gms.measurement.zza.<init>(Unknown Source)
at com.google.android.gms.measurement.zza.zzaR(Unknown Source)
at com.google.android.gms.measurement.internal.zzn.zziJ(Unknown Source)
at com.google.android.gms.measurement.internal.zzz.zza(Unknown Source)
at com.google.android.gms.measurement.internal.zzw.<init>(Unknown Source)
at com.google.android.gms.measurement.internal.zzaa.zzDj(Unknown Source)
at com.google.android.gms.measurement.internal.zzw.zzaT(Unknown Source)
at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I tried building/deploying the app multiple times to different emulators to make sure that this wasn't a one time thing or a single emulator thing.
From looking at the stack trace, I saw that it had nothing to do with any of the code I wrote so I am assuming this is some build/gradle issue.
One thing I found regarding this issue on StackOverflow was this but that had to do with rstyleable not being defined, not Rstring. The solution to that issue was to include a dependency to Google Play Services library which I have done in my build.gradle.
Another thing I found was this. In this case com.google.android.gms.R$string was missing but that user's stack trace looks different than mine(that one has more lines with GooglePlayServices in it). The proposed solution in that thread was again to make sure you included the GooglePlayServices dependency. Unlike that stack trace, my stack trace gave no indication that any Google Play Services resource file was missing.
Does anyone know what the issue is or how I could fix this?