[英]react-native-audio-recorder-player error Plugin with id "kotlin-android" not found. compileSdkVersion is not specified
[英]compileSdkVersion is not specified error in React Native Android
當我嘗試在我的 React Native 項目中構建 Android 應用程序時出現構建錯誤。
當我運行react-native run-android
時,它說:
> Configure project :react-native-os
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-os'.
> compileSdkVersion is not specified.
在 Android Studio 中,我可以看到它說了同樣的話: Cause: compileSdkVersion is not specified.
所以我在 Android Studio 中編輯了 build.gradle(Module: app) 文件,但問題仍然存在,錯誤信息沒有改變。
android {
// compileSdkVersion rootProject.ext.compileSdkVersion
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
我在其他線程中嘗試過類似的解決方案,但沒有任何效果。 有誰知道這里的問題是什么?
最簡單有效的解決方案,如果發生這種情況反應原生移動到 node_module/@react-native-firebase/ 對於所有模塊示例 - app、firestore 等。轉到他們的 android 文件夾並打開 build.gradle 你會看到,
project.ext {
set('react-native', [
versions: [
android : [
minSdk : 'same your project version root folder/android/app/build.gradle',
targetSdk : 'same your project version root folder/android/app/build.gradle',
compileSdk: 'same your project version root folder/android/app/build.gradle',
buildTools: 'same your project version root folder/android/app/build.gradle'
],
firebase: [
bom: firebaseBomVersion,
],
],
])
}
希望這使它起作用。 快樂編碼:)
Go 到node_module>@react-native-firebase>messaging>android>build.gradle
查找定義最小值和目標 sdk 的代碼,並定義 sdk 和與主項目build.gradle文件中相同的構建版本。
然后運行命令cd android &&./gradlew clean && cd..
還要確保您已在應用級別build.gradle中定義了默認配置 firebase 確保您在build.gradle之上導入了此導入:應用插件:“com.google.gms.google-services”和默認配置為: defaultConfig { applicationId "..." minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 00 versionName "... multiDexEnabled true }
我認為您正在使用Android Supported Library 。
如果你是27+ 支持的庫,你應該使用compileSdkVersion 27和targetSdkVersion 27
確保你在 android/app/build.gradle 中有:
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
(這個錯誤發生在我不小心將configuration.compile更改為configuration.implementation之后)
我今天也遇到了同樣的問題,並設法通過以下方式解決:
npm i
$ cd android
$ ./gradlew clean
$ cd ..
$ react-native run-android
希望這可以幫助
檢查你的 android/app/build.gradle 是否有印刷錯誤。
我的問題是由 gradle 找不到node
命令引起的。
# fixed by linking the node path to the /usr/bin/node
# node is binary was located in $HOME/.nvm/versions/node/v14.13.0/bin/node
sudo ln -s $(which node) /usr/bin/node
當我運行上面的命令時,上面的問題就消失了。
也許我回答得太晚了,但可能的原因是如果您的 build.gradle 版本高於 7,您也可能會收到 maven 的錯誤,找不到 ID 為“maven”的插件。 如果您嘗試按照這些步驟並解決 sdk 編譯錯誤消失的錯誤。
https:\/\/lifesaver.codes\/answer\/plugin-with-id-maven-not-found-12774<\/a>
這在我的情況下有效
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.