从Java迁移到Kotlin

时间:2017-09-13 08:53:14

标签: java android kotlin

我有一个用Java编写的Android应用程序,但我想将其转换为Kotlin。我添加了Kotlin插件并配置了应用程序的gradle。

buildscript {
    ext.kotlin_version = '1.1.4-3'
dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}


apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

我正在使用 - code - >将单个文件从Java转换为Kotlin。将java文件转换为kotlin

转换后我收到此错误:

Process: com.stockal.app, PID: 10633

java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzac; or its super classes (declaration of 'com.google.android.gms.common.internal.zzac' appears in /data/app/com.stockal.app-1/base.apk:classes75.dex)
    at com.google.firebase.provider.FirebaseInitProvider.zza(Unknown Source)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
    at android.app.ActivityThread.installProvider(ActivityThread.java:5461)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5032)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4972)
    at android.app.ActivityThread.-wrap1(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1555)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5776)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

0 个答案:

没有答案