我正在尝试将MPAndroidChartLibrary添加到我的Android Studio项目中,但是当我尝试运行该应用时,它会一直失败并出现1个错误。我对gradle不是很了解,所以我真的不知道哪里出错了。
我的gradle文件是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "com.bacon.corey.audiotimeshift"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile files('C:/Users/Corey/.AndroidStudioBeta/Projects/AudioTimeShift/libraries/mpandroidchartlibrary-1-7-4.jar')
}
据我所见,这一切都应该没问题,但它不起作用。 这是Gradle控制台的日志:
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42100Library 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:compileDebugJava
Note: C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\src\main\java\com\bacon\corey\audiotimeshift\MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Program Files (x86)\Android\android-sdk\build-tools\21.0.2\dx.bat --dex --output C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\dex\debug C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\classes\debug C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\dependency-cache\debug C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\classes-08104da82547c1da8de562eb9350a514962ceaa7.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\classes-c916341f097aba848a3f8d1cb524d87b40a5e434.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\internal_impl-21.0.0-dd323fb38f6f05cc36bfccaf6824e44b4d16534e.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\library-2.4.0-1028d824e09b12c83da4be3e497c82fdc33874f5.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\mpandroidchartlibrary-1-7-4-1e0626ccaecee3e156334e8c3c9fcf07d352edb9.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\support-annotations-21.0.0-9528452d0a4563476596d64e06f21a3014c413f7.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/ValueAnimator$AnimatorUpdateListener;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
Information:BUILD FAILED
Information:Total time: 18.241 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
如果有人能给我一些关于我哪里出错的指示,我会非常感激。
谢谢,Corey B:)
答案 0 :(得分:7)
MPAndroidChart已将com.nineoldandroids:library:2.4.+
作为依赖项。从依赖项中删除compile 'com.nineoldandroids:library:2.4.0'
。