【问题标题】:MPAndroidChart Android Studio Errors while building APKMPAndroidChart Android Studio 在构建 APK 时出错
【发布时间】:2016-12-08 09:53:55
【问题描述】:

我正在尝试一些关于 MPAndroidChart 的教程,它在我的模拟器中运行良好。但是当我尝试构建 APK 时,我遇到了两个错误...

“错误:将字节码转换为dex时出错: 原因:com.android.dex.DexException: 多个dex文件定义Lcom/github/mikephil/charting/BuildConfig;"

“错误:任务 ':app:transformClassesWithDexForDebug' 执行失败。 com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:org.gradle.process。 internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_91\bin\java.exe'' 以非零退出值 2" 结束

谁能帮帮我...

这是我的 build.gradle 脚本

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.1"

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

repositories {
        maven { url "https://jitpack.io" }
    }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:24.1.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'

    testCompile 'junit:junit:4.12'
}

【问题讨论】:

    标签: android android-studio mpandroidchart


    【解决方案1】:

    您的 build.gradle 的依赖项中可能不止一次包含相同的库/目录。

    我的建议是检查您的“libs”文件夹。确保只引用一次 MPAndroidChart。

    另外,尝试注释掉这一行:

    compile fileTree(include: ['*.jar'], dir: 'libs')
    

    【讨论】:

    • 清理项目并删除/按照您的建议将该行作为评论..及其工作..谢谢伙计。
    猜你喜欢
    • 2022-10-25
    • 1970-01-01
    • 2017-09-27
    • 2020-04-24
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 2020-03-10
    • 2017-05-10
    相关资源
    最近更新 更多