当前位置:  开发笔记 > 编程语言 > 正文

Android Studio 3.2 Canary 2 Kotlin运行时VerifyError:拒绝类

如何解决《AndroidStudio3.2Canary2Kotlin运行时VerifyError:拒绝类》经验,为你挑选了0个好方法。

嗨我刚刚将Android Studio更新为3.2 canary 2并且我的项目编译正常,但我有一个运行时异常.

这是崩溃:

FATAL EXCEPTION: main
Process: fr.myApp, PID: 12658
java.lang.VerifyError: Rejecting class kotlin.reflect.jvm.internal.KClassImpl that attempts to sub-class erroneous class kotlin.reflect.jvm.internal.KDeclarationContainerImpl (declaration of 'kotlin.reflect.jvm.internal.KClassImpl' appears in /data/app/fr.myApp-2/split_lib_dependencies_apk.apk)
    at kotlin.reflect.jvm.internal.KClassCacheKt.getOrCreateKotlinClass(kClassCache.kt:63)
    at kotlin.reflect.jvm.internal.ReflectionFactoryImpl.getOrCreateKotlinClass(ReflectionFactoryImpl.java:45)
    at kotlin.jvm.internal.Reflection.getOrCreateKotlinClass(Reflection.java:61)
    at fr.myApp.reusable.base.modules.NewBaseActivity.(NewBaseActivity.kt)
    at java.lang.Class.newInstance(Native Method)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1096)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3122)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
    at android.app.ActivityThread.access$1100(ActivityThread.java:229)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:7331)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 Caused by: java.lang.VerifyError: Verifier rejected class kotlin.reflect.jvm.internal.KDeclarationContainerImpl due to bad method java.lang.reflect.Method kotlin.reflect.jvm.internal.KDeclarationContainerImpl.tryGetMethod(java.lang.Class, java.lang.String, java.util.List, java.lang.Class, boolean) (declaration of 'kotlin.reflect.jvm.internal.KDeclarationContainerImpl' appears in /data/app/fr.myApp-2/split_lib_dependencies_apk.apk)
    at kotlin.reflect.jvm.internal.KClassCacheKt.getOrCreateKotlinClass(kClassCache.kt:63) 
    at kotlin.reflect.jvm.internal.ReflectionFactoryImpl.getOrCreateKotlinClass(ReflectionFactoryImpl.java:45) 
    at kotlin.jvm.internal.Reflection.getOrCreateKotlinClass(Reflection.java:61) 
    at fr.myApp.reusable.base.modules.NewBaseActivity.(NewBaseActivity.kt) 
    at java.lang.Class.newInstance(Native Method) 
    at android.app.Instrumentation.newActivity(Instrumentation.java:1096) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3122) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:229) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:7331) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

以前版本的com.android.tools.build:gradle(3.2.0-alpha02)都很好用

这是我的成绩档案:

buildscript {
ext.realm_version = '4.3.4'
ext.kotlin_version = '1.2.21'
ext.kotlinx_coroutines_version = '0.22.2'
ext.android_arch_version = '1.0.0-alpha9-1'
ext.android_support_version = '27.0.2'
ext.retrofit_version = '2.3.0'
ext.moshi_version = '1.5.0'
ext.okhttp_version = '3.8.0'
ext.constraint_layout_version = '1.0.2'
ext.junit_version = '4.12'
ext.espresso_version = '2.2.2'
ext.dagger_version = '2.13'
ext.picasso_version = '2.5.2'
ext.timber_version = '4.6.0'
ext.chuck_version = '1.1.0'
ext.crashlitycs_version = '2.9.0'
ext.easyImage_version = '1.3.1'
ext.gradleBuild_version = '3.2.0-alpha03'

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

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0-alpha03'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "io.realm:realm-gradle-plugin:$realm_version"
    classpath 'io.fabric.tools:gradle:1.+'
    }
}

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

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

并且:

    apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'

kotlin {
    experimental {
        coroutines "enable"
    }
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "fr.myApp"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Kotlin :
    //implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation "org.jetbrains.kotlin:kotlin-reflect"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"

    // Support lib :
    implementation "com.android.support:appcompat-v7:$android_support_version"
    implementation "com.android.support:support-v4:$android_support_version"
    implementation "com.android.support:design:$android_support_version"
    implementation "com.android.support:recyclerview-v7:$android_support_version"
    implementation "com.android.support:cardview-v7:$android_support_version"
    implementation "com.android.support.constraint:constraint-layout:$constraint_layout_version"

    // Data binding :
    //kapt "com.android.databinding:compiler:$gradleBuild_version"

    // Android lifecycle :
    implementation "android.arch.lifecycle:extensions:1.1.0"
    kapt "android.arch.lifecycle:compiler:$android_arch_version"

    // Networking: Retrofit + moshi :
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
    implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
    implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"

    // Image downloading and caching :
    implementation "com.squareup.picasso:picasso:$picasso_version"

    // Dependencies injection: Dagger 2
    implementation "com.google.dagger:dagger:$dagger_version"
    implementation "com.google.dagger:dagger-android:$dagger_version"
    implementation "com.google.dagger:dagger-android-support:$dagger_version"
    kapt "com.google.dagger:dagger-compiler:$dagger_version"
    kapt "com.google.dagger:dagger-android-processor:$dagger_version"

    // Crypto: FB Conceal + SecurePreferences
    implementation 'com.facebook.conceal:conceal:2.0.1@aar'

    // Logging: Crashlytics + Timber + Chuck
    implementation "com.jakewharton.timber:timber:$timber_version"
    implementation("com.crashlytics.sdk.android:crashlytics:$crashlitycs_version@aar") {
        transitive = true
    }
    debugImplementation "com.readystatesoftware.chuck:library:$chuck_version"
    releaseImplementation "com.readystatesoftware.chuck:library-no-op:$chuck_version"

    // Camera
    implementation "com.github.jkwiecien:EasyImage:$easyImage_version"

    // Permissions
    implementation 'com.github.tajchert:nammu:1.2.0'

    testImplementation "junit:junit:$junit_version"
    androidTestImplementation("com.android.support.test.espresso:espresso-core:$espresso_version", {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}

我的职业守卫:

-dontwarn okio.**
-dontwarn javax.annotation.**
-keepclasseswithmembers class * {
    @com.squareup.moshi.* ;
}
-keep @com.squareup.moshi.JsonQualifier interface *
-keepclassmembers class kotlin.Metadata {
    public ;
}
-keepclassmembernames class kotlinx.** {
    volatile ;
}

这是一个插件bug,Kotlin bug,还是我错过了什么?我不想回到以前的版本.

推荐阅读
wangtao
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有