Home > Back-end >  Cannot run Project.afterEvaluate(Closure) when the project is already evaluated
Cannot run Project.afterEvaluate(Closure) when the project is already evaluated

Time:02-28

currently i am having this error:

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

i already tried this things:


my code:

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
}

i have the latest flutter version and also the latest flutter plugin version.

PS: i use oneSignal.

Please help me!

CodePudding user response:

It looks like that's a known issue with the OneSignal Grandle plugin.

Github OneSignal Issue

In the discussion some solutions are proposed, by they seem to broke OneSignal or to cause more issue.

Two of them are:

My suggestion is to bring attention to the Github Issue so that it can be solved by the OneSignal community.

  • Related