简体   繁体   English

DrawerLayout - 使用Android Studio和Gradle进行编译时的ClassNotFoundException

[英]DrawerLayout - ClassNotFoundException while compiling with Android Studio and Gradle

I was trying to create a sample app using the new DrawerLayout with the Android Studio and Gradle. 我试图使用Android Studio和Gradle的新DrawerLayout创建一个示例应用程序。 I am referring the official google document mentioned here . 我指的是这里提到的官方谷歌文件。 But whenever I launch the app, it exits with an exception (ClassNotFoundException - DrawerLayout). 但每当我启动应用程序时,它都会以异常(ClassNotFoundException - DrawerLayout)退出。

I have installed the latest support library from SDK manager (support-v4-13.0.0.jar) and it's automatically added to dependencies by the IDE. 我已经从SDK管理器(support-v4-13.0.0.jar)安装了最新的支持库,它会自动添加到IDE的依赖项中。 I tried copying this jar to the libs folder of project and changed the reference in the Libraries in "Project Structure". 我尝试将此jar复制到项目的libs文件夹,并在“项目结构”中更改了库中的引用。 But still getting the error. 但仍然得到错误。

Here is the "dependencies" section from my build.gradle 这是我的build.gradle中的“依赖项”部分

dependencies { compile 'com.android.support:support-v4:13.0.+' }

What I am missing here? 我在这里缺少什么?

Thanks. 谢谢。

This was a little weird, but I could figure it out. 这有点奇怪,但我可以搞清楚。

I Just replaced the inclusion of DrawerLayout in the layout XML from 我刚刚在布局XML中替换了DrawerLayout的包含

<DrawerLayout> .... </DrawerLayout>

to

<android.support.v4.widget.DrawerLayout> ... </android.support.v4.widget.DrawerLayout>

And this fixed the issue. 这解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android Studio / Gradle中编译捆绑库的问题 - Issue with compiling bundled libs in Android Studio/Gradle 运行项目时出现Android Studio“ClassNotFoundException” - Android Studio “ClassNotFoundException” occured while running the project Android Studio 说在项目或库中找不到“androidx.drawerlayout.widget.DrawerLayout”,即使我已经将它添加到 gradle - Android Studio says "androidx.drawerlayout.widget.DrawerLayout" was not found in the project or libraries, even though I already add it in the gradle 在将Android Studio更新到2.3.1并升级到之后,应用程序崩溃,并显示ClassNotFoundException - App crashes with ClassNotFoundException after updating Android Studio to 2.3.1 and gradle to 编译apk时出现Android Studio错误 - Android Studio Error while compiling an apk 编译Java项目时Android Studio Gradle 3.0错误 - Android Studio Gradle 3.0 error when compiling java project 在 Android Studio 中编译 Gradle 项目时检查 ARR 元数据时出错 - Error checking ARR metadata when compiling Gradle project in Android Studio Android Studio-Gradle构建编译未版本化的类文件 - Android Studio - Gradle build compiling unversioned class files 在 Android Studio 中访问 aar 文件的类时出现 classNotFoundException - classNotFoundException while accessing the aar file's classes in Android Studio 同步Gradle时遇到Android Studio问题 - Running into issues in Android Studio while syncing Gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM