无法实例化活动组件信息类未找到异常Android

时间:2017-06-14 11:18:27

标签: java android classnotfoundexception

我的应用程序直接部署到任何设备,没有任何异常。但是当安装.apk时,它会引发以下异常。其次,它与Nougat 7.0及更高版本一起运行良好,但对于较低操作系统版本(如5.0和6.0)的崩溃具有相同的例外。等异常的原因是什么?

的Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="amitechnologies.products.apps.equalizeraudioplayer.v3" >

    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.BATTERY_STATS" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity
            android:name="amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="amitechnologies.products.apps.equalizeraudioplayer.v3.view.MainActivity"
            android:screenOrientation="sensorPortrait"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:label="@string/app_name" >
        </activity>

    </application>

</manifest>

的build.gradle:

 apply plugin: 'com.android.application'
android {
    signingConfigs {
        config {
            keyAlias 'm-zaes'
            keyPassword 'm-zaes'
            storeFile file('D:/AMI_Repo/AMI_Designer/Targets/Android/AMI 3d Player v3/keystore.jks')
            storePassword 'm-zaes'
        }
    }
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "amitechnologies.products.apps.equalizeraudioplayer.v3"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.1"
        signingConfig signingConfigs.config

        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFile 'D:/AMI_Repo/AMI_Designer/Targets/Android/AMI 3d Player v3/app/proguard-android.txt'
            signingConfig signingConfigs.config
        }
    }
    sourceSets {
        main {
            jniLibs.srcDir 'jniLibs'
        }
    }
    repositories {
        maven { url "https://jitpack.io" }
    }
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.google.android.gms:play-services-ads:10.2.4'
        compile 'com.google.apis:google-api-services-youtube:v3-rev180-1.22.0'
        compile 'com.android.support:multidex:1.0.1'
        //glide
        compile 'com.github.bumptech.glide:glide:3.7.0'

        // CardView
        compile 'com.android.support:cardview-v7:25.3.1'
    }
    productFlavors {
    }
}

dependencies {
}

堆栈跟踪

Process: amitechnologies.products.apps.equalizeraudioplayer.v3, PID: 15548
                                                                                                       java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{amitechnologies.products.apps.equalizeraudioplayer.v3/amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles}: java.lang.ClassNotFoundException: Didn't find class "amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles" on path: DexPathList[[zip file "/data/app/amitechnologies.products.apps.equalizeraudioplayer.v3-1/base.apk"],nativeLibraryDirectories=[/data/app/amitechnologies.products.apps.equalizeraudioplayer.v3-1/lib/arm, /vendor/lib, /system/lib]]
                                                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2395)
                                                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2564)
                                                                                                           at android.app.ActivityThread.access$800(ActivityThread.java:170)
                                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1441)
                                                                                                           at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                                                           at android.os.Looper.loop(Looper.java:194)
                                                                                                           at android.app.ActivityThread.main(ActivityThread.java:5576)
                                                                                                           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:955)
                                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
                                                                                                        Caused by: java.lang.ClassNotFoundException: Didn't find class "amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles" on path: DexPathList[[zip file "/data/app/amitechnologies.products.apps.equalizeraudioplayer.v3-1/base.apk"],nativeLibraryDirectories=[/data/app/amitechnologies.products.apps.equalizeraudioplayer.v3-1/lib/arm, /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:1070)
                                                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)
                                                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2564) 
                                                                                                           at android.app.ActivityThread.access$800(ActivityThread.java:170) 
                                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1441) 
                                                                                                           at android.os.Handler.dispatchMessage(Handler.java:111) 
                                                                                                           at android.os.Looper.loop(Looper.java:194) 
                                                                                                           at android.app.ActivityThread.main(ActivityThread.java:5576) 
                                                                                                           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:955) 
                                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750) 
                                                                                                        Suppressed: java.lang.ClassNotFoundException: amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles
                                                                                                           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

文件夹结构: enter image description here

5 个答案:

答案 0 :(得分:2)

  

正如聊天中的讨论我发现,你手动生成APK的方式   没有生成正确的APK,所以我建议这些方式   生成APK for Manual Install:

用于调试版本

  • 删除App文件夹中的构建文件夹。
  • 转到Build>Build APk。它将生成.apk文件 app>build>output>apk目录。
  • 将您的设备复制并手动安装。

适用于发布版

  • 删除App文件夹中的构建文件夹。
  • 转到Build>Generate Signed APk并提供推荐的详细信息,确保您Build type : release并检查了签名版v1(jar signature)v2(full apk signature)。它将生成.apk文件 app>build>output>apk目录。
  • 将您的设备复制并手动安装。

答案 1 :(得分:1)

起初&#34;清洁&#34;和&#34;将项目与Gradle文件同步&#34;。然后运行你的代码

答案 2 :(得分:1)

替换此

<activity
        android:name="amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles"         
</activity>

用这个

 <activity
        android:name=".amitechnologies.products.apps.equalizeraudioplayer.v3.view.LoaderOfAllMediaFiles"         
 </activity>

原因是你错过了android:name

中的一个点(。)

答案 3 :(得分:0)

如果您的minSDK版本低于21,则需要对multidex执行以下操作

<强>的build.gradle

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 25
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

<强>的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your_app_package">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

答案 4 :(得分:0)

删除app文件夹中的Build文件夹并重建项目