每次我运行我的项目(通过模拟器)时,它都会因以下错误而崩溃:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{parking.sampleProj.testApp/parking.sampleProj.testApp.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "parking.sampleProj.testApp.LoginActivity" on path: DexPathList[[zip file "/data/app/parking.sampleProj.testApp-A8HKlv12hsjFRpN8R_O-zw==/base.apk"],nativeLibraryDirectories=[/data/app/parking.sampleProj.testApp-A8HKlv12hsjFRpN8R_O-zw==/lib/x86, /system/lib, /vendor/lib]
我的 AndroidManifest.xml 看起来正确,我正在引用活动,所以我不明白为什么它说找不到类:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" >
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="sampleProj.testApp.MainActivity" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这些是我的 gradle 文件中的依赖项:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.1'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
我的 LoginActivity 类设置为 public。我不明白问题是什么。请问有什么帮助吗?
九州编程
一只甜甜圈
相关分类