I'm trying to preview my MainActivity XML file and I'm getting this error:
java.lang.ClassNotFoundException: android.support.v4.widget.DrawerLayoutImpl
My Main Fragment and Navigation Drawer Fragment are working just fine.
Searched all over these forums and tried a bunch of things to no avail. I know it must be an issue with the library and my gradle build but I'm not sure what I'm doing wrong:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.0.0'
defaultConfig {
applicationId "com.example.example"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.0'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile 'com.android.support:support-v13:21.0.0'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile project(':facebook')
}
v4 was added automatically by android studio since I was using a navigation drawer. v13 I included myself (by going to project structure-->dependencies and adding it there) thinking it would help. I copied both .jar files to my libs folder thinking that would help as well. Cleaned project/synced gradle did all of that, not sure what else to do.
Just in case, here is what Android Studio created for me for activity_main.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. -->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- 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.example.example.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
ENTIRE STACK TRACE
java.lang.ClassNotFoundException: android.support.v4.widget.DrawerLayoutImpl
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:53)
at org.jetbrains.android.uipreview.ProjectClassLoader.findClass(ProjectClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.)
at java.lang.ClassLoader.loadClass(ClassLoader.)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.)
at java.lang.ClassLoader.defineClass(ClassLoader.)
at java.lang.ClassLoader.defineClass(ClassLoader.)
at com.android.tools.idea.rendering.RenderClassLoader.loadClassFromJar(RenderClassLoader.java:93)
at org.jetbrains.android.uipreview.ProjectClassLoader.loadClassFromModuleOrDependency(ProjectClassLoader.)
at org.jetbrains.android.uipreview.ProjectClassLoader.load(ProjectClassLoader.java:89)
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:56)
at org.jetbrains.android.uipreview.ProjectClassLoader.findClass(ProjectClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.)
at java.lang.ClassLoader.loadClass(ClassLoader.)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:96)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.)
at android.view.LayoutInflater.inflate(LayoutInflater.)
at android.view.LayoutInflater.inflate(LayoutInflater.)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.)
at com.android.tools.idea.rendering.RenderService.render(RenderService.)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.)
at com.intellij.util.Alarm$Request$1.run(Alarm.)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.)
at java.util.concurrent.FutureTask.run(FutureTask.)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.)
at java.lang.Thread.run(Thread.)