i'm getting this class not found error on api's below 21 even though google said it supports till api 14
i have tried it on android studio 3.0 beta 6
09-19 17:12:39.273 2794-2794/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: xxxx, PID: 2794
java.lang.RuntimeException: Unable to get provider android.arch.lifecycle.LifecycleRuntimeTrojanProvider: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleRuntimeTrojanProvider" on path: DexPathList[[zip file "/data/app/xxxx-1.apk"],nativeLibraryDirectories=[/data/app-lib/xxxx-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
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:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleRuntimeTrojanProvider" on path: DexPathList[[zip file "/data/app/xxxxx-1.apk"],nativeLibraryDirectories=[/data/app-lib/xxxxx-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
I've been using kotlin for development.
// architecture components
implementation "android.arch.lifecycle:runtime:$arch_version"
implementation "android.arch.lifecycle:extensions:$arch_version"
kapt "android.arch.lifecycle:compiler:$arch_version"
arch version is the latest one ext.arch_version = '1.0.0-alpha9-1'
building tool -> ext.buildToolsVersion = '26.0.1'
i have checked the other solutions says disable minify and proguard i have already tested them
debug {
// applicationIdSuffix '.debug' // Remove to fix Robolectric problem
versionNameSuffix '-DEBUG'
debuggable true
minifyEnabled false
useProguard false
multiDexEnabled true
Disabling Instant Run worked for me. (Settings -> Build, Execution, Deployment -> Instant Run -> uncheck "Enable Instant Run")
I was having the same problem, my app wouldn't run in api 19 devices (4.4) and it was a Dex problem.
I followed google documentation on multidex to solve it
1 - in app gradle, inside defaultConfig enable multidex
defaultConfig{
....
multiDexEnabled true
}
2 - to support multidex in other versions, add this dependency to your app gradle
compile 'com.android.support:multidex:1.0.1'
3 - if you have a class that extends Application, make it extend MultiDexApplication
if you don't, add this to your manifest file inside application tag
android:name="android.support.multidex.MultiDexApplication"
that's it. worked for me
Related
I am fairly new to android app development. Today i tried to implement a map inn my app, and cannot make it work. I even tried to make a new app with the default map activity, which crashes instantly.
This is the error I am getting:
--------- beginning of crash
2018-12-25 23:03:24.440 8401-8428/? E/AndroidRuntime: FATAL EXCEPTION: Thread-5
Process: com.example.krist.maptest, PID: 8401
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at ez.b(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):3)
at ey.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):3)
at fa.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):15)
at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):6)
at ed.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):21)
at ed.run(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):8)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/00000016/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000016/MapsDynamite.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader#14799081#14.7.99 (100400-223214910):4)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at ez.b(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):3)
at ey.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):3)
at fa.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):15)
at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):6)
at ed.a(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99 (100400-223214910):21)
at ed.run(:com.google.android.gms.dynamite_mapsdynamite#14799081#14.7.99
(100400-223214910):8)
I am running on a Pixel 3XL with the latest updates. Any ideas what the issue might be? Thanks.
I also had same issue, and it was solved pasting this line of code to 'application' element of AndroidManifest.xml.
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Hope it helped you.
Check if dependencies are set up correctly. Play services and gmaps versions should not vary.
Enable multidexing in your build.
add this line in dependencies:
implementation 'com.android.support:multidex:1.0.3' and make these changes in defaultConfig:
android {
defaultConfig {
...
multiDexEnabled true
}
...
}
And sync project.
I migrated my app to AndroidX and it's crashing on launch on API level 21. My application throws this exception:
10-08 09:42:50.930 11346-11346/com.example.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.test, PID: 11346
java.lang.RuntimeException: Unable to get provider androidx.core.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.example.test-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.test-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5121)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4713)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4596)
at android.app.ActivityThread.access$1600(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.example.test.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.test-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5106)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4713)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4596)
at android.app.ActivityThread.access$1600(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
And here is the provider definition in my AndroidManifest.xml file:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths" />
</provider>
On the latest API level it works fine. Any suggestions would be useful, thanks in advance.
It seems that this error came from incomplete configuration of MultiDex in your app. Here you may find the similar issue and here is an article answering it.
I suggest you to check the following (extending App class helped me):
Your Application class (App.class, for instance, if you use it) should extend from MultiDexApplication class:
public class BaseApplication extends MultiDexApplication {}
or if you don't use Application class check your manifest:
<?xml version="1.0" encoding="utf-8"?>
<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>
The documentation is outdated; use androidx.multidex for androidx:
implementation "androidx.multidex:multidex:2.0.1"
AndroidManifest.xml:
<application
android:name="androidx.multidex.MultiDexApplication">
</application>
Use the Jetifier when it still uses any com.android.support libraries:
android.enableJetifier=true
The problem is your React Native android project is not in AndroidX while react-native-image-picker is in an AndroidX environment; therefore, it is missing packages from the androidx package library.
Simple fix is adding the following lines to your ./android/gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
If you have any existing RN libraries that uses old android packages, your project won't build since they will be missing once you updated your project.
A clever tool found here deals with RN libraries that uses old android packages and brings them up to date.
npm i --save-dev jetifier
npx jetify
react-native run-android
All checked out and it's working on my end. Hope this helps anyone and please do share if it does.
Source https://github.com/react-native-community/react-native-image-picker/issues/1088#issuecomment-509755692
add below ndk lib support to your project if you have used the external library -
ndk
{
abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
}
inside the default config of your app level build.gradle file
defaultConfig
{
applicationId "org.comcast.net"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk
{
abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
}
}
it has solved my problem, hopefully it will solve at your end also.
After Android Studio 2.3 update (and gradle update) if I have instant run activated, and I install app from Android Studio through run or generate signed apk it works fine.
If I manually install the debug apk it immediately crashes on opening, with ClassNotFoundException.
Note: if I remove the reference to the file provider, the class not found becomes the main activity. This issue is with the debug apk that getting generated in Build-->Output-->apk folder. If you run app directly it always run fine.
Without instant run there is no crash. With previous versions of Android Studio there was not crash either.
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.vfirst.ifbagro-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.vfirst.ifbagro-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4993)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4596)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4536)
at android.app.ActivityThread.access$1300(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5214)
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:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.vfirst.ifbagro-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.vfirst.ifbagro-1, /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.ActivityThread.installProvider(ActivityThread.java:4978)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4596)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4536)
at android.app.ActivityThread.access$1300(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
I had the same error and I solved it with MultiDex
add build.gradle multiDexEnabled "true".
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
described on this link : https://developer.android.com/studio/build/multidex.html
Try this :
android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
this code into your manifest :
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
If you use custom application class, use this code :
public class YouApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
and then for manifest :
<application
...
android:name="YOUR_PACKAGE.YouApplication">
...
</application>
I hope help you my friend
As for me I tried the following : Try to check if your phone's Auto-start Manager allows your app to auto-start. By allowing your app to auto-start I think will help in fixing the Instant-run Problem. Hope's this helps.
I'm having an app and which works in android Lollipop and above, if I installed the app in android Kitkat device, the application crashes and show the error as below:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.SplashActivity}: java.lang.ClassNotFoundException: Didn't find class "com.SplashActivity" on path: DexPathList[[zip file "/data/app/com.partner-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.partner-1, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2131)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
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:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.SplashActivity" on path: DexPathList[[zip file "/data/app/com.partner-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.partner-1, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2122)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
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:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
at dalvik.system.NativeStart.main(Native Method)
I tried a lot and was not able to fix it, most of the answers are for eclipse projects.
The reason for api 21 on is:
Android 5.0 (API level 21) and higher uses a runtime called ART which natively supports loading multiple DEX files from APK files. ART performs pre-compilation at app install time which scans for classesN.dex files and compiles them into a single .oat file for execution by the Android device. Therefore, if your minSdkVersion is 21 or higher, you do not need the multidex support library.
From this guide: https://developer.android.com/studio/build/multidex.html
I solved the class not found error by naming my classes like this:
[Activity(Name = "somepackage.custombuttonrenderer")]
public class CustomButtonRenderer: ButtonRenderer
{ }
Here is my answer: Why is my custom ButtonRenderer not working?
Update you app level build.gradle file:
implementation 'com.android.support:multidex:1.0.0'
And update you application class with :
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
This worked to me:
Add this in your APLICATION class.
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(getBaseContext());
}
Explanation:
Android app (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can add the multidex support
The the same crash happened after I imported Couchbase Lite Android using either Gradle or jars.
Couldn't really figure out what's going on here as I didn't touch the code and only dropped the jars into the "libs" folder.
// inside Custom Application class
#Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics()); // <===== Crash here!
}
Trace:
07-07 19:37:43.785 15247-15247/? E/AndroidRuntime﹕
FATAL EXCEPTION: main
Process: sg.com.bigspoon.www, PID: 15247
java.lang.NoClassDefFoundError: io.fabric.sdk.android.services.common.ExecutorUtils
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:202)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:197)
at sg.com.bigspoon.www.data.BigSpoon.onCreate(BigSpoon.java:121)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4541)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
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:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
EDIT:
Although this is "fixed". But it is still very bizarre why this is happening. I would enlighten me and I would mark it as correct answer instead.
This is solved by enabling multiDex in build.gradle
android {
defaultConfig {
// Lower than 14 doesn't support multidex
minSdkVersion 14
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
SOURCE and more details -->
https://github.com/chrisjenx/Calligraphy/issues/136
https://developer.android.com/tools/building/multidex.html