首页 > 解决方案 > 不再支持源选项 5。在 android studio 中使用 6 或更高版本

问题描述

我正在尝试在我的 Windows 机器上构建一个 android 应用程序。构建时低于错误。自 2 个月以来我一直在研究我的 android 项目,但现在我收到错误我正在使用 android studio 4.2.1,而我试图构建 apk 它给出了错误我不知道如何使用 mavenCentral() 请帮助

            Source option 5 is no longer supported. Use 6 or later.

我最近在 build.gradle 中添加了 mavenCentral()

               allprojects {
repositories {
    google()
    mavenCentral()
//    jcenter() //  Warning: this repository is going to shut down soon ( 
     // i replaced jcenter() to   mavenCentral()
   }
      }

错误截图

构建.gradle

其他 Gradle 文件代码是这个

      apply plugin: 'com.android.application'
      apply plugin: 'com.google.gms.google-services'
      apply plugin: 'kotlin-android'

      android {

          compileSdkVersion 30
          buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.example.myshop"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
   }

  buildFeatures {
      viewBinding true
  }
  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard- 
rules.pro'
    }
}
compileOptions {
    sourceCompatibility kotlin_version
    targetCompatibility kotlin_version
}
kotlinOptions {
    jvmTarget = '1.8'
}
  }

 dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  implementation 'androidx.core:core-ktx:1.5.0'
 implementation 'androidx.appcompat:appcompat:1.3.0'
  implementation 'com.google.android.material:material:1.3.0'
 implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
 testImplementation 'junit:junit:4.13.2'
 androidTestImplementation 'androidx.test.ext:junit:1.1.2'
 androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-firestore:23.0.0'
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'


implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation 'com.google.firebase:firebase-analytics-ktx:19.0.0'
implementation 'com.google.android.material:material:1.3.0'
// glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
//Adding coroutines to a project
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"

}

标签: androidandroid-studio

解决方案


在 pom 文件中找到了解决方案。不幸的是,这意味着你必须制作一个 pom 文件。

要生成 pom 文件,您需要按照此答案中的说明进行操作。

生成 pom.xml 文件后,尝试添加:

<properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

推荐阅读