美文网首页
gradle编译的问题

gradle编译的问题

作者: 技术笔记 | 来源:发表于2019-10-11 19:24 被阅读0次

    首先碰到了如下错误:

    To run dex in process, the Gradle daemon needs a larger heap.
    It currently has 1024 MB.
    For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
    To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
    For more information see https://docs.gradle.org/current/userguide/build_environment.html
    
    Dex: Error converting bytecode to dex:
    Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/exoplayer/AspectRatioFrameLayout;
        UNEXPECTED TOP-LEVEL EXCEPTION:
        com.android.dex.DexException: Multiple dex files define Lcom/google/android/exoplayer/AspectRatioFrameLayout;
            at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
            at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
            at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
            at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
            at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
            at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:506)
            at com.android.dx.command.dexer.Main.runMonoDex(Main.java:336)
            at com.android.dx.command.dexer.Main.runDx(Main.java:291)
            at com.android.dx.command.dexer.Main.main(Main.java:247)
            at com.android.dx.command.Main.main(Main.java:94)
        
    
    FAILURE: Build failed with an exception.
    

    根据错误提示增加了org.gradle.jvmargs=-Xmx1536M,再次编译,碰到了新的问题。

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':ijkplayer-example:transformDexWithDexForAll32Release'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/exoplayer/AspectRatioFrameLayout;
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    * Get more help at https://help.gradle.org
    
    

    根据错误,检查了下AspectRatioFrameLayout相关的包,结果这个方向错了,最后发现在build.gradle里面加上multidex就可以了。

    defaultConfig {
        // ...
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        flavorDimensions rootProject.ext.flavorDimensions
    
        multiDexEnabled true
    
    }
    

    相关文章

      网友评论

          本文标题:gradle编译的问题

          本文链接:https://www.haomeiwen.com/subject/fspxmctx.html