skip to Main Content

I’m currently having the following error in Flutter /Android studio
I couldn’t find any help on google:

Warning: unable to detect project KGP version. Skipping version
checking. This may be because you have applied KGP after the Flutter
Gradle Plugin.

e:
/Users/…/android/app/src/main/kotlin/com/example/esosba_app/MainActivity.kt:
(3, 8): Unresolved reference: io e:
/Users/…/android/app/src/main/kotlin/com/example/esosba_app/MainActivity.kt:
(5, 21): Unresolved reference: FlutterActivity

this is my Gradle :

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
       
    }
}

plugins {
    id "com.android.application" version "8.0.0"
    id "org.jetbrains.kotlin.android" version "1.7.10"
   id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
 namespace 'com.example.esosba_app' // Fügen Sie diesen Eintrag hinzu
    compileSdkVersion 33
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.esosba_app"
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug // TODO: Hier sollte ein //Signatur-Konfigurationsblock angefügt werden.
        }
    }
}

flutter {
    source '../..'
}

dependencies {
   implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"

   
}

And my MainActivity.kt

package com.example.esosba_app

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

Does anyone know how to solve this problem? Thank you very much

2

Answers


  1. You may need to change your gradle files according to this.
    https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply
    I can see some differences in your gradle. Make sure that you change your app level gradle, root level gradle and gradle settings according to the above article.

    Login or Signup to reply.
  2. inside :

    android/gradle/wrapper/gradle-wrapper.properties

    just change distributionUrl to :

    distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip

    or

    distributionUrl=https://services.gradle.org/distributions/gradle-8.3-all.zip

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search