首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复不能转换kotlin-android-扩展-1.3.71.jar‘使用Jetifier错误?

如何修复不能转换kotlin-android-扩展-1.3.71.jar‘使用Jetifier错误?
EN

Stack Overflow用户
提问于 2020-04-02 22:47:46
回答 3查看 4.3K关注 0票数 4

任务执行失败:app:mergeDebugJavaResource‘。

无法解析配置的所有文件“:app:调试器运行时Could”。未能将工件‘kotlin-android-exsions.jar (org.jetbrains.kotlin:kotlin-android-extensions:1.3.71)’转换为匹配属性{artifactType=android,org.gradle.libraryelements=jar,org.gradle.use=java-运行时}。执行失败的C:\Users\user.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions\1.3.71\ea43e0e563e1915ea845a482fd6f31a948386ab9\kotlin-android-extensions-1.3.71.jar.:JetifyTransform:未能使用Jetifier转换'C:\Users\user.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-android-extensions\1.3.71\ea43e0e563e1915ea845a482fd6f31a948386ab9\kotlin-android-extensions-1.3.71.jar‘。原因:给定的工件包含一个带有包引用'android.support.v4‘的字符串文字,无法安全地重写。使用反射(如注释处理器)的库需要手动更新以添加对androidx的支持。

app build.gradle

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.appname"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    //to avoid retrofit client error
    compileOptions {
        targetCompatibility = JavaVersion.VERSION_1_8
        sourceCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }
}
androidExtensions {
    experimental = true
}

dependencies {
    ext.kotlin_version = '1.3.71'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    def lifecycle_version = '2.2.0'
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    // Optional : Kotlin extension (https://d.android.com/kotlin/ktx)
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation 'androidx.core:core-ktx:1.2.0'
    def appcompat_version = "1.1.0"

    implementation "androidx.appcompat:appcompat:$appcompat_version"
    // For loading and tinting drawables on older versions of the platform
    implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "androidx.viewpager2:viewpager2:1.0.0"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation 'com.google.android.gms:play-services-maps:17.0.0'

    //GIF
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'

    ext {
        retrofit_version = '2.8.1'
    }
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation("io.reactivex.rxjava2:rxkotlin:2.4.0")
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    // Skip this if you don't want to use integration libraries or configure Glide.
    kapt 'com.github.bumptech.glide:compiler:4.11.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'

    def room_version = "2.2.5"

    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version" // For Kotlin use kapt instead of annotationProcessor

    // optional - Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$room_version"

    // optional - RxJava support for Room
    implementation "androidx.room:room-rxjava2:$room_version"
}
repositories {
    mavenCentral()
}
apply plugin: 'com.google.gms.google-services'

gradle.properties

代码语言:javascript
运行
复制
org.gradle.jvmargs=-Xmx1536m
org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
kotlin.caching.enabled=false

项目gradle.build

代码语言:javascript
运行
复制
buildscript {
    ext.kotlin_version = '1.3.71'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 
        classpath 'com.google.gms:google-services:4.3.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

回答 3

Stack Overflow用户

发布于 2020-04-27 15:01:46

在我的例子中,删除行

代码语言:javascript
运行
复制
    implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

应用程序build.gradle解决了这个问题。"Kotlin扩展“功能似乎是通过在项目classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"apply plugin: 'kotlin-android-extensions'中添加build.gradle获得的。

以下是一个相关的问题(但尚未得到答复):

Failed to transform artifact 'kotlin-android-extensions.jar

票数 6
EN

Stack Overflow用户

发布于 2020-04-03 00:26:04

实际上,kotlin-android-extensions是一个Gradle插件,而不是代码依赖。

尝试删除和删除以下内容:

代码语言:javascript
运行
复制
implementation files('jetifier-processor-1.0.0-beta09')
implementation files('jetifier-core-1.0.0-beta09')

并将这些行添加到文件gradle.properties

代码语言:javascript
运行
复制
android.useAndroidX=true
android.enableJetifier=true

并在尝试构建之前将目录C:\Users\user.gradle\caches为空。

票数 1
EN

Stack Overflow用户

发布于 2020-04-04 06:31:54

改进型gradle.properties

代码语言:javascript
运行
复制
org.gradle.jvmargs=-Xmx1536m
org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=false

项目build.gradle

代码语言:javascript
运行
复制
buildscript {
    ext.kotlin_version = '1.3.71'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

和app bild.gradle

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.appname"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    //to avoid retrofit client error
    compileOptions {
        targetCompatibility = JavaVersion.VERSION_1_8
        sourceCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }
}
androidExtensions {
    experimental = true
}

dependencies {
    ext.kotlin_version = '1.3.71'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    implementation "androidx.annotation:annotation:1.1.0"
    // To use the Java-compatible @Experimental API annotation
    implementation "androidx.annotation:annotation-experimental:1.0.0"


    def appcompat_version = "1.1.0"

    implementation "androidx.appcompat:appcompat:$appcompat_version"
    // For loading and tinting drawables on older versions of the platform
    implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "androidx.viewpager2:viewpager2:1.0.0"
    implementation 'com.google.android.gms:play-services-maps:17.0.0'

    //GIF
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'

    ext {
        retrofit_version = '2.8.1'
    }
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation("io.reactivex.rxjava2:rxkotlin:2.4.0")
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'

    def room_version = "2.2.5"

    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
}
repositories {
    mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61002390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档