我有一個問題,我把它和我的所有項目,所以我想出了一個新的項目與Android 3金絲雀7,但它總是給我同樣的錯誤。java.lang.RuntimeException:無法實例化新項目中的活動ComponentInfo - Android 3 Canary 7
我的MacOS塞拉利昂10.12.6
這是一個全新的項目,所以我不知道該怎麼辦它
出現此錯誤的解決:
07-24 10:25:57.776 29708-29708/com.estebanmoncaleano.myapplication E/AndroidRuntime: FATAL EXCEPTION: main Process: com.estebanmoncaleano.myapplication, PID: 29708 java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.estebanmoncaleano.myapplication/com.estebanmoncaleano.myapplication.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.estebanmoncaleano.myapplication.MainActivity" on path: DexPathList[[zip file "/data/app/com.estebanmoncaleano.myapplication-2/base.apk", zip file "/data/app/com.estebanmoncaleano.myapplication-2/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2972) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3243) at android.app.ActivityThread.access$1000(ActivityThread.java:218) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6917) 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:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.estebanmoncaleano.myapplication.MainActivity" on path: DexPathList[[zip file "/data/app/com.estebanmoncaleano.myapplication-2/base.apk", zip file "/data/app/com.estebanmoncaleano.myapplication-2/split_lib_dependencies_apk.apk"],nativeLibraryDirectories=[/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:1094) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2962) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3243) at android.app.ActivityThread.access$1000(ActivityThread.java:218) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1718) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6917) 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:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Suppressed: java.lang.ClassNotFoundException: com.estebanmoncaleano.myapplication.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) ... 13 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
我的搖籃:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.estebanmoncaleano.myapplication"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
我的清單:
個<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.estebanmoncaleano.myapplication">
<application
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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我的搖籃Proyect設置:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableAapt2=false
你覺得我能做些什麼來解決我的問題?
謝謝你的時間!
請向我們展示您的'activity_main.xml'和'MainActivity.java' –