gpt4 book ai didi

android - 为什么我的 flutter 应用程序在下载依赖项时无法编译?

转载 作者:行者123 更新时间:2023-11-29 22:42:50 25 4
gpt4 key购买 nike

我有一个新的 flutter 应用程序(除以下内容外没有添加或更改)。我需要使用这些包 url_launcher , permission_handlerfirebase_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 并在构建 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

最佳答案

需要将您的项目迁移到 AndroidX。因为 permission_handler 包已经使用了 AndroidX 并且您已经在 gradle 中使用了支持库。

检查 here .

正如@Kshitij Dhakal 所建议的,当同一库的版本在不同包中不同时,您还需要应用依赖项解析。

喜欢,这个解决方案取自flutter issues .

subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx')) {
details.useVersion "1.0.1"
}
}
}
}

关于android - 为什么我的 flutter 应用程序在下载依赖项时无法编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58814496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com