I am creating an app in Android Studio IDE using Java, but whenever I build my project this error comes:
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10.
Required by:
project :app
I have checked all the previous answers, but they are outdated. I haven't even used Kotlin anywhere but despite of that, this error comes. Here's my app level Gradle code:
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'
}
and below is my project level Gradle code:
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
}
Please help because I cannot develop further features without testing older features. (The line 8 in project level Gradle file causes errors on being removed, so I am bound to keep it)
Edit 1 - Removed a confusing line from the code here as well as in my own file, didn't make any difference.
Edit 2 - Added a necessary line for more clarification.
CodePudding user response:
Add jcenter() to your repositories
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()
}
}
Also add java 11 to your project
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}