ฉันได้อัปเกรด Android Studio เป็น
Android Studio 3.2
Build #AI-181.5540.7.32.5014246, built on September 17, 2018
JRE: 1.8.0_152-release-1136-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
ฉันสร้างโครงการใหม่โดยใช้เทมเพลตกิจกรรมที่ว่างเปล่า
Sync Gradle
Clean
Build
Run
logcat แอปพลิเคชันของฉันแสดงข้อยกเว้นนี้เมื่อเริ่มต้น
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.support.v4.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.support.v7.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.support.v7.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.support.v7.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void com.manacle.secondmanacle.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:11)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle, android.os.PersistableBundle) (Activity.java:7009)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7000)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2731)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2856)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1589)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:106)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.os.Looper.loop() (Looper.java:164)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6494)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:438)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:807)
2018-09-27 13:51:41.116 22090-22090/? I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.manacle.secondmanacle-6Ra5peoMwc4HH30iTlEXCg==/base.apk"],nativeLibraryDirectories=[/data/app/com.manacle.secondmanacle-6Ra5peoMwc4HH30iTlEXCg==/lib/arm64, /system/lib64, /vendor/lib64]]
ฉันไม่ได้ทำการเปลี่ยนแปลงใด ๆ กับแอปเทมเพลตที่สร้างโดย Android Studio
เหตุใดแอปสร้างเทมเพลตจึงไม่เริ่มทำงานอย่างสมบูรณ์
ฉันพยายามย้ายไปใช้ androidX แต่ปัญหายังคงเหมือนเดิมทุกประการ
เหตุใด Android Studio จึงไม่สามารถสร้างแอปพลิเคชันเทมเพลตที่ "สะอาด" ได้
ไฟล์ gradle ของฉันมีลักษณะดังนี้: -
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
====
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.manacle.secondmanacle"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}