gradle编译意外的顶级异常

时间:2015-09-13 05:48:24

标签: android quickblox dex

我的工作build.graddle:

    apply plugin: 'com.android.application'


android {
    compileSdkVersion 23
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.squiri.squiri"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        //multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.vk:androidsdk:+'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'

}

如果我在下一行添加到此文件:

repositories {
    mavenCentral()
    maven { url 'http://maven.stickerpipe.com/artifactory/stickerfactory' }
}
...
dependenies{
...
    compile('vc908.stickers:stickerfactory:+') {
        transitive = true;
    }
}

我收到下一个错误:

    Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72300Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2221Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE
:app:prepareComAnjlabAndroidIabV3Library1026Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk400Library UP-TO-DATE
:app:prepareComGithubCastorflexSmoothprogressbarLibrary110Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable780Library UP-TO-DATE
:app:prepareComVkAndroidsdk1510Library UP-TO-DATE
:app:prepareVc908StickersStickerfactory053Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 33.864 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

为什么???符号:在我的电脑上的其他项目(quickblox示例聊天)中工作一切正常!

我的工作不在build.gradle:

    apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    maven { url 'http://maven.stickerpipe.com/artifactory/stickerfactory' }
}


android {
    compileSdkVersion 23
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.squiri.squiri"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        //multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.vk:androidsdk:+'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'


    compile('vc908.stickers:stickerfactory:+') {
        transitive = true;
    }
}

在quickblox示例聊天中使用build.gradle:

    apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    maven { url 'http://maven.stickerpipe.com/artifactory/stickerfactory' }
}

android {
    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

dependencies {
    compile files(rootProject.core_jar_path, rootProject.chat_jar_path, rootProject.messages_jar_path)
    compile 'com.google.android.gms:play-services-gcm:7.5.0'
    compile 'com.android.support:support-v4:19.0.+'
    compile 'com.android.support:appcompat-v7:19.0.0'
    compile project(':pull-to-refresh')
    compile('vc908.stickers:stickerfactory:0.2.2@aar') {
        transitive = true;
    }
}

我尝试了什么:

  • 清除,重建,重新创建项目

  • 将java的编译版本更改为1.7

  • 为multidex配置启用具有大内存大小分配的multiDexEnabled

  • 删除appcompat并支持依赖项

  • 将stickerfactory的版本更改为最新版本(“:+”)

没有任何作用。

类比问题还有quickblox jar库!(所有jar库都来自quickblox聊天示例(jars目录))

1 个答案:

答案 0 :(得分:2)

不要包含所有游戏服务。它包括许多不必要的类

compile 'com.google.android.gms:play-services:7.5.0'

而只添加neccecarry模块。 例如

compile 'com.google.android.gms:play-services-analytics:7.5.0'