android - 在android studio中编译应用程序时出错?

标签 android compiler-errors

在Android Studio项目中创建会产生错误,错误堆栈如下。创建自定义Nawigation Drawer Activity 后 pop 错误,那是什么?

java.lang.ClassNotFoundException: android.support.v4.view.AccessibilityDelegateCompatIcs$AccessibilityDelegateBridge
at org.jetbrains.android.uipreview.ProjectClassLoader.load(ProjectClassLoader.java:112)
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:52)
at org.jetbrains.android.uipreview.ProjectClassLoader.findClass(ProjectClassLoader.java:73)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at android.support.v4.view.AccessibilityDelegateCompat.<clinit>(AccessibilityDelegateCompat.java:296)
at android.support.v4.widget.DrawerLayout.<init>(DrawerLayout.java:162)
at android.support.v4.widget.DrawerLayout.<init>(DrawerLayout.java:256)
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:408)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.inflate(LayoutInflater.java:478)
at android.view.LayoutInflater.inflate(LayoutInflater.java:381)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:674)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:663)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:663)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:790)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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)

我的xml出现错误:
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<!-- As the main content view, the view below consumes the entire
     space available using match_parent in both dimensions. -->
<FrameLayout android:id="@+id/container" android:layout_width="match_parent"
    android:layout_height="match_parent" />

<!-- android:layout_gravity="start" tells DrawerLayout to treat
     this as a sliding drawer on the left side for left-to-right
     languages and on the right side for right-to-left languages.
     If you're not building against API 17 or higher, use
     android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed width in dp and extends the full height of
     the container. -->
<fragment android:id="@+id/navigation_drawer"
    android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent"
    android:layout_gravity="start"
    android:name="com.tvitbook.dd.tvitbook.NavigationDrawerFragment"
    tools:layout="@layout/fragment_navigation_drawer" />

image

最佳答案

我的猜测是您没有所需的兼容性库(android.support.v4)。如果是这种情况,请将其添加到docs之后的项目中:

  1. Make sure you have downloaded the Android Support Repository using the SDK Manager.
  2. Open the build.gradle file for your application.
  3. Add the support library to the dependencies section. For example, to add the v4 support library, add the following lines:

    dependencies { ... compile "com.android.support:support-v4:18.0.+" }

关于android - 在android studio中编译应用程序时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26694310/

相关文章:

android - Android OpenGL ES 环境中的插值

android - android :actionMenuTextColor and actionMenuTextColor之间的区别

android - 获取 GCM 错误 : INVALID_SENDER occasionally in an app that has two GCM BroadcastReceivers

android - 错误 :Execution failed for task org. gradle.process.internal.ExecException: 'finished with non-zero exit value 2

c++ - 如何在 C++ 的另一个模板函数中使用属于模板类的嵌套类型?

.net - 收集和传达编译器错误的方法有哪些

未找到 Android Theme.AppCompat - 但遵守 Google 说明

c - C-bash的第一个程序: ./: is a directory

c++ - IDL接口(interface),C++,CORBA,我正在处理 "conflicting return type specified for"和 "invalid abstract return type for member function ‘virtual..."

c++ - dev c++编译器错误