Multiple dex files define /BuildConfig, can't find the cause:

后端 未结 5 1617
不知归路
不知归路 2020-11-30 08:19

I\'m using the new gradle build system and I\'m facing the following problem:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex file         


        
5条回答
  •  感情败类
    2020-11-30 09:03

    Add this to your build.gradle:

    android {
        dexOptions {
            preDexLibraries = false
        }
    }
    

    I suppose this way there is no conflicting BuildConfig.java.

    EDIT:

    Why the above works: Android studio will first dex the libraries before dex-ing the app module. If you have a library module with the same package name as your app module, this 'pre-dexing' will result in the creation of a BuildConfig.java in the same package as for the app.

    Note: 'pre-dexing' will slow down your build process a bit so I suggest that you change your library's package name instead.

提交回复
热议问题