使用 kotlin 和 greendao 的 Android Studio 3.0 Proguard 返回 ClassLookupException

标签 android android-studio gradle kotlin

完整的异常(exception)是:

Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.build.gradle.shrinker.ClassLookupException: Invalid class reference: java/rmi/server/RemoteStub

Error:java.lang.RuntimeException: com.android.build.gradle.shrinker.ClassLookupException: Invalid class reference: java/rmi/server/RemoteStub

Error:com.android.build.gradle.shrinker.ClassLookupException: Invalid class reference: java/rmi/server/RemoteStub

我正在使用 Kotlin 和 GreenDao。

我的毕业典礼:

apply plugin: 'org.greenrobot.greendao'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.xxx.xxx"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 4
        versionName "0.0.0.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        buildTypes.each {
            it.buildConfigField 'String', 'GreenDAODatabaseName', '"App_Database"'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

第二个gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.2-4'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'

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

allprojects {
    repositories {
        jcenter()
    }
}

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

到目前为止,我在应用程序中所做的只是添加一些用 kotlin 编写的 UI 类( fragment 和 Activity )。 greenDAO 存在两个实体。在我添加 kotlin proguard 之前,它可以完美地工作。

最佳答案

GreenDAO 尚不支持 Kotlin(请参阅 this)。

关于使用 kotlin 和 greendao 的 Android Studio 3.0 Proguard 返回 ClassLookupException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44214306/

相关文章:

Android 6 请求权限

java - 如何多次购买 Google Play 产品?

android - 如何将相对布局设置为默认布局

android - 无法在 android studio 的设置菜单中找到 Android SDK

c++ - Gradle 无法仅在 Windows 上找到插件

groovy - 使用Spock : setup( )进行Groovy2.0单元测试

android - 更改 Android Studio 的设备文件资源管理器的默认 'Save as...' 文件夹

android - 用 picasso 调整图像大小

android - 如何在 ListView 中滚动时保存 CheckBox 的状态?

android - ButterKnife 编译错误 : error duplicate class