Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Didn't find class on path: DexPathList?

My app is working fine when I test in real device using USB in android studio.But When I send the apk to another device and install there,it is not working.App get crashed.I did not find any right way to solve the problem.Errors are given below:

FATAL EXCEPTION: main Process: com.w3xplorers.cmch,PID: 17715                                                                           java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.w3xplorers.cmch/com.w3xplorers.cmch.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.w3xplorers.cmch.MainActivity" on path: DexPathList[[zip file "/data/app/com.w3xplorers.cmch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.w3xplorers.cmch-1/lib/arm, /system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)     at android.app.ActivityThread.access$900(ActivityThread.java:150)     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)     at android.os.Handler.dispatchMessage(Handler.java:102)     at android.os.Looper.loop(Looper.java:168)     at android.app.ActivityThread.main(ActivityThread.java:5845)     at java.lang.reflect.Method.invoke(Native Method)     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:797)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.w3xplorers.cmch.MainActivity" on path: DexPathList[[zip file "/data/app/com.w3xplorers.cmch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.w3xplorers.cmch-1/lib/arm, /system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]     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:1085)     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544)      at android.app.ActivityThread.access$900(ActivityThread.java:150)      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)      at android.os.Handler.dispatchMessage(Handler.java:102)      at android.os.Looper.loop(Looper.java:168)      at android.app.ActivityThread.main(ActivityThread.java:5845)      at java.lang.reflect.Method.invoke(Native Method)      atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)                                                                         Suppressed: java.lang.ClassNotFoundException: com.w3xplorers.cmch.MainActivity     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)                                                                                ... 12 more     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available 

My Manifests is below:

`<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.w3xplorers.cmch">  <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.SEND_SMS" />   <application     android:name="com.w3xplorers.cmch.EnableMultiDex"     android:allowBackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:roundIcon="@mipmap/ic_launcher_round"     android:supportsRtl="true"     android:theme="@style/AppTheme" >     <activity         android:name="com.w3xplorers.cmch.MainActivity"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" >         <intent-filter>             <action android:name="android.intent.action.MAIN" />             <category android:name="android.intent.category.LAUNCHER" />         </intent-filter>     </activity>     <activity         android:name="com.w3xplorers.cmch.HomeActivity"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity         android:name="com.w3xplorers.cmch.QuickSms"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity         android:name="com.w3xplorers.cmch.GroupSms"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity         android:name="com.w3xplorers.cmch.SelfSms"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity         android:name="com.w3xplorers.cmch.Contact"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity         android:name="com.w3xplorers.cmch.Favourite"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity         android:name="com.w3xplorers.cmch.Info"         android:screenOrientation="portrait"         android:theme="@style/AppTheme.NoActionBar" />     <activity android:name="com.w3xplorers.cmch.Dialog" /> </application>  </manifest>` 

Gradle below:

apply plugin: 'com.android.application'  android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig {     applicationId "com.w3xplorers.cmch"     minSdkVersion 13     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'     } } }   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.0' compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5' compile 'com.android.support:design:25.3.0' compile 'com.andreabaccega:android-form-edittext:1.0.3' compile 'com.android.volley:volley:1.0.0' compile 'com.squareup.okhttp3:okhttp:3.3.1' compile 'com.android.support:multidex:1.0.1' testCompile 'junit:junit:4.12' } 
like image 808
Avijit Avatar asked Apr 16 '17 09:04

Avijit


2 Answers

I had to enable Java 8 Support after updating to Android Studio 3.5

Add the following lines in your build.gradle file:

android {     defaultConfig {             ...     }     compileOptions {         sourceCompatibility JavaVersion.VERSION_1_8         targetCompatibility JavaVersion.VERSION_1_8     } } 

You can check the documentation here: https://developer.android.com/studio/write/java8-support

like image 183
Johan Ferreira Avatar answered Sep 28 '22 08:09

Johan Ferreira


Go to your project level build.gradle file and decrease the version of gradle dependency to anything lower than 2.3.0, say use 2.2.3

dependencies {     classpath 'com.android.tools.build:gradle:2.2.3'     .... } 

Then clean -->build -->install debug apk to other device-->it may be OK then!

like image 44
ridoy Avatar answered Sep 28 '22 09:09

ridoy