【发布时间】:2019-11-12 08:12:50
【问题描述】:
我有一个新的颤振应用程序(除以下内容外,没有添加或更改任何内容)。我需要使用这些包url_launcher、permission_handler 和firebase_auth。但是只要我在我的 main.dart 文件中导入这些包(在添加 pubsec.yaml 之后)
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:permission_handler/permission_handler.dart';
编译失败并显示如下错误。
D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
BUILD FAILED in 7s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See (this link will be in the comment) for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
如何在同一个项目中使用所有这三个包。 (我认为是因为 androidX 兼容性)
在 gradlew.properties 添加以下内容并在 build gradle 中设置 compilerSdkVersion 28 后
android.useAndroidX=true
android.enableJetifier=true
android {
compileSdkVersion 28
..
现在我收到以下错误。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.core:core' has different version for the compile (1.0.0-rc01) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution
【问题讨论】:
-
这是命名冲突。请参考Program type already present
-
我该怎么办? @user5607081
-
您需要将项目迁移到 AndroidX。因为软件包使用了 AndroidX,而你在 gradle 中使用了 Support。
-
检查here。
-
@AbhayKoradiya 我使用您的链接解决了问题。将此添加到答案中,以便我接受。还要添加这个link。
标签: android flutter firebase-authentication androidx