首页 > 解决方案 > 我需要帮助才能从 Windows 上的 Git Hub 运行 React 本机应用程序

问题描述

我需要帮助才能在我的手机上运行这个 React 本机应用程序。https://github.com/minhtc/audiobookapp Expo Go 安装在我的安卓手机上。当我运行以下命令时:

这就是我得到的。你能帮我吗 ?

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.

标签: androidreactjsreact-nativenative

解决方案


在这种情况下,我认为您项目中的一个库使用 21 的 minSdkVersion。您的项目 minSdkVersion 是 16。这些版本之间的不兼容导致了这个问题。

我认为如果您将项目 minSdkVersion 增加到 21,问题就解决了。为此,打开 android 根目录中的根 Gradle 文件,在本节中将 16 更改为 21:

buildscript {
    ext {
        ...
        minSdkVersion = 16 --> minSdkVersion = 21
        ...
    }
}

推荐阅读