当我在模拟器上运行时它工作正常(API 21)但是当我在我的设备Nexus 7(API 19)上运行它时,它会崩溃并跟随以下堆栈跟踪。
堆栈跟踪
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:263)
at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:225)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at uwi.dcit.AgriExpenseTT.MainMenu.onCreate(MainMenu.java:40)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(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:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
仅供参考,我尝试与gradle同步,清理,重建,下载支持sdk并设置依赖项。正如此处所述http://developer.android.com/tools/support-library/setup.html#add-library
应用程序的Build.gradle
apply plugin: 'android'
repositories {
mavenCentral();
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//compile'com.google.api-client:google-api-client-android:1.19.0'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:multidex:1.0.0'
compile project(path: ':AgriExpenseBackend', configuration: 'android-endpoints')
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
dexOptions {
preDexLibraries = false
incremental true
javaMaxHeapSize "4g"
}
}
库
gson-2.1.jar,poi-3.10-FINAL-20140208.jar
感谢任何帮助或建议