Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

android - 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'
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...