react-native-mlkit-ocr
react-native-mlkit-ocr copied to clipboard
expo build errors for android (wrong kotlin version)
Hello!
I love this package, been working great for me in a managed expo / eas build project. But with my latest update, it only builds fine on iOS. On Android, it I get the following error: "Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15."
Unsure of how to tackle this, any pointers would be much appreciated. Is there a way to override the kotlin version manually?
My package versions:
...
"expo": "^46.0.13",
"react-native-mlkit-ocr": "0.2.5",
...
The build error logs:
[stderr] e: /home/expo/.gradle/caches/transforms-3/0485c57e77da2d74e4400ab5f4119067/transformed/jetified-kotlin-stdlib-jdk8-1.6.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/39ce31cacf59c39e98c8af78aab9d48a/transformed/jetified-react-native-0.69.6-release-api.jar!/META-INF/ReactAndroid_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/71974a8810180bf42d7354e2ae463e17/transformed/jetified-kotlin-stdlib-common-1.6.10.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/76ffa0bc7ee35e73adab5c035a9c7f86/transformed/jetified-kotlin-stdlib-jdk7-1.6.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (21, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (26, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (35, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (37, 17): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (38, 11): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (41, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (42, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (48, 5): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (49, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (50, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (51, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (52, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (54, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (55, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (56, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (57, 19): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (68, 16): Unresolved reference: forEach
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (68, 26): Cannot infer a type for this parameter. Please specify it explicitly.
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (70, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (71, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (72, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (88, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (89, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (90, 13): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (91, 24): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (95, 11): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (96, 11): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (97, 11): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (98, 11): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (100, 23): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (106, 12): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (107, 12): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (108, 12): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (109, 12): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
[stderr] The class is loaded from /home/expo/.gradle/caches/transforms-3/f9a6c4180d9d810f143b823eeeb39ba3/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
[stderr] e: /home/expo/workingdir/build/app/node_modules/react-native-mlkit-ocr/android/src/main/java/com/reactnativemlkitocr/MlkitOcrModule.kt: (110, 12): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
Update on this one: I managed to solve it from the expo / eas build side by writing a config plugin:
./kotlin-version-plugin.js:
const { withGradleProperties } = require('@expo/config-plugins');
function withKotlinGradle(config, version) {
return withGradleProperties(config, config => {
console.log(
`[config-plugins/kotlin-version] Setting android.kotlinVersion to: ${version}. This could lead to Android build issues.`
);
config.modResults = setKotlinVersion(config.modResults, version);
return config;
});
}
function setKotlinVersion(gradleProperties, version) {
const updatedProps = [...gradleProperties];
updatedProps.push({
type: 'property',
key: 'kotlinVersion',
value: version,
});
return updatedProps;
}
module.exports = withKotlinGradle;
app.json:
...
"plugins": [
[
"./kotlin-version-plugin",
"1.6.0"
]
]
...
and now the build works :)
@jonasbetareader Thanks so much for posting this man!
Update on this one: I managed to solve it from the expo / eas build side by writing a config plugin:
./kotlin-version-plugin.js: const { withGradleProperties } = require('@expo/config-plugins'); function withKotlinGradle(config, version) { return withGradleProperties(config, config => { console.log( `[config-plugins/kotlin-version] Setting android.kotlinVersion to: ${version}. This could lead to Android build issues.` ); config.modResults = setKotlinVersion(config.modResults, version); return config; }); } function setKotlinVersion(gradleProperties, version) { const updatedProps = [...gradleProperties]; updatedProps.push({ type: 'property', key: 'kotlinVersion', value: version, }); return updatedProps; } module.exports = withKotlinGradle;app.json: ... "plugins": [ [ "./kotlin-version-plugin", "1.6.0" ] ] ...and now the build works :)
Had the same issue on expo 47, tried this and it seams to be working.
You don't need to write a custom plugin. expo-build-properties lets you modify the kotlin version used. Adding this should work:
app.json:
...
"plugins": [
[
"expo-build-properties",
{
"android": {
"kotlinVersion": "1.6.21"
}
}
]
]
...