AndroidStudio编译失败问题汇总


场景一:

 Androidstudio使用assembleRelease打正式包报错。

BuildConfig is defined multiple times
或者

Multiple dex files define Lcom/xxx/xxx/BuildConfig 

问题原因:module包名与app包名写的一致。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

    package="com.sport007.android">

问题解决::

  1. 重写module中的包名
  2. 删除所有build文件,重新编译

  执行了上述步骤,很有可能还是会报错,module中的R文件一直默认是App的。然后执行第三步

  3. 删除res文件,重新创建res下所有文件。

现在编译打包即正常。

 场景二:编译失败

问题一

 org.gradle.internal.service.ServiceCreationException: Could not create service of type OutputFilesRepository using ExecutionGradleServices.createOutputFilesRepository().

 问题二:KAPT编译失败

Kotlin could not find the required JDK tools in the Java installation '/Libr

解决:修改gradle jdk