简体   繁体   English

建立APK档案时发生错误

[英]Error while building apk file

Whenever i try to build my apk file it fails with following error. 每当我尝试构建我的apk文件时,它都会失败,并显示以下错误。

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 错误:任务':app:transformClassesWithDexForDebug'的执行失败。 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/gms/auth/api/signin/internal/zzf; com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / auth / api / signin / internal / zzf;

Please help. 请帮忙。

Thanks. 谢谢。

Just try this code:

  useLibrary 'org.apache.http.legacy'
  multiDexEnabled true


public class MyApp extends Application {


@Override
public void onCreate() {
    super.onCreate();
    MultiDex.install(this);

}

manifestfile: 清单文件:

    <application
    android:name="com.activity.MyApp"
    android:allowBackup="true"
    ....
   <activity name...../>
   />//application

It complains about duplicate package, com/google/android/gms/auth, you can try a gradle clean / clean project as a simple step. 它抱怨重复的软件包com / google / android / gms / auth,您可以尝试简单地进行gradle clean / clean项目。 If this doesn't work it means that somewhere in the project dependencies you are including this package more than one time. 如果这不起作用,则意味着您在项目依赖项中的某个位置多次包含了此软件包。

Just go to build tab and choose clean project. 只需转到“构建”选项卡,然后选择“干净项目”即可。 After clean project completed make rebuild project. 清洁项目完成后,进行重建项目。 then run your project. 然后运行您的项目。

i hope this will solve your problem. 我希望这能解决您的问题。

please add this code in build.gradle(module:app) 请将此代码添加到build.gradle(module:app)

    afterEvaluate {
    tasks.matching {
        it.name.startsWith('dex')
    }.each { dx ->
        if (dx.additionalParameters == null) {
            dx.additionalParameters = ['--multi-dex']
        } else {
            dx.additionalParameters += '--multi-dex'
        }
    }
}

You can try any of this.. it might works 您可以尝试任何一种方法。

  1. Clean and rebuild the module or, 清洁并重建模块,或者
  2. Invalidate / restart android studio or, 无效/重启android studio或
  3. Check Gradle dependencies duplicate and clean the gradle at the right taskbar or, 检查Gradle依赖项是否重复,并在右侧的任务栏上清除Gradle,或者,
  4. add multiDexEnabled true in your gradle defaulConfig 在gradle defaulConfig中添加multiDexEnabled true

A duplicate in the build.gradle file was the issue. 问题是build.gradle文件中的重复项。 Firebaseui was causing the build error. Firebaseui导致了构建错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM