Context: Im building an app that is for API 34. Gr...
# community-support
h
Context: Im building an app that is for API 34. Gradle 8.7, Android Gradle 8.5.0, Kotlin 2.0.20 Im having a few error that is preventing me from syncing and building into apk inside Android Studio: Issue 1:
Copy code
unable to detect project KGP version. Skipping version checking.
Issue 2:
Copy code
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
   > Could not find org.jetbrains.kotlin:kotlin-stdlib:2.0.20.
     Required by:
         project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at <https://docs.gradle.org/current/userguide/declaring_repositories.html>
Issue 3:
Copy code
Could not find org.jetbrains.kotlin:kotlin-stdlib:2.0.20.
Required by:
    project :app
Search in build.gradle files
For my app/build.gradle:
Copy code
plugins {
    id 'com.android.application' version '8.5.0'
    id 'org.jetbrains.kotlin.android' version '2.0.20'
    id 'dev.flutter.flutter-gradle-plugin'
    id 'com.google.gms.google-services' version '4.4.2'
}



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'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace 'com.example.application'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        applicationId "com.example.com"
        minSdkVersion 21
        compileSdk 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
        }
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    ndkVersion '25.1.8937393'
    compileSdk 34
}

flutter {
    source '../..'
}
My android/build.gradle:
Copy code
allprojects {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}
Any help would be greatly appreciated (Im very new to gradle, flutter, kotlin gradle and mobile development)
v
Can you provide build
--scan
URL of the errors? The first might be a follow-up error due to 2/3, 2 and 3 look like the same. But you seem to have cut important information
h
v
Well, the output is quite clear, isn't it?
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
You can figure out how project repositories are declared by configuring your build to fail on project repositories.
For more information, please refer to https://docs.gradle.org/8.7/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories in the Gradle documentation.
So you declared repositories in your settings script with the default "prefer project" policy. Then you applied the misbehaving flutter plugin which adds a project repository unasked which is bad practice. By this it overwrites all repositories you declared in the settings script and thus KGP is not found. Either make flutter plugin not misbehave, or move your repository to the build script or a convention plugin, or use the "prefer settings" policy and add the repository the flutter plugin is adding manually to your settings script.