我的任務是使用 React Native 構建 apk 應用程式,我觀看了這個視頻以了解如何做并采用了相同的代碼 https://www.youtube.com/watch?v=5tgcogEoIiQ&t=590s
https://github.com/mahdi-sharifimehr/RN-Tutorial-Main/tree/RN-Tutorial-35 我得到這樣的錯誤:
> Task :app:processDebugManifest FAILED
Type 'ProcessApplicationManifest': static method 'getArtifactName()' should not be annotated with: @Internal. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Type 'ProcessApplicationManifest': static method 'getNameFromAutoNamespacedManifest()' should not be annotated with: @Internal. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
/root/escrow_checker/apps/RN-Tutorial-Main-RN-Tutorial-35/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.71.0-rc.0] /root/.gradle/caches/transforms-2/files-2.1/af47c244ab2af63c65c98f6eb4516ef2/jetified-react-native-0.71.0-rc.0-debug/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)
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
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.71.0-rc.0] /root/.gradle/caches/transforms-2/files-2.1/af47c244ab2af63c65c98f6eb4516ef2/jetified-react-native-0.71.0-rc.0-debug/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 19s
在網上找了一個解決方案,將build.gradle中的minSdkVersion改為23,但是現在出現這樣的錯誤:
> Task :app:processDebugResources FAILED
Type 'LinkApplicationAndroidResourcesTask': non-property method 'canHaveSplits()' should not be annotated with: @Input. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/root/.gradle/caches/transforms-2/files-2.1/991cf6dc746cd39d23cce3c15a61bfa7/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.
請告訴我出了什么問題以及為什么我不能輕松構建 apk,這是我在主目錄中的操作 npm install cd android chmod x ./gradlew ./gradlew assembleDebug
Gradle 版本 Gradle 7.4.2
我不明白為什么它不想構建,理論上我應該得到 apk
uj5u.com熱心網友回復:
" uses-sdk:minSdkVersion 16 不能小于庫中宣告的版本 21 "
看起來您的 minSdkVersion 與您正在使用的 Facebook 庫不兼容。您使用的是哪種 React Native 專案?
如果它是 expo 管理的,你需要這個:https ://docs.expo.dev/versions/latest/sdk/build-properties/
如果它是一個非 expo 專案,您可以輕松地自行進入 Android 檔案。此鏈接將幫助您:How to specify the minSdkVersion in react native project
您可能只需要將 16 更改為 21 即可構建。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/534232.html
