Flutter Could not determine the dependencies of task ‘:xxx:compileDebugAidl‘.

Could not determine the dependencies of task ':share:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':share:debugCompileClasspath'.
   > Could not resolve androidx.lifecycle:lifecycle-common:{strictly 2.0.0}.
     Required by:
         project :share
      > Cannot find a version of 'androidx.lifecycle:lifecycle-common' that satisfies the version constraints:
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.lifecycle:lifecycle-common:2.2.0'
           Constraint path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'androidx.lifecycle:lifecycle-common:{strictly 2.0.0}' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.lifecycle:lifecycle-common-java8:2.2.0' --> 'androidx.lifecycle:lifecycle-common:2.2.0'
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.lifecycle:lifecycle-runtime:2.2.0' --> 'androidx.lifecycle:lifecycle-common:2.2.0'
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.fragment:fragment:1.1.0' --> 'androidx.activity:activity:1.0.0' --> 'androidx.savedstate:savedstate:1.0.0' --> 'androidx.lifecycle:lifecycle-common:2.0.0'
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.fragment:fragment:1.1.0' --> 'androidx.loader:loader:1.0.0' --> 'androidx.lifecycle:lifecycle-livedata:2.0.0' --> 'androidx.lifecycle:lifecycle-livedata-core:2.0.0' --> 'androidx.lifecycle:lifecycle-common:2.0.0'

   > Could not resolve androidx.lifecycle:lifecycle-runtime:{strictly 2.0.0}.
     Required by:
         project :share
      > Cannot find a version of 'androidx.lifecycle:lifecycle-runtime' that satisfies the version constraints:
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.lifecycle:lifecycle-runtime:2.2.0'
           Constraint path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'androidx.lifecycle:lifecycle-runtime:{strictly 2.0.0}' because of the following reason: debugRuntimeClasspath uses version 2.0.0
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'androidx.core:core:1.3.1' --> 'androidx.lifecycle:lifecycle-runtime:2.0.0'
           Dependency path 'io.flutter.plugins.share:share:1.0-SNAPSHOT' --> 'io.flutter:flutter_embedding_debug:1.0.0-92ae191c17a53144bf4d62f3863c110be08e3fd3' --> 'androidx.fragment:fragment:1.1.0' --> 'androidx.activity:activity:1.0.0' --> 'androidx.lifecycle:lifecycle-runtime:2.1.0'

......

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

 

如上所示是运行Flutter工程中出现的部分编译错误,代码没问题,主要是编译打包时会报上面错误,这个主要是Flutter 依赖的第三方库中Android代码兼容性问题,我的工程中出现这个问题主要是Flutter SDK依赖环境引起,编译异常之前一直是正常的,后来切换到可支持Web环境,进行了 flutter channel 切换,然后Flutter SDK当前版本为beta版,切换之后简单工程是没问题的,如果依赖的第三方库比较多就可能报 Could not determine the dependencies of task 类的错误,可以通过命令行再把Flutter SDK切换到稳定环境 flutter channel stable,再运行即可。

可以通过 flutter channel查看当前有哪些版本,然后 flutter channel dev/beta/stable 即切换到对应分支

 

上面是我遇到出现 Could not determine the dependencies of task 问题和解决方案,还有可能是第三方依赖一直下载不下来,此时可以再添加配置阿里云maven依赖,主要在Android 下的build.gradle中配置两个地方buildscript 和 allprojects下的 repositories 中配置

 

  maven { url 'https://maven.aliyun.com/repository/google' }
  maven { url 'https://maven.aliyun.com/repository/jcenter' }
  maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }

也有可能是依赖的Flutter第三方库问题,可以试着修改  pubspec.yaml配置,如 shared_preferences: ^0.4.1 改为 shared_preferences: 0.4.1 这时候是0.4.1稳定版

 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,这个问题可能是由以下两个原因之一引起的: 1. 缺少字体文件 2. build-tools版本与项目的版本不一致 以下是解决这两个问题的方法: 1. 如果缺少字体文件,请按照以下步骤将字体文件添加到您的项目中: - 将字体文件复制到您的项目的android/app/src/main/assets/fonts/目录下。 - 在您的项目的android/app/build.gradle文件中添加以下代码: ```gradle project.ext.react = [ ... extraPackagerArgs: ["--assetExts", "ttf"] ] ``` - 在您的项目的android/app/src/main/java/com/yourproject/MainApplication.java文件中添加以下代码: ```java package com.yourproject; import android.graphics.Typeface; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import java.util.Arrays; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage() ); } @Override protected String getJSMainModuleName() { return "index"; } @Override protected String getJSBundleFile() { return "assets://index.android.bundle"; } @Override protected String getBundleAssetName() { return "index.android.bundle"; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/YourFont.ttf"); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } } ``` 2. 如果build-tools版本与项目的版本不一致,请按照以下步骤解决: - 运行flutter doctor -v命令,查看您的Flutter环境是否正常。 - 确保您的项目的build.gradle文件中的buildToolsVersion与您的Android SDK中安装的build-tools版本相同。 - 如果您的Android SDK中没有安装所需的build-tools版本,请打开Android Studio并安装它们。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值