当项目已经评估时不能 运行 Project.afterEvaluate(关闭)
Cannot run Project.afterEvaluate(Closure) when the project is already evaluated
目前我遇到这个错误:
Microsoft Windows [Version 10.0.19043.1526]
(c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Flutter\StudioProjects\nomadnet>flutter run
Using hardware rendering with device sdk gphone x86 arm. If you notice graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Flutter\flutter_windows_2.10.1-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 421
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
* 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 37s
Running Gradle task 'assembleDebug'... 38,8s
Exception: Gradle task assembleDebug failed with exit code 1
我已经试过这个东西了:
- 我也尝试了更多的东西,但我不再了解它们了
我的代码:
app/build.gradle:
buildscript {
repositories {
// ...
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.apps.social_circle"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
android {
defaultConfig {
manifestPlaceholders = [
onesignal_app_id: 'f0f22efa-186b-4b17-be29-f3f86e4d6184',
onesignal_google_project_number: 'REMOTE'
]
}
}
packagingOptions {
exclude 'AndroidManifest.xml' //This fixes a bug in FAN 5.0.1
}
}
flutter {
source '../..'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics'
// das ist für alle sachen sehr wichtig
implementation 'com.google.firebase:firebase-firestore'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.onesignal:OneSignal:3.2.4'
}
android/build.gradle:
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我有最新的flutter版本,还有最新的flutter插件版本
PS:我使用 oneSignal。
请帮帮我!
这似乎是 OneSignal Grandle 插件的一个已知问题。
在讨论中提出了一些解决方案,它们似乎破坏了 OneSignal 或引起更多问题。
其中两个是:
- 在“android/app/build.gradle”的序列中将 onesignal 插件放在它后面。 信用:Direnalex comment
- 降级 Flutter 和 Kotlin。 图片来源:Dgilperez comment
我的建议是提请注意 Github 问题,以便 OneSignal 社区可以解决它。
为了解决上面的以下问题,我想看看你的 flutter doctor,和 verbose once 运行 app.
但请先尝试这个
1. downgrade your pub library , then do a pub repair, and flutter clean.
Did this solved the issue? if not Then do the following below.
2. downgrade your flutter version, and choose the stable channel for the down graded version, do a flutter clean, then pub repair, and fix the codes of yours to match the down graded version.
目前我遇到这个错误:
Microsoft Windows [Version 10.0.19043.1526]
(c) Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Flutter\StudioProjects\nomadnet>flutter run
Using hardware rendering with device sdk gphone x86 arm. If you notice graphics artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\Flutter\flutter_windows_2.10.1-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 421
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
* 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 37s
Running Gradle task 'assembleDebug'... 38,8s
Exception: Gradle task assembleDebug failed with exit code 1
我已经试过这个东西了:
- 我也尝试了更多的东西,但我不再了解它们了
我的代码:
app/build.gradle:
buildscript {
repositories {
// ...
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
}
dependencies {
// ...
// OneSignal-Gradle-Plugin
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.apps.social_circle"
minSdkVersion 20
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
android {
defaultConfig {
manifestPlaceholders = [
onesignal_app_id: 'f0f22efa-186b-4b17-be29-f3f86e4d6184',
onesignal_google_project_number: 'REMOTE'
]
}
}
packagingOptions {
exclude 'AndroidManifest.xml' //This fixes a bug in FAN 5.0.1
}
}
flutter {
source '../..'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-analytics'
// das ist für alle sachen sehr wichtig
implementation 'com.google.firebase:firebase-firestore'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.onesignal:OneSignal:3.2.4'
}
android/build.gradle:
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我有最新的flutter版本,还有最新的flutter插件版本
PS:我使用 oneSignal。
请帮帮我!
这似乎是 OneSignal Grandle 插件的一个已知问题。
在讨论中提出了一些解决方案,它们似乎破坏了 OneSignal 或引起更多问题。
其中两个是:
- 在“android/app/build.gradle”的序列中将 onesignal 插件放在它后面。 信用:Direnalex comment
- 降级 Flutter 和 Kotlin。 图片来源:Dgilperez comment
我的建议是提请注意 Github 问题,以便 OneSignal 社区可以解决它。
为了解决上面的以下问题,我想看看你的 flutter doctor,和 verbose once 运行 app.
但请先尝试这个
1. downgrade your pub library , then do a pub repair, and flutter clean.
Did this solved the issue? if not Then do the following below.
2. downgrade your flutter version, and choose the stable channel for the down graded version, do a flutter clean, then pub repair, and fix the codes of yours to match the down graded version.