ERROR Task :expo:compileDebugKotlin FAILED



我使用react-native init创建了一个应用程序,并运行良好,直到我试图开始使用expo在我的电话上测试它。

尝试用expo (npx expo start)启动应用程序,我有:

Developer tools running on http://localhost:19002
Opening developer tools in the browser...
Some dependencies are incompatible with the installed expo package version:
- @react-native-community/slider - expected version: 4.1.7 - actual version installed: 4.1.10
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]
Starting Metro Bundler
Error: Problem validating fields in app.json. Learn more: https://docs.expo.dev/workflow/configuration/
should NOT have additional property 'displayName'.

,在expo中的应用变成全白色。

另外,如果我尝试使用react-native (npx react-native run-android),我有:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1190 file(s) to forward-jetify. Using 6 workers...
> Configure project :expo
> Task :expo:compileDebugKotlin FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
87 actionable tasks: 3 executed, 84 up-to-date
Error: Autolinking is not set up in `settings.gradle`: expo modules won't be autolinked.
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (11, 18): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (11, 23): Unresolved reference: createApplicationLifecycleListeners
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (12, 20): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (18, 18): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (18, 23): Unresolved reference: createApplicationLifecycleListeners
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (19, 20): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesExpoModulesPackage.kt: (10, 21): Unresolved reference: adapters
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesExpoModulesPackage.kt: (11, 21): Unresolved reference: core
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesExpoModulesPackage.kt: (16, 31): Unresolved reference: ModuleRegistryAdapter
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.kt: (22, 14): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.kt: (22, 19): Unresolved reference: createReactActivityLifecycleListeners
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (23, 14): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (23, 19): Unresolved reference: createReactNativeHostHandlers
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (30, 14): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (57, 14): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (63, 14): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.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:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Error: Autolinking is not set up in `settings.gradle`: expo modules won't be autolinked.
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (11, 18): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (11, 23): Unresolved reference: createApplicationLifecycleListeners
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (12, 20): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (18, 18): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (18, 23): Unresolved reference: createApplicationLifecycleListeners
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesApplicationLifecycleDispatcher.kt: (19, 20): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesExpoModulesPackage.kt: (10, 21): Unresolved reference: adapters
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesExpoModulesPackage.kt: (11, 21): Unresolved reference: core
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesExpoModulesPackage.kt: (16, 31): Unresolved reference: ModuleRegistryAdapter
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.kt: (22, 14): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.kt: (22, 19): Unresolved reference: createReactActivityLifecycleListeners
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactActivityDelegateWrapper.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: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (23, 14): Type mismatch: inferred type is Unit but Iterable<TypeVariable(R)> was expected
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (23, 19): Unresolved reference: createReactNativeHostHandlers
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (30, 14): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (57, 14): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.kt: (63, 14): Unresolved reference: it
e: C:ProyectospropiosPlacitnode_modulesexpoandroidsrcmainjavaexpomodulesReactNativeHostWrapper.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:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
at makeError (C:ProyectospropiosPlacitnode_modules@react-native-communitycli-platform-androidnode_modulesexecaindex.js:174:9)
at C:ProyectospropiosPlacitnode_modules@react-native-communitycli-platform-androidnode_modulesexecaindex.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async runOnAllDevices (C:ProyectospropiosPlacitnode_modules@react-native-communitycli-platform-androidbuildcommandsrunAndroidrunOnAllDevices.js:106:5)
at async Command.handleAction (C:ProyectospropiosPlacitnode_modulesreact-nativenode_modules@react-native-communityclibuildindex.js:192:9)

这是我的package.json:

{
"name": "placit",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-native-fontawesome": "^0.2.7",
"@react-native-async-storage/async-storage": "^1.15.9",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-community/slider": "^4.1.10",
"@react-navigation/native": "^6.0.6",
"@react-navigation/native-stack": "^6.2.4",
"expo": "^43.0.1",
"react": "17.0.2",
"react-native": "0.66.0",
"react-native-elements": "^3.4.2",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.8.0",
"react-native-svg": "^12.1.1",
"react-redux": "^7.2.5",
"redux": "^4.1.1",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "7.15.8",
"@babel/runtime": "7.15.4",
"@react-native-community/eslint-config": "2.0.0",
"babel-jest": "26.6.3",
"eslint": "7.14.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.66.2",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}

升级到Kotlin v1.5.10修复了这个问题。

将以下代码添加到/android/build中。级依赖关系

dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
...
}

你可以自己安装,当我运行expo run:android

expo install expo-linear-gradient

需要将此添加到android/build.gradle

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}}}

我所面对的:

我得到了一个类似的错误,像这样

: expo-modules-core: compileDebugKotlin

What I tried:

在花了这么多时间寻找解决方案之后,在尝试了这些对某些人有效但对我却行不通的命令之后,

cd android && ./gradlew clean && cd ../ && rm -rf node_modules && yarn && npx react-native run-android

实际修复:

显然,它正在寻找Kotlin编译器,但它没有找到它,所以通过将此添加到

来修复它。android/build.gradle

buildscript {
...
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10" // <-- add this
...
}
}

然后运行

npx react-native run-android

奏效了

相关内容

  • 没有找到相关文章

最新更新