在我的Android应用程序中包含库的问题

时间:2016-02-22 18:35:56

标签: java android android-studio gradle dependency-management

我完全清楚网站上存在类似的问题,但没有一个能解决我的问题。 这个词是,我正在尝试使用" openimaj"库进入我的android应用程序,在android studio中。在导入依赖项之前一切正常

'org.openimaj:core-audio:1.3.1'

但是当我导入此依赖项时,会出现以下错误!

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: 
Process 'command 'C:\ProgramFiles\Java\jdk1.8.0_66\bin\java.exe'' 
finished with non-zero exit value 2

请注意我使用了http://www.openimaj.org/UseLibrary.html中的教程。它基于Maven构建配置,但我将其转换为gradle格式。 这是我的应用程序级别gradle.build:

apply plugin: 'com.android.application'
apply plugin: 'maven'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.shadan.voicerecognitionmodule"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile ('com.android.support:appcompat-v7:23.1.1')
    compile ('com.android.support:design:23.1.1')
    compile ('org.openimaj:core-audio:1.3.1')  //I TRY TO IMPORT THIS
}

我的项目级build.gradle是:

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

 buildscript {
     repositories {
         jcenter()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:1.5.0'

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
 }

 allprojects {
     repositories {
         jcenter()
         maven { url "http://snapshots.openimaj.org" }
         maven { url "http://maven.openimaj.org" }
     }
 }

 task clean(type: Delete) {
     delete rootProject.buildDir
 }

编辑:

我的gradle控制台错误是:

 UNEXPECTED TOP-LEVEL EXCEPTION:
 com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
     at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)
     at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:161)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)



  FAILED

 FAILURE: Build failed with an exception.

 * What went wrong:
 Execution failed for task ':app:transformClassesWithDexForDebug'.
 > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 2

 * Try:
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

0 个答案:

没有答案