android - 我需要帮助才能从 Windows 上的 Git Hub 运行 React 本机应用程序
问题描述
我需要帮助才能在我的手机上运行这个 React 本机应用程序。https://github.com/minhtc/audiobookapp Expo Go 安装在我的安卓手机上。当我运行以下命令时:
- npm 安装
- npx react-native run-android
这就是我得到的。你能帮我吗 ?
D:\GIT Hub\audiobookapp>npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :app:processDebugManifest FAILED
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
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.5/userguide/command_line_interface.html#sec:command_line_warnings
51 actionable tasks: 3 executed, 48 up-to-date
D:\GIT Hub\audiobookapp\android\app\src\debug\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.64.2] C:\Users\olinga\.gradle\caches\transforms-2\files-2.1\766c9672dfddf764e285b6ee68a73930\jetified-react-native-0.64.2\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.facebook.react" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.64.2] C:\Users\olinga\.gradle\caches\transforms-2\files-2.1\766c9672dfddf764e285b6ee68a73930\jetified-react-native-0.64.2\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.facebook.react" to force usage (may lead to runtime failures)
* 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 1m 37s
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
D:\GIT Hub\audiobookapp\android\app\src\debug\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.64.2] C:\Users\olinga\.gradle\caches\transforms-2\files-2.1\766c9672dfddf764e285b6ee68a73930\jetified-react-native-0.64.2\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.facebook.react" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
解决方案
在这种情况下,我认为您项目中的一个库使用 21 的 minSdkVersion。您的项目 minSdkVersion 是 16。这些版本之间的不兼容导致了这个问题。
我认为如果您将项目 minSdkVersion 增加到 21,问题就解决了。为此,打开 android 根目录中的根 Gradle 文件,在本节中将 16 更改为 21:
buildscript {
ext {
...
minSdkVersion = 16 --> minSdkVersion = 21
...
}
}
推荐阅读
- flutter - 从firebase获取数据以插入MultiSelectFormField(小部件)
- jmeter - 如何从服务器上传和运行 jmeter 脚本
- python - 我正在尝试使用 pytorch 库构建一个带有一个神经元的神经网络。它一直给我一个错误
- python - 卡在“列表索引必须是整数或切片,而不是元组”错误
- python - 为什么列表中的某些项目不会在迭代中打印?
- javascript - 当我写一个正确的单词时,我的 if 和 else 都会同时被执行
- c++ - 指针中的错误分配
- php - DateTime 修改函数跳过二月
- django - 有没有办法从 django 模型中返回特定字段的第一个实例的查询集
- java - 如何在 Java 中高效地创建和写入多个文件?