我刚刚升级到Flutter 3.7.9,现在无法在Android上运行该应用程序。
- 在iOS和Web上,应用程序运行良好
- 如果我恢复到Flutter 3.0.5,Android应用程序运行良好(这也是在不同的分支上,因为3.7.9中有一堆依赖关系被破坏,必须修复)
这就是我得到的错误:
* What went wrong:
A problem occurred configuring project ':device_info_plus'.
> Could not resolve all artifacts for configuration ':device_info_plus:classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22.
Required by:
project :device_info_plus
> The consumer was configured to find a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22:
- gradle70JavadocElements
- gradle70RuntimeElements
- gradle70SourcesElements
- gradle71JavadocElements
- gradle71RuntimeElements
- gradle71SourcesElements
- javadocElements
- runtimeElementsWithFixedAttribute
- sourcesElements
All of them match the consumer attributes:
- Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle71JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.1' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle71RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides attribute 'org.gradle.plugin.api-version' with value '7.1' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle71SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.1' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
- Variant 'runtimeElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
The following variants were also considered but didn't match the requested attributes:
- Variant 'apiElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle70ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle71ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':device_info_plus' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':device_info_plus' of type org.gradle.api.Project.
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 4s
Exception: Gradle task assembleProdDebug failed with exit code 1
Exited
字符串
下面是一些可能有用的信息(在我的项目根目录flutter/android文件夹中使用./gradlew --version
检索)
------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------
Build time: 2020-06-02 20:46:21 UTC
Revision: a27f41e4ae5e8a41ab9b19f8dd6d86d7b384dad4
Kotlin: 1.3.72
Groovy: 2.5.11
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_301 (Oracle Corporation 25.301-b09)
OS: Mac OS X 10.16 x86_64
型
我也有device_info_plus: ^4.0.0
,这在Flutter的升级之间没有改变。我也尝试过将device_info_plus升级到其最新版本8. 1. 0,但错误仍然存在。
你有没有其他关于如何解决这个问题并在Flutter 3.7.9上运行Android应用程序的建议?如果有人可以验证他们能够使用Java 8或Kotlin1.6在Flutter 3.7.9上运行Android也会有所帮助。
最新消息:
我运行./gradlew wrapper --gradle-version=7.0.1 --distribution-type=bin
。我没有找到直接更新Kotlin的方法。现在我得到一个单独的错误:
An exception has occurred in the compiler (1.8.0_292). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
at ... (I'm skipping the hundreds of lines that say at some file in javac or Gradle)
型
从我发现的情况来看,这是因为我使用的是Java 1.8,但我安装了Java 11,仍然出现相同的错误。错误仍然显示“编译器(1.8.0_292)”,1.8.0_292看起来像Java版本,但它不是我拥有或使用的任何地方。即使我有Java 1.8,它也是1.8.0_301
有没有关于如何在Android上运行应用程序的建议?
1条答案
按热度按时间kq0g1dla1#
我找到了一个适合我的解决方案。Android Studio一直在使用错误的Java版本:
flutter/android
文件夹(用于我的flutter项目)Preferences | Build, Execution, Deployment | Build Tools | Gradle
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
行(替换设置distributionUrl的任何其他行)在此之前我尝试了很多东西,所以我不确定是否还有其他我做的事情使这成为可能(例如,我删除了我的.gradle文件夹在~和android文件夹中),但在完成这些步骤后,我可以在android上构建flutter应用程序。