English 中文(简体)
科特林图书馆得到了一名新的科特林汇编员的遵守,可以读到
原标题:Kotlin library was complied with a newer Kotlin compiler and can t be read

Hello I tried to run Kotlin file on Android Studio (version 4.1) and I got an error: Kotlin library {0} was compiled with a newer Kotlin compiler and can t be read. Please update Kotlin plugin.

Even I got this error I m able to run kotlin files but Ide don t gives me tips when I use kotlin functions and methods are marked by red colour. Kotlin version in gradle is 1.6.0, if I m return to older version I can see tips about method names and red colour is not showed. Gradle build(app):

plugins {
    id  com.android.application 
    id  kotlin-android 
}

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.kotlin_udemy4"
        minSdkVersion 26
        targetSdkVersion 31
        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 
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation  androidx.core:core-ktx:1.7.0 
    implementation  androidx.appcompat:appcompat:1.4.2 
    implementation  com.google.android.material:material:1.6.1 
    testImplementation  junit:junit:4.+ 
    androidTestImplementation  androidx.test.ext:junit:1.1.3 
    androidTestImplementation  androidx.test.espresso:espresso-core:3.4.0 
}

逐步建设:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.6.0"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

是否有任何人知道如何解决这一问题?

问题回答

我有同样的问题。 为了解决这一问题,我做了以下工作:

  1. I try to Rebuild the project, then this error log appear: The minCompileSdk (32) specified in a dependency s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module s compileSdkVersion (android-31). Dependency: androidx.appcompat:appcompat-resources:1.5.0. AAR metadata file: C:Users..........

  2. 下游和roid状腺脂:配对1.4.0,然后是yn。 这就是说。

Maybe you can try this way.

Besides Kotlin version 1.6.21 ...

该版本的“Series”似乎已经过时;例如,目前版本的“Chipmunk”使用:

  • com.android.tools.build:gradle:7.2.1
  • jcenter() should be replaced with mavenCentral().
  • And also, use JavaVersion.VERSION_11.

这个问题是由于你的项目gradle版本。

您可以尝试以下步骤,以克服这一错误,在以下步骤中提升你的和海底工作室的版本。

  1. 进入buil.gradle(项目水平),并更新你的建筑工具和原始材料。

    dependencies { //Old version classpath "com.android.tools.build:gradle:7.0.0-rc01" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

       // change to the new one
        classpath "com.android.tools.build:gradle:7.2.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
    

    iii

  2. Now navigate to the gradle-wrapper.properties and update your gradel version

// old version distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip

// change to the new version distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip

  1. And finally change your compile sdk version in build.gradle(module level)

//old version
compileSdk 31

//new version compileSdk 34

请假 如果你不相信新版本,就简单地将新版本的改动推向上版本,将强调新版本,并据此更新。

Next to isssue popup i selected "Details" link and there was information about expected version. Probably because I m using older Android studio I got the problem. I updated Kotlin in gradle build to: 1.4.32 according to message. enter image description here





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签