NoClassDefFoundError - AppCompatDelegateImplV14

时间:2016-02-10 06:48:45

标签: android android-support-library android-appcompat

我试图通过将所有活动替换为从AppCompatActivity扩展来更新项目。但我的应用程序始终不会以相同的错误开始:

  

java.lang.NoClassDefFoundError:android.support.v7.app.AppCompatDelegateImplV14

  • Appcompat + Design(23.1.1)
  • 游戏服务(8.4.0)

我尝试了什么:

  1. 启用multidex。
  2. 跑到gradlew -q:projectName:dependenciev - 没有 嵌套/我只排除' support-v4'在顶层)。
  3. 清理/重建 项目
  4. 堆栈跟踪:

    java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
                                                                            at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:135)
                                                                            at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:117)
                                                                            at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:456)
                                                                            at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
                                                                            at [PACKAGE NAME].StartUpActivity.onCreate(StartUpActivity.java:18)
                                                                            at android.app.Activity.performCreate(Activity.java:6289)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:177)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:145)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5951)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at java.lang.reflect.Method.invoke(Method.java:372)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
    

    Build.gradle:

    apply plugin: 'com.android.application'
    apply plugin: 'android-apt'
    def AAVersion = '3.3.2'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"
        useLibrary 'org.apache.http.legacy'
    
    
        defaultConfig {
            applicationId "[PACKAGENAME]"
            minSdkVersion 9
            targetSdkVersion 23
            multiDexEnabled true
    
        }
    
        signingConfigs {
            release {
           // --------------- release keystore info
            }
        }
    
        buildTypes {
    
            debug {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
    
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                signingConfig signingConfigs.release
            }
        }
    
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/NOTICE'
        }
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['.apt_generated', 'src']
                resources.srcDirs = ['.apt_generated', 'src']
                aidl.srcDirs = ['.apt_generated', 'src']
                renderscript.srcDirs = ['.apt_generated', 'src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
            instrumentTest.setRoot('tests')
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
        apt {
            arguments {
                androidManifestFile variant.outputs[0]?.processResources?.manifestFile
                resourcePackageName '[PACKAGENAME]'
            }
        }
        dexOptions {
            preDexLibraries = false
        }
    }
    configurations {
        all*.exclude  group: 'com.android.support' , module: 'support-v4'
    }
    
    dependencies {
        // --------- Projects
        compile project(':facebook')
        compile project(':zxing-2.3.0:android')
        // compile fileTree(dir: 'libs', include: '*.jar')
    
        // ------------ Compile local jars
        compile files('libs/crittercism_v3_0_3_sdkonly.jar')
        compile files('libs/ormlite-android-4.45.jar')
        compile files('libs/ormlite-core-4.45.jar')
        compile files('libs/viewpagerindicator.jar')
    
        compile 'com.android.support:multidex:1.0.1'
    
        compile(
                [group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.2.3'],
                [group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.2.3'],
                [group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.2.3']
        )
    
    
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile ('com.android.support:design:23.1.1')
    
        compile 'com.google.android.gms:play-services-analytics:8.4.0'
        compile 'com.google.android.gms:play-services-gcm:8.4.0'
        compile 'com.google.android.gms:play-services-location:8.4.0'
    
        apt("org.androidannotations:androidannotations:$AAVersion")
        compile ("org.androidannotations:androidannotations-api:$AAVersion")
    
    }
    

    Gradlew依赖关系树:

    _releaseCompile - ## Internal use, do not manually configure ##
    +--- com.android.support:multidex:1.0.1
    +--- project :facebook
    +--- project :zxing-2.3.0:android
    +--- com.fasterxml.jackson.core:jackson-core:2.2.3
    +--- com.fasterxml.jackson.core:jackson-annotations:2.2.3
    +--- com.fasterxml.jackson.core:jackson-databind:2.2.3
    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.2.3
    |    \--- com.fasterxml.jackson.core:jackson-core:2.2.3
    +--- com.android.support:appcompat-v7:23.1.1
    +--- com.android.support:design:23.1.1
    |    +--- com.android.support:appcompat-v7:23.1.1
    |    \--- com.android.support:recyclerview-v7:23.1.1
    |         \--- com.android.support:support-annotations:23.1.1
    +--- com.google.android.gms:play-services-analytics:8.4.0
    |    \--- com.google.android.gms:play-services-basement:8.4.0
    +--- com.google.android.gms:play-services-gcm:8.4.0
    |    +--- com.google.android.gms:play-services-base:8.4.0
    |    |    \--- com.google.android.gms:play-services-basement:8.4.0
    |    \--- com.google.android.gms:play-services-measurement:8.4.0
    |         \--- com.google.android.gms:play-services-basement:8.4.0
    +--- com.google.android.gms:play-services-location:8.4.0
    |    +--- com.google.android.gms:play-services-base:8.4.0 (*)
    |    \--- com.google.android.gms:play-services-maps:8.4.0
    |         \--- com.google.android.gms:play-services-base:8.4.0 (*)
    \--- org.androidannotations:androidannotations-api:3.3.2
    

    解决方案/对我/: 我在一个子项目中有一个support-v4 jar,但我无法排除。所以我必须修改子项目以排除jar。

1 个答案:

答案 0 :(得分:3)

  

我只排除' support-v4'在顶层

你要

java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
  

如果Java虚拟机或ClassLoader实例尝试,则抛出该异常   加载类的定义(作为普通方法调用的一部分或   作为使用新表达式创建新实例的一部分)和否   可以找到班级的定义。

Build.gradle

中删除支持-v4
compile project(':android-support-v4')