Skip to content

Android Kotlin and Gradle issue #2621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rupertpople opened this issue Mar 5, 2025 · 1 comment
Closed

Android Kotlin and Gradle issue #2621

rupertpople opened this issue Mar 5, 2025 · 1 comment
Labels
question Further information is requested stale

Comments

@rupertpople
Copy link

rupertpople commented Mar 5, 2025

I have been in a loop the last couple of days trying to configure Kotlin and Gradle so I can develop my app for Android in react. Within my React app I get this error when running any gradle command:

The binary version of its metadata is 1.9.0, expected version is 1.6.0.

The class is loaded from C:/Users/user/.gradle/wrapper/dists/gradle-8.6-all/3mbtmo166bl6vumsh5k2lkq5h/gradle-8.6/lib/kotlin-stdlib-1.9.20.jar!/kotlin/collections/ArraysKt___ArraysKt.class

In my project level build. gradle I have:

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "23.1.7779620"
        kotlinVersion = '1.9.20'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:8.6.0")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") // Enforce Kotlin 1.6.0
    }
}

My app level build.gradle:

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: "kotlin-android" // Ensure Kotlin support
apply plugin: "kotlin-kapt"

import com.android.build.OutputFile

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    compileSdkVersion 34
    ndkVersion "23.1.7779620"

    namespace "com.project"

    defaultConfig {
        applicationId "com.project"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 1
        versionName "1.0"
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false
            include(*reactNativeArchitectures())
        }
    }

    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {
                output.versionCodeOverride =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }
        }
    }
}

dependencies {
    implementation("com.facebook.react:react-android")
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")

    debugImplementation("com.facebook.flipper:flipper:0.185.0")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:0.185.0") {
        exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:0.185.0")

    implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
applyNativeModulesAppBuildGradle(project)

gradle-wrapper.properties:


distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Project-wide Gradle settings.

org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
android.useAndroidX=true

android.enableJetifier=true

FLIPPER_VERSION=0.125.0
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64


newArchEnabled=false
hermesEnabled=true
kotlinVersion=1.9.20
settings.gradle:

rootProject.name = 'Project'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')
@rupertpople rupertpople added the question Further information is requested label Mar 5, 2025
Copy link

github-actions bot commented Jun 4, 2025

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

1 participant