【问题标题】:React-Native error Task :expo:compileReleaseKotlin FAILEDReact-Native 错误任务:expo:compileReleaseKotlin FAILED
【发布时间】:2022-01-04 00:07:50
【问题描述】:

我在使用 Expo 的 React Native 项目中运行以下内容时遇到错误。我尝试了不同版本的 Expo,并删除并重新创建了 node_modules 和 package-lock.json 文件。

./gradlew bundleRelease --stacktrace
> Task :expo:compileReleaseKotlin FAILED
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (11, 18): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (11, 23): Unresolved reference: createApplicationLifecycleListeners
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (12, 10): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (12, 20): Unresolved reference: it
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (18, 18): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (18, 23): Unresolved reference: createApplicationLifecycleListeners
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (19, 10): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ApplicationLifecycleDispatcher.kt: (19, 20): Unresolved reference: it
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ExpoModulesPackage.kt: (10, 21): Unresolved reference: adapters
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ExpoModulesPackage.kt: (11, 21): Unresolved reference: core
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ExpoModulesPackage.kt: (16, 31): Unresolved reference: ModuleRegistryAdapter
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (22, 14): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (22, 19): Unresolved reference: createReactActivityLifecycleListeners
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (53, 37): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (60, 37): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (66, 37): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactActivityDelegateWrapper.kt: (73, 37): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (23, 14): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (23, 19): Unresolved reference: createReactNativeHostHandlers
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (30, 14): Unresolved reference: it
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (57, 14): Unresolved reference: it
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (63, 14): Unresolved reference: it
e: /Users/anderbard/Development/cloversocial/MyApp/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapper.kt: (85, 31): Overload resolution ambiguity: 
public inline fun <T> Iterable<TypeVariable(T)>.forEach(action: (TypeVariable(T)) -> Unit): Unit defined in kotlin.collections
public inline fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.forEach(action: (Map.Entry<TypeVariable(K), TypeVariable(V)>) -> Unit): Unit defined in kotlin.collections

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':expo:compileReleaseKotlin'.

我需要更旧版本的 Expo 吗?有什么建议吗?

【问题讨论】:

  • 尝试降级 expo 版本并检查。
  • 这与删除 android 和 ios 并运行 expo prebuild 相结合

标签: android react-native gradle expo


【解决方案1】:

只需删除 Android 和 iOS 文件夹并使用 expo 弹出重新创建它们对我有用。在查看 android 文件夹中的更改后,与 42 相比,Expo 44 中有很多非常不同的文件,这可能是它无法构建的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-22
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2022-11-12
    • 2021-09-15
    • 2023-03-16
    • 2020-07-30
    相关资源
    最近更新 更多