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

吉吉·达哈尔(Kshitij Dhakal)

我有一个新的flutter应用程序(除了以下内容,没有添加或更改)。我需要使用这些包url_launcherpermission_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中添加以下内容并在build gradle中设置editorSdkVersion 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
阿比(Abhay Koradiya)

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

在这里检查

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

就像,此解决方案是从抖动问题中获取的

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么此部分应用程序无法编译?

为什么在控制台购买时无法在我的应用程序中使用此功能?

为什么我的应用程序无法创建bean?

为什么Composer无法安装我的应用程序

为什么我的应用程序无法填满整个屏幕?

为什么LaunchAgents无法运行我的Automator应用程序?

为什么我无法购买应用程序?

为什么我的应用程序在更改布局时崩溃?

为什么我的应用程序在执行按钮时崩溃?

为什么在调用OnBackPressed时我的应用程序崩溃了?

为什么在我更改页面时关闭应用程序?

为什么在调用 func 时我的应用程序冻结

使用Mix编译Phoenix应用程序的Ejabberd依赖项时出错:无法编译依赖项:ejabberd,“ mix compile”失败

为什么我的应用程序在调试时因应用程序停止而崩溃?

为什么Gradle在Grails 3.1应用程序中将我的传递依赖降级?

为什么我的 Slack 应用程序在由非管理员安装时无法正常工作?

为什么我的 .NET Web API 应用程序在使用 docker-compose 时无法连接到 docker 上的 MySQL?

为什么我的应用程序崩溃了?

毕加索有时无法下载照片并使我的应用程序崩溃

为什么C#7.2功能无法在UWP应用程序中编译?

为什么`npm run bundle -- -p` (webpack -p) 不为我的 rails 应用程序编译资产?

为什么我的AMD CPU在编译应用程序时遇到问题?

应用程序编译时没有协议功能-为什么?

为什么我无法在我的 AndroidViewModel 类中访问我的应用程序?

为什么当我尝试显示我的 ip usig Inet 时我的应用程序崩溃?

AppEngine / Go应用程序无法编译。我错过了什么?

Flutter Build For Web-“无法编译应用程序”

当我的应用程序在后台运行时,为什么我的BroadcastReceiver无法注册?

为什么无法在我的应用程序包中快速找到我的MOV文件?