Error ‘:app:compileDebugKotlin’ java.lang.reflect.InvocationTargetException after migrating to Androidx

  android, android-studio, gradle, kapt, kotlin

After I migrate my project there some error like data binding and more, but I already solve it then the error change into this :

Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)

I’ve try many solution like updating kotlin version to 1.4.20 and also some source ask me to upgrade the room version so I update it to the latest version but it all turns out failed.

here is my gradle module :

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'

android {

compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
    applicationId "my package"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode 1
    versionName "1.18"
    testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

dexOptions {
    javaMaxHeapSize "4g"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}
packagingOptions {
    exclude 'META-INF/rxjava.properties'
}

buildFeatures {
    dataBinding = true
}

}

 dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core:1.3.2'
implementation 'com.jakewharton:butterknife:10.2.3'
kapt 'com.jakewharton:butterknife-compiler:10.2.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'

implementation 'jp.wasabeef:blurry:2.1.1'
implementation 'jp.wasabeef:fresco-processors:2.1.0'

implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.github.IntruderShanky:Sectioned-RecyclerView:2.1.1'
implementation 'id.zelory:compressor:2.1.0'


implementation 'com.github.rey5137:material:1.2.2'
implementation 'com.squareup.picasso:picasso:2.5.2'

implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata:2.2.0'

kapt 'androidx.lifecycle:lifecycle-compiler:2.2.0'
def room_version = "2.2.6"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
testImplementation "androidx.room:room-testing:$room_version"

implementation files('libs/jxl.jar')
implementation 'com.github.myinnos:AlphabetIndex-Fast-Scroll-RecyclerView:1.0.8'
implementation 'com.github.bumptech.glide:glide:3.8.0'

implementation 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.9'
implementation "com.prolificinteractive:material-calendarview:1.4.3"
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.github.AnyChart:AnyChart-Android:0.0.3'
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'io.reactivex:rxandroid:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.itextpdf:itext7-core:7.1.7'
implementation 'com.rmtheis:tess-two:6.0.4'
implementation files('libs/google-api-translate-java-0.98-mod2.jar')
implementation files('libs/json_simple-1.1.jar')
implementation files('libs/jtar-1.0.4.jar')
implementation files('libs/microsoft-translator-java-api-0.6-mod.jar')
implementation 'com.stepstone.stepper:material-stepper:4.3.1'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.kyanogen.signatureview:signature-view:1.0'
implementation("com.microblink:blinkid:[email protected]") {
    transitive = true
}
implementation 'com.itextpdf:itext7-core:7.1.7'
implementation deps.kotlin
implementation deps.android.support.appcompat
implementation deps.android.support.constraintlayout
implementation 'com.github.yeriomin:play-store-api:0.19'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'org.jsoup:jsoup:1.11.1'
implementation 'com.google.android.play:core:1.9.0'//for new version updater
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
implementation 'com.github.jakebonk:NotifyMe:1.0.1'
implementation 'com.szagurskii:patternedtextwatcher:0.5.0'
implementation 'com.schibstedspain.android:leku:5.0.0'
testImplementation deps.test.junit
androidTestImplementation deps.test.runner
androidTestImplementation deps.test.espresso

}
repositories {
mavenCentral()
}

configurations.all {
resolutionStrategy {
    force("org.antlr:antlr4-runtime:4.5.3")
    force("org.antlr:antlr4-tool:4.5.3")
}
}

and this is my gradle project :

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:4.1.2'
    classpath 'com.google.gms:google-services:4.3.4'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
    classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
 }

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

}
}

ext {
  supportlib_version = '27.1.1'
  appcompat_version = supportlib_version
  design_version = supportlib_version
  constraintlayout_version = '1.1.0'
  junit_version = '4.12'
  testrunner_version = '1.0.2'
  espresso_version = '3.0.2'
}

 ext.deps = [
    'kotlin' : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72",
    'android': [
            'support': [
                    'core'            : "com.android.support:support-v4:$supportlib_version",
                    'appcompat'       : 'androidx.appcompat:appcompat:1.0.0',
                    'constraintlayout': 'androidx.constraintlayout:constraintlayout:1.1.3',
                    'design'          : "com.android.support:design:$design_version"
            ]
    ],
    'test'   : [
            'junit'   : "junit:junit:$junit_version",
            'runner'  : 'androidx.test.ext:junit:1.1.1',
            'espresso': 'androidx.test.espresso:espresso-core:3.1.0'
    ]
  ]

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

 project.ext {
    blinkIdVersion = '5.9.0'
    compileSdkVersion = 28
    targetSdkVersion = 28
    buildToolsVersion = '28.0.3'
    appCompatVersion = '28.0.0'
 }

Source: Android Questions

One Reply to “Error ‘:app:compileDebugKotlin’ java.lang.reflect.InvocationTargetException after migrating to Androidx”

LEAVE A COMMENT