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稳定版