1

When I run on the emulator it works fine (API 21) but when I run it on my device Nexus 7 (API 19), it crashes with the following stack trace.

Stack trace

 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)

Just for reference I did try syncing with gradle, cleaning, rebuilding, the support sdk's are downloaded and the dependencies set. Just as stated here http://developer.android.com/tools/support-library/setup.html#add-library

Build.gradle for application

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"
    }

}

libs

gson-2.1.jar, poi-3.10-FINAL-20140208.jar

Any help or suggestions is appreciated

steff_bdh
  • 1,108
  • 2
  • 15
  • 32
  • When you run on the device, are you using a release build? This kind of thing can be caused by Proguard stripping out the classes. – Carlos P Mar 11 '15 at 15:02
  • http://stackoverflow.com/questions/30224899/why-am-i-still-getting-java-lang-noclassdeffounderror-android-support-v7-appcom – Victor Gomes Aug 14 '15 at 19:05

0 Answers0