2016-03-08 59 views
-1

我添加了一个新的图书馆,以我的Android Studio项目的外部库和失败,当我运行它,现在我收到此错误:摇篮建立时,我输入

UNEXPECTED TOP-LEVEL ERROR: 
Execution failed for task ':app:preDexDebug'. 
>com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command' /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java" finished with non-zero value 3 
BUILD FAILED 
Total time:17 mins 33.841 secs 
1 error 
0 warning 

我在app /库添加的库。我用右键单击并添加为一个库。 add as library

我读这是可能的,如果我把外部库,而不是项目/应用程序/库库,但我不知道怎么做了修正这个错误。 External libraries

这是我的gradle构建文件:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.nameht.pruebas" 
     minSdkVersion 15 
     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.2.0' 
    compile files('libs/symja-2016-03-07.jar') 
} 

回答

0

您两次导入库。使用这个compile fileTree(include: ['*.jar'], dir: 'libs')的人和使用这个compile files('libs/symja-2016-03-07.jar')的人。尝试删除其中的一个,事情应该正常工作。我建议删除这个compile files('libs/symja-2016-03-07.jar'),因为你不需要担心单独从lib中添加jar。

你gradle这个文件应该是这样的 -

apply plugin: 'com.android.application' 

repositories { 
    mavenCentral() 
    flatDir {      <-- This is important 
     dirs 'libs' 
    } 
} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.nameht.pruebas" 
     minSdkVersion 15 
     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.2.0' 
    compile files('libs/symja-2016-03-07.jar') 
}