我正在使用 Java 在 Android Studio IDE 中創建一個應用程式,但是每當我構建我的專案時,都會出現此錯誤:
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10.
Required by:
project :app
我已經檢查了所有以前的答案,但它們已經過時了。我什至沒有在任何地方使用過 Kotlin,但盡管如此,還是出現了這個錯誤。這是我的應用級 Gradle 代碼:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.safechat"
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'com.google.firebase:firebase-auth:21.0.1'
testImplementation 'junit:junit:'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:29.0.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.browser:browser:1.4.0'
}
以下是我的專案級 Gradle 代碼:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
請幫忙,因為我無法在不測驗舊功能的情況下開發更多功能。(專案級 Gradle 檔案中的第 8 行在洗掉時會導致錯誤,所以我一定要保留它)
編輯 1 - 從這里的代碼和我自己的檔案中洗掉了一個令人困惑的行,沒有任何區別。
編輯 2 - 添加了必要的行以進行更多說明。
uj5u.com熱心網友回復:
將 jcenter() 添加到您的存盤庫
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
還將 java 11 添加到您的專案中
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/387122.html
上一篇:gradle不匯入本地java庫
