错误报告
我已经开始学习React Native Navigation,但我无法启动应用程序,无法实现基本的导航代码。
重现步骤
1.运行:npm install --save react-native-navigation
。
1.编写basic navigation的代码。
1.运行:npx react-native start
。
1.运行:npx react-native run-android
。
预期行为
当前行为
alaeddine@Ala-Dev:~/Apps/GitaApp$ npx react-native run-android
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Starting JS server...
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 up-to-date
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/alaeddine/Apps/GitaApp/node_modules/react-native-navigation/lib/android/app/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Plugin with id 'kotlin-android' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/alaeddine/Apps/GitaApp/node_modules/react-native-navigation/lib/android/app/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Plugin with id 'kotlin-android' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 (/home/alaeddine/Apps/GitaApp/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /home/alaeddine/Apps/GitaApp/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/home/alaeddine/Apps/GitaApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/alaeddine/Apps/GitaApp/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
构建. gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
1条答案
按热度按时间50few1ms1#
我得到了同样的错误,这就是我解决问题的方法,
1.步骤-1)
npm install --save react-native-navigation
1.步骤-2)
npx rnn-link
1.如果
step-2
仍然抛出错误,则按照Manual installation
在文档中手动提供的项目中进行更改:1.步骤-3)编写基本导航代码
1.步骤-4)运行:
npm start
1.步骤-5)运行:
npm run android
(适用于机器人)