2017-09-26 15 views
-2

JavaベースのマルチキシプロジェクトをKotlinに移行しようとしましたが、アプリケーションがKotlinクラスを参照しようとするたびにClassNotFoundExceptionが発生します。変わったことは、同じコードがときどき動作することがあることです。働くAPKを生産するコンピューターや他のコンピューターは生産しないコンピューターがあります。問題を解決するには再構築が必要な場合もあります。Kotlinクラスを参照するときにClassNotFoundExceptionが発生する

私はGoogleに試みましたが、私はthisスレッドしか見つかりませんでしたが、解決はありません。このことは、他の人にとっては適切に機能するのですか、それともまだマルチレックスされたKotlinプロジェクトはありませんか?

私は、AS 2.3.3およびAS 3.0.0-beta6,2.3.3アンドロイドプラグイン、kotoinバージョン1.1.50、、proguardなしで試しました。

buildscript { 

    ext.kotlin_version = '1.1.50' 
    ext.android_plugin_version = '2.3.3' 
    ext.support_lib_version = '25.3.1' 
    ext.play_services_version = '11.0.4' 

    repositories { 
     jcenter() 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
    dependencies { 
     classpath "com.android.tools.build:gradle:$android_plugin_version" 
     classpath 'me.tatarka:gradle-retrolambda:3.2.5' 
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 
     classpath 'com.google.gms:google-services:3.0.0' 
     classpath 'com.google.firebase:firebase-plugins:1.1.1' 
    } 
} 

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



apply plugin: "com.android.application" 
apply plugin: "me.tatarka.retrolambda" 
apply plugin: 'kotlin-android' 
apply plugin: 'kotlin-android-extensions' 
apply plugin: "com.google.firebase.firebase-perf" 

repositories { 
    mavenCentral() 
    jcenter() 
    maven { 
     url "https://jitpack.io" 
    } 
} 

android { 
    signingConfigs { 
     debug { 
      ... 
     } 
    } 

    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "com.my.app" 
     signingConfig signingConfigs.debug 
     minSdkVersion 14 
     targetSdkVersion 25 
     versionCode 13 
     versionName "2.0.1.b8face5" 
     vectorDrawables.useSupportLibrary = true 
     multiDexEnabled true 
     testInstrumentationRunner "com.my.app.TestRunner" 

    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    //this is because instabug uses rxjava 1 and now we have both 1 and 2 on the classpath 
    packagingOptions { 
     exclude "META-INF/rxjava.properties" 
    } 


    buildTypes { 
     debug { 
      applicationIdSuffix ".debug" 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     release { 

     } 
    } 
} 

dependencies { 
    compile fileTree(include: "*.jar", dir: "libs") 
    // Force usage of support annotations in the test app, since it is internally used by the runner module. 
    androidTestCompile("com.android.support.test.espresso:espresso-core:2.2.1") { 
     exclude module: "support-annotations" 
    } 
    androidTestCompile("com.android.support.test.espresso:espresso-contrib:2.2.1") { 
     // Necessary to avoid version conflicts 
     exclude group: "com.android.support", module: "appcompat" 
     exclude group: "com.android.support", module: "support-v4" 
     exclude group: "com.android.support", module: "support-annotations" 
     exclude module: "recyclerview-v7" 
    } 
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 
    compile "com.android.support:appcompat-v7:$support_lib_version" 
    compile "com.android.support:recyclerview-v7:$support_lib_version" 
    compile "com.android.support:design:$support_lib_version" 
    compile "com.android.support:cardview-v7:$support_lib_version" 
    compile "com.google.android.gms:play-services-auth:$play_services_version" 
    compile "com.google.android.gms:play-services-identity:$play_services_version" 
    compile "com.google.android.gms:play-services-location:$play_services_version" 
    compile "com.google.android.gms:play-services-maps:$play_services_version" 
    compile "com.google.firebase:firebase-core:$play_services_version" 
    compile "com.google.firebase:firebase-crash:$play_services_version" 
    compile "com.google.firebase:firebase-perf:$play_services_version" 

    compile "com.google.code.gson:gson:2.8.1" 
    compile "com.google.maps.android:android-maps-utils:0.4" 
    compile "com.squareup.retrofit2:retrofit:2.3.0" 
    compile "com.squareup.retrofit2:converter-gson:2.3.0" 
    compile "com.squareup.retrofit2:adapter-rxjava2:2.3.0" 
    compile "io.reactivex.rxjava2:rxandroid:2.0.1" 
    compile "io.reactivex.rxjava2:rxjava:2.1.3" 
    compile "com.squareup.okhttp3:okhttp-urlconnection:3.8.1" 
    compile "com.facebook.stetho:stetho:1.5.0" 
    compile "com.facebook.stetho:stetho-okhttp3:1.5.0" 
    compile "com.squareup.picasso:picasso:2.5.2" 
    compile "com.jakewharton:butterknife:8.2.1" 
    compile "com.annimon:stream:1.1.8" 
    compile "com.github.lawloretienne:quickreturn:0.0.1" 
    compile "com.github.chrisbanes:PhotoView:1.2.6" 
    compile "fr.baloomba:viewpagerindicator:2.4.2" 
    compile "com.github.bluejamesbond:textjustify-android:2.1.6" 
    compile "com.turingtechnologies.materialscrollbar:lib:10.1.4" 
    compile "com.github.PhilJay:MPAndroidChart:v3.0.1" 
    compile "com.android.support:multidex:1.0.1" 
    compile "com.bugsnag:bugsnag-android:3.9.0" 
    //TODO check periodically whether they upgraded to rxjava 2 
    compile "com.instabug.library:instabug:4.2.11" 

    testCompile "junit:junit:4.12" 
    androidTestCompile "com.android.support:support-annotations:$support_lib_version" 
    androidTestCompile "com.android.support.test:runner:0.5" 
    androidTestCompile "com.android.support.test:rules:0.5" 
    annotationProcessor "com.jakewharton:butterknife-compiler:8.2.1" 
    compile "com.google.dagger:dagger:2.5" 
    annotationProcessor "com.google.dagger:dagger-compiler:2.5" 
    provided "javax.annotation:jsr250-api:1.0" 
} 


apply plugin: "com.google.gms.google-services" 
+0

詳細情報が必要です。クラス 'ClassNotFoundException'が発生していますか? – Krish

+0

すべてのクラスがKotlinに変換されました。クラッシュは、そのようなクラスが参照されたときに初めて発生します。たとえば、SplashActivityを変換すると、アプリケーションを起動することさえできません。 – guni

答えて

0

最後に問題を解決できました。例外はRetroLambdaのバグが原因で、3.7.0に更新した後、ありがたいことに消えました。グラデルクリーンですべてを削除していないようだからビルドは非決定論的でした。私は手動でアプリケーションとルートモジュールの両方のビルドフォルダを削除した後、結果は確定的になりました。

0

Java 8を使用している場合は、Kotlin jre8も使用する必要があります。

compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" 
+0

良い見通しですが、コンパイルされません。私はorg.jetbrains.kotlin:kotlin-stdlibで試しましたが、結果はjre7と同じです。 – guni

関連する問題