java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20900832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
提问by Balakrishnan
i am using terminal [not eclipse]. i got following exception error, while i use emulator.debug
successfully and installd successfully. But emulator show Unfortunatly app has stop
. Then i run $ adb logcat
it will display following.
我正在使用终端 [不是 eclipse]。我收到以下异常错误,同时我emulator.debug
成功使用并成功安装。但是模拟器显示Unfortunatly app has stop
。然后我运行$ adb logcat
它会显示以下内容。
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
at com.example.trintwo.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access0(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
I got this error, Even I installed android support library and i checked android-support-v7-appcompat.jar
in android/support/v7/appcompat/lib
path what will i do to clear this error.
我收到了这个错误,即使我安装了 android 支持库,我检查android-support-v7-appcompat.jar
了android/support/v7/appcompat/lib
路径我将如何清除这个错误。
采纳答案by nitesh goel
If you are using eclipse than just import the v7 compat library project into your work space and add it as a library to your project. Else if you are doing it from terminal than what you can do is put android-support-v7-appcompat
library project (which you can find in sdk\extras\android\support\v7\appcompat
) in the same directory where is your project and add this line to your project.properties
file.
如果您使用的是 eclipse,那么只需将 v7 兼容库项目导入您的工作空间并将其作为库添加到您的项目中。否则,如果您是从终端执行此操作,那么您可以做的是将android-support-v7-appcompat
库项目(您可以在sdk\extras\android\support\v7\appcompat
中找到)放在您的项目所在的同一目录中,并将这一行添加到您的project.properties
文件中。
android.library.reference.1=../android-support-v7-appcompat
Do not forget to add both jar files v4, v7 to your project as well.
不要忘记将 jar 文件 v4、v7 也添加到您的项目中。
回答by Mike Ortiz
Make sure to do the following (from Support Library Setup):
确保执行以下操作(来自支持库设置):
Right-click the library project folder and select Build Path > Configure Build Path.
In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
Uncheck Android Dependencies.
右键单击库项目文件夹并选择构建路径 > 配置构建路径。
在 Order and Export 选项卡中,检查您刚刚添加到构建路径的 .jar 文件,以便它们可用于依赖于该库项目的项目。例如,appcompat 项目要求您导出 android-support-v4.jar 和 android-support-v7-appcompat.jar 文件。
取消选中 Android 依赖项。
回答by pgarriga
AppCompat is a lib with resource. You cannot add the jar, cause this library uses resources. So you need to add a library project.
AppCompat 是一个带有资源的库。您无法添加 jar,因为此库使用资源。所以你需要添加一个库项目。
Follow Adding Support Librariessteps.
遵循添加支持库步骤。
回答by user3081695
Right-click the your project folder and select java Build Path >Libraries
whether .jar file of your library project is present or not
if not buld the correct path that contains .jar file
右键单击您的项目文件夹并选择 java Build Path >Libraries
库项目的 .jar 文件是否存在
如果没有构建包含 .jar 文件的正确路径
回答by Kalpesh
If you are using Android Studiothen its quick easier, Please add compile 'com.android.support:cardview-v7:21.+'in dependencies in build.gradle.
如果您使用的是Android Studio,那么它会更简单,请在 build.gradle 的依赖项中添加compile 'com.android.support:cardview-v7:21.+'。
dependencies {
compile 'com.android.support:cardview-v7:21.+'
}