J'ai des erreurs sur chaque widget de conception de support. Comme la vue de recyclage, la disposition du coordinateur, etc. À chaque fois, j'ajoute un widget de conception de support qu'il affiche
Java.lang.ClassNotFoundException: Android.view.View$OnUnhandledKeyEventListener
sur la section de mise en page. J'utilise api 28.0.0-rc01, version 4.4 Android 3.1.4. Voici mon fichier build.gradle (app)
apply plugin: 'com.Android.application'
Android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.Android.test5test"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.Android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.Android.support.constraint:constraint-layout:1.1.2'
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'
implementation 'com.Android.support:design:28.0.0-rc01'
implementation 'com.Android.support:cardview-v7:28.0.0-rc01'
implementation 'com.Android.support:recyclerview-v7:28.0.0-rc01'
}
Voici mon fichier de mise en page
<LinearLayout
xmlns:Android="http://schemas.Android.com/apk/res/Android"
xmlns:app="http://schemas.Android.com/apk/res-auto"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:orientation="vertical">
<Android.support.design.widget.AppBarLayout
Android:layout_width="match_parent"
Android:layout_height="wrap_content">
<Android.support.design.widget.TabLayout
Android:id="@+id/work_tab"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
app:tabIndicatorHeight="5dp"
app:tabTextColor="@color/white"
app:tabSelectedTextColor="@color/colorAccent"
app:tabGravity="fill"
app:tabMode="fixed" />
</Android.support.design.widget.AppBarLayout>
</LinearLayout>
Voici la trace de la pile de l'erreur
Java.lang.ClassNotFoundException: Android.view.View$OnUnhandledKeyEventListener
at org.jetbrains.Android.uipreview.ModuleClassLoader.load(ModuleClassLoader.Java:180)
at com.Android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.Java:61)
at org.jetbrains.Android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.Java:118)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:424)
at Java.lang.ClassLoader.loadClass(ClassLoader.Java:357)
at org.jetbrains.Android.uipreview.ModuleClassLoader.loadClass(ModuleClassLoader.Java:213)
at Android.support.design.widget.TabLayout$SlidingTabIndicator.setSelectedIndicatorHeight(TabLayout.Java:2402)
at Android.support.design.widget.TabLayout.<init>(TabLayout.Java:425)
at Android.support.design.widget.TabLayout.<init>(TabLayout.Java:399)
at Sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at Sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.Java:62)
at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:423)
at org.jetbrains.Android.uipreview.ViewLoader.createNewInstance(ViewLoader.Java:481)
at org.jetbrains.Android.uipreview.ViewLoader.loadClass(ViewLoader.Java:264)
at org.jetbrains.Android.uipreview.ViewLoader.loadView(ViewLoader.Java:222)
at com.Android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.Java:209)
at Android.view.BridgeInflater.loadCustomView(BridgeInflater.Java:337)
at Android.view.BridgeInflater.loadCustomView(BridgeInflater.Java:348)
at Android.view.BridgeInflater.createViewFromTag(BridgeInflater.Java:248)
at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:730)
at Android.view.LayoutInflater.rInflate_Original(LayoutInflater.Java:863)
at Android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.Java:72)
at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:837)
at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:824)
at Android.view.LayoutInflater.rInflate_Original(LayoutInflater.Java:866)
at Android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.Java:72)
at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:837)
at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:824)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:515)
at Android.view.LayoutInflater.inflate(LayoutInflater.Java:394)
at com.Android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.Java:325)
at com.Android.layoutlib.bridge.Bridge.createSession(Bridge.Java:384)
at com.Android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.Java:193)
at com.Android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.Java:544)
at com.Android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.Java:678)
at Java.util.concurrent.FutureTask.run(FutureTask.Java:266)
at Java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1142)
at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:617)
at Java.lang.Thread.run(Thread.Java:745)
J'ai vérifié le fichier de classe View, mais "OnUnhandledKeyEventListener" était présent. Je ne sais pas pourquoi ce problème se produit. S'il vous plaît, dites-moi comment résoudre ce problème.
Ouvrez le dossier styles.xml in app> src> main> res> values et modifiez cette ligne.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
à
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
Actuellement, il n'y a malheureusement pas de solution de contournement. Android.support.v4.view.ViewCompat n'implémente pas View.OnUnhandledKeyEventListener dans le package androidx . Le bogue a été soumis ici .