react-nativeexpo

expo-modules-core:compileReleaseKotlin FAILED


I updated my project to the latest version of React-Native and Expo

package.json

    "dependencies": {
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-community/checkbox": "^0.5.17",
    "@react-native-community/datetimepicker": "8.0.1",
    "@react-native-community/netinfo": "11.3.1",
    "@react-native-community/slider": "^4.5.2",
    "@react-native-firebase/app": "^19.0.1",
    "@react-native-masked-view/masked-view": "0.3.1",
    "@react-navigation/bottom-tabs": "^6.5.20",
    "@react-navigation/drawer": "^6.6.15",
    "@react-navigation/native": "^6.1.18",
    "@react-navigation/stack": "^6.3.29",
    "@rnmapbox/maps": "^10.1.30",
    "@sentry/react-native": "~5.22.0",
    "@turf/turf": "^6.5.0",
    "expo": "^51.0.32",
    "expo-constants": "~16.0.1",
    "expo-device": "~6.0.2",
    "expo-document-picker": "~12.0.1",
    "expo-file-system": "^17.0.1",
    "expo-image-picker": "~15.0.5",
    "expo-keep-awake": "~13.0.2",
    "expo-localization": "~15.0.3",
    "expo-location": "~17.0.1",
    "expo-modules-autolinking": "^1.10.3",
    "expo-notifications": "~0.28.3",
    "expo-print": "~13.0.1",
    "expo-sharing": "~12.0.1",
    "expo-task-manager": "~11.8.2",
    "firebase": "^10.8.1",
    "haversine": "^1.1.1",
    "i18n-js": "4.2.0",
    "install": "^0.13.0",
    "moment": "^2.30.1",
    "moment-duration-format": "^2.3.2",
    "papaparse": "^5.4.1",
    "react": "18.2.0",
    "react-native": "0.75.2",
    "react-native-cli": "^2.0.1",
    "react-native-dialog": "^9.3.0",
    "react-native-dotenv": "^3.4.10",
    "react-native-gesture-handler": "~2.19.0",
    "react-native-iap": "^12.13.0",
    "react-native-maps": "1.14.0",
    "react-native-mmkv": "^2.12.2",
    "react-native-modal": "^13.0.1",
    "react-native-modal-datetime-picker": "^17.1.0",
    "react-native-rate": "^1.2.12",
    "react-native-reanimated": "~3.15.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.34.0",
    "react-native-select-dropdown": "3.4.0",
    "react-native-star-rating-widget": "^1.7.3",
    "react-native-svg": "15.2.0",
    "react-native-vector-icons": "^10.1.0",
    "react-native-view-shot": "^3.8.0",
    "react-native-xml2js": "^1.0.3",
    "xml2js": "^0.6.2"
    }

It is a bare workflow app and i use a mac.

If I compile in Xcode for IOS, it all works fine. If I compile for Android in Android Studio it has the following error

> Task :expo-modules-core:compileReleaseKotlin FAILED
e: file:///Users/.../Documents/.../node_modules/expo-modules-core/android/src/main/java/expo/modules/kotlin/jni/JavaScriptValue.kt:42:7 Public-API inline function cannot access non-public-API property accessor.

I followed the official Expo SDK update documentation

Any ideas on how to solve this?


Solution

  • Found teh SOlution. React Native Upgrade Helper wants to set in android/build.gradle Kotlin to 1.9.24:

    compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "26.1.10909125"
        kotlinVersion = "1.9.24"
    }
    repositories {
        google()
    

    But Expo needs 1.9.23 as it stands in Expo Upgrade helper:

            minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
        kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'
        kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23'
    
        ndkVersion = "25.1.8937393"
        ndkVersion = "26.1.10909125"
    }
    repositories {
        google()
    dependencies {
        classpath('com.android.tools.build:gradle')
        classpath('com.facebook.react:react-native-gradle-plugin')
        classpath('org.jetbrains.kotlin:kotlin-gradle-plugin')
    }
    }
    

    My build.gradle now looks like this:

            minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
        kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'
        kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23'
    
        ndkVersion = "25.1.8937393"
        ndkVersion = "26.1.10909125"
    }
    repositories {
        google()
    dependencies {
        classpath('com.android.tools.build:gradle')
        classpath('com.facebook.react:react-native-gradle-plugin')
        classpath('org.jetbrains.kotlin:kotlin-gradle-plugin')
    }
    }
    

    and all works fine now.