当我在Android Studio中运行我的项目时,我得到了XML文档的下列错误,即activity_main.xml。我在最新安装的Manjaro Linux上使用最新的LTS内核运行Android Studio。
渲染问题
无法加载未知错误的AppCompat ActionBar。无法实例化一个或多个类 无法实例化以下类: android.support.v7.widget.AppCompatImageView(Open Class,Show Exception,Clear Cache) - android.support.v7.widget.Toolbar(Open Class,Show Exception,Clear Cache) - android.support.v7.widget.AppCompatTextView(Open Class,Show Exception,Clear Cache) - android.support.v7.widget.ActionBarContextView(Open Class,Show Exception,Clear Cache) - android.support.v7.app.WindowDecorActionBar(Open Class,Show Exception,Clear Cache) - android.support.v7.widget.ActionBarOverlayLayout(Open Class,Show Exception,Clear Cache)
堆栈追踪:
java.lang.ClassNotFoundException: android.support.v4.view.TintableBackgroundView
at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:181)
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:56)
at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:119)
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:214)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at com.android.tools.idea.rendering.RenderClassLoader.defineClassAndPackage(RenderClassLoader.java:177)
at com.android.tools.idea.rendering.RenderClassLoader.loadClassFromJar(RenderClassLoader.java:92)
at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:171)
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:56)
at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:119)
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:214)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:500)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:254)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:215)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadClass(LayoutlibCallbackImpl.java:218)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:336)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:155)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:225)
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.inflate(LayoutInflater.java:489)
at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:90)
at com.android.layoutlib.bridge.bars.NavigationBar.<init>(NavigationBar.java:52)
at com.android.layoutlib.bridge.bars.NavigationBar.<init>(NavigationBar.java:46)
at com.android.layoutlib.bridge.impl.Layout.createNavBar(Layout.java:325)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:151)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:288)
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:547)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:681)
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)
答案 0 :(得分:3)
尝试转到项目中的build.gradle(module:app)文件,在那儿更改以下内容:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
收件人:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1
'