尝试通过Refractor>迁移到AndroidX迁移到androidx时,我已经尝试了很多次(使缓存无效并重新启动,清理,重建),但是每次完成一些处理和加载并出现以下错误日志时:

java.lang.IllegalArgumentException: Argument for @NotNull parameter 'element' of org/jetbrains/android/refactoring/MigrateToAppCompatUsageInfo$GradleUsageInfo.<init> must not be null
    at org.jetbrains.android.refactoring.MigrateToAppCompatUsageInfo$GradleUsageInfo.$$$reportNull$$$0(MigrateToAppCompatUsageInfo.java)
    at org.jetbrains.android.refactoring.MigrateToAppCompatUsageInfo$GradleUsageInfo.<init>(MigrateToAppCompatUsageInfo.java)
    at org.jetbrains.android.refactoring.MigrateToAppCompatUsageInfo$AddGoogleRepositoryUsageInfo.<init>(MigrateToAppCompatUsageInfo.java:714)
    at org.jetbrains.android.refactoring.MigrateToAndroidxProcessor$findUsagesInBuildFiles$2.invoke(MigrateToAndroidxProcessor.kt:456)
    at org.jetbrains.android.refactoring.MigrateToAndroidxProcessor.findUsagesInBuildFiles(MigrateToAndroidxProcessor.kt:463)
    at org.jetbrains.android.refactoring.MigrateToAndroidxProcessor.findUsages(MigrateToAndroidxProcessor.kt:220)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:959)
    at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
    at com.intellij.refactoring.BaseRefactoringProcessor.lambda$doRun$0(BaseRefactoringProcessor.java:189)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:247)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
    at com.intellij.openapi.progress.impl.CoreProgressManager$5.run(CoreProgressManager.java:434)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$null$10(ApplicationImpl.java:574)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

这些是我的项目级别gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.11'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.27.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.google.com/' }
    }
}

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

这些是我的应用程序级别gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.cinopsys.movieshows"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    def support_version = "28.0.0"
    def room_version = "1.1.1"
    def lifecycle_version = "1.1.1"
    def retrofitVersion = "2.4.0"
    def okhttpLoggingInterceptorVersion = "3.9.1"
    def paging_version = "1.0.1"
    def coroutines_version = "1.1.0"
    def firebase_version = "16.0.6"
    def crashlytics_version = "2.9.8"
    def fcm_version = "17.3.4"
    def glide_version = "4.8.0"
    def versions_work = "1.0.0-beta03"


    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "com.android.support:appcompat-v7:$support_version"
    implementation "com.android.support:support-v4:$support_version"
    implementation "com.android.support:support-media-compat:$support_version"
    implementation "com.android.support:design:$support_version"
    implementation "com.android.support:cardview-v7:$support_version"
    implementation "com.android.support:recyclerview-v7:$support_version"
    implementation "com.android.support:preference-v7:$support_version"
    implementation "com.android.support:preference-v14:$support_version"
    implementation "com.github.bumptech.glide:glide:$glide_version"
    implementation "com.google.firebase:firebase-messaging:$fcm_version"
    implementation 'com.android.support:support-v4:28.0.0'
    kapt "com.github.bumptech.glide:compiler:$glide_version"

    //Expandable TextView
    implementation 'com.ms-square:expandableTextView:0.1.4'

    //Work Manager
    implementation "android.arch.work:work-runtime:$versions_work"

    //Paging
    implementation "android.arch.paging:runtime:$paging_version"

    //Room
    implementation "android.arch.persistence.room:runtime:$room_version"
    kapt "android.arch.persistence.room:compiler:$room_version"

    //ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"
    kapt "android.arch.lifecycle:compiler:$lifecycle_version"

    //firebase
    implementation "com.google.firebase:firebase-core:$firebase_version"
    implementation "com.crashlytics.sdk.android:crashlytics:$crashlytics_version"

    // retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation "com.squareup.retrofit2:retrofit-mock:$retrofitVersion"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttpLoggingInterceptorVersion"

    //kotlin coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"


    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'

最佳答案

这是一个已知问题,记录在这里:https://issuetracker.google.com/issues/123303598

一种替代方法是使用和修改此脚本,然后手动进行转换:https://gist.github.com/dlew/5db1b780896bbc6f542e7c00a11db6a0

07-27 20:56