Closed asfdfdfd closed 7 years ago
Я правильно понимаю, что у вас уже очень много на мокси написано? И эта проблема только появилась? А что изменилось? У меня проблема не воспроизводится. Так же стоит заметить, что можно увидеть, что Android Studio может спокойно пронавигироваться в сгенерированный код.
Вы пробовали запустить сэмпл? С ним такая же проблема?
PS: вообще уже есть таска #122 -- похоже это и ваш случай.
Я правильно понимаю, что у вас уже очень много на мокси написано
Я думаю десятка два презентеров примерно.
И эта проблема только появилась? А что изменилось?
Да. Она появилась когда обновил kotlin с 1.1.2 на 1.1.3 и везде поставил kapt вместо annotationProcessor.
Вы пробовали запустить сэмпл?
Нет, не пробовал. Имеется в виду этот https://github.com/Arello-Mobile/Moxy/tree/master/sample-kotlin ?
Проверил на этом примере https://github.com/Arello-Mobile/Moxy/tree/master/sample-kotlin
На нём подобное поведение воспроизвести не получается.
А если вернуть annotationProcessor вместо kapt?
С annotationProcessor без kapt семпл собирается нормально.
Не обратил внимание. Собирается нормально, но при тапе по активити:
07-19 14:00:27.356 2757 2757 D AndroidRuntime: Shutting down VM
07-19 14:00:27.357 2757 2757 E AndroidRuntime: FATAL EXCEPTION: main
07-19 14:00:27.357 2757 2757 E AndroidRuntime: Process: com.arellomobile.mvp.sample.kotlin, PID: 2757
07-19 14:00:27.357 2757 2757 E AndroidRuntime: kotlin.UninitializedPropertyAccessException: lateinit property dialogPresenter has not been initialized
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at com.arellomobile.mvp.sample.kotlin.MainActivity.getDialogPresenter(MainActivity.kt:15)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at com.arellomobile.mvp.sample.kotlin.MainActivity$onCreate$1.onClick(MainActivity.kt:38)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at android.view.View.performClick(View.java:5204)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at android.view.View$PerformClick.run(View.java:21153)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
07-19 14:00:27.357 2757 2757 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Да. Она появилась когда обновил kotlin с 1.1.2 на 1.1.3 и везде поставил kapt вместо annotationProcessor.
А если в вашем проекте обратно вернусть с kapt на annotationProcessor?
Я здесь выразился не совсем точно. Вот такое у меня изменение было при повышении версии kotlin в моём проекте:
compile 'com.arello-mobile:moxy:1.5.3'
- annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.3'
compile 'com.arello-mobile:moxy-android:1.5.3'
compile 'com.arello-mobile:moxy-app-compat:1.5.3'
kapt 'com.arello-mobile:moxy-compiler:1.5.3'
То есть был и kapt и annotationProcessor (который я и убрал). При включенном annotationProcessor kotlin ругался на что-то там FunctionReference.
Сейчас я вернул annotationProcessor обратно и пока всё работает. Немного понаблюдаю и напишу сюда о результатах.
Всё ещё работает без каких либо отклонений.
@asfdfdfd how you solved it? i have the build gradle like your post above but everything i change still need a clean before making project =(
@defaultbr i've returned 'annotationProcessor' line to the build.gradle. Let me show you my (cleaned from sensitive information) gradle files, probably it will help you.
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'com.github.ben-manes.versions' version '0.15.0'
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
mavenCentral()
flatDir { dirs '../libs' }
}
def propertiesFileVersion = rootProject.file('version.properties')
def propertiesVersion = new Properties();
propertiesVersion.load(new FileInputStream(propertiesFileVersion));
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.mytestapp.test"
minSdkVersion 16
targetSdkVersion 25
multiDexEnabled true
versionCode propertiesVersion['versionCode'] as Integer
versionName propertiesVersion['versionName']
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
if (!project.hasProperty("opencv.dir")) {
throw new InvalidUserDataException("Please set OpenCV Android SDK path to the 'opencv.dir' property.");
}
arguments "-DOpenCV_DIR=" + project.property("opencv.dir") + "/sdk/native/jni"
cppFlags "-frtti -fexceptions"
}
}
}
productFlavors {
development {
minSdkVersion 16
applicationIdSuffix ".development"
}
production {
minSdkVersion 16
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Force JSR305 version to resolve dependency conflict between Stetho and Dagger.
compile 'com.google.code.findbugs:jsr305:3.0.2'
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.2'
ext.com_google_android_gms_version = '11.0.4'
compile "com.google.android.gms:play-services-auth:$com_google_android_gms_version"
compile "com.google.android.gms:play-services-auth-api-phone:$com_google_android_gms_version"
compile "com.google.android.gms:play-services-vision:$com_google_android_gms_version"
compile "com.google.firebase:firebase-core:$com_google_android_gms_version"
compile "com.google.firebase:firebase-messaging:$com_google_android_gms_version"
//noinspection GradleCompatible
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
ext.com_android_support_version = '25.3.1'
compile "com.android.support:appcompat-v7:$com_android_support_version"
compile "com.android.support:recyclerview-v7:$com_android_support_version"
compile "com.android.support:design:$com_android_support_version"
compile "com.android.support:exifinterface:$com_android_support_version"
compile "com.android.support:preference-v7:$com_android_support_version"
compile "com.android.support:cardview-v7:$com_android_support_version"
compile "com.android.support:customtabs:$com_android_support_version"
testCompile 'junit:junit:4.12'
compile 'io.branch.sdk.android:library:2.10.3'
ext.com_facebook_android_version = '4.25.0'
compile "com.facebook.android:facebook-android-sdk:$com_facebook_android_version"
compile "com.facebook.android:account-kit-sdk:$com_facebook_android_version"
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.facebook.stetho:stetho-okhttp3:1.5.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxkotlin:2.1.0'
compile 'com.jakewharton.threetenabp:threetenabp:1.0.5'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'net.ypresto.timbertreeutils:timbertreeutils:1.0.0'
compile 'com.google.dagger:dagger:2.11'
compile 'com.google.dagger:dagger-android:2.11'
compile 'com.google.dagger:dagger-android-support:2.11'
kapt 'com.google.dagger:dagger-compiler:2.11'
kapt 'com.google.dagger:dagger-android-processor:2.11'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'com.squareup.retrofit2:converter-jackson:2.3.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.0'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'commons-io:commons-io:2.5'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.arello-mobile:moxy:1.5.3'
annotationProcessor 'com.arello-mobile:moxy-compiler:1.5.3'
compile 'com.arello-mobile:moxy-android:1.5.3'
compile 'com.arello-mobile:moxy-app-compat:1.5.3'
kapt 'com.arello-mobile:moxy-compiler:1.5.3'
compile 'me.zhanghai.android.materialprogressbar:library:1.4.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile(name:'lokalise-sdk', ext:'aar')
compile 'com.google.code.gson:gson:2.8.1'
compile 'com.amplitude:android-sdk:2.14.1'
compile 'com.appsflyer:af-android-sdk:4.7.4@aar'
compile 'com.github.hotchemi:android-rate:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
almost equals, except the CMake things and some dependencies (i've added annotationProcessor too)
and almost every line i change at presenter, i must do a Clean before running =(
Could you try to reproduse this throble with moxy-kotlin example? Then I will be able to try to self reproduce this and then I will contact with kapt-team.
May be it happens only within specific enviroment.
@asfdfdfd @defaultbr could you try to remove apply plugin: 'kotlin-kapt'
? Just for test -- may be it's will help =)
@senneco
As result program compiled and started but does not work.
@senneco i've removed it too, but doesnt work coz Kotlin and other dependencies need kapt (dagger for ex)
Аналогичная проблема, наблюдается каждый раз когда во вью или в презентере появляются новые методы. На тестовом сэмпле воспроизвел проблему так:
sample-kotlin\build.gradle
...
ext.kotlin_version = '1.1.4-2'
...
apply plugin: 'kotlin-kapt'
...
compile 'com.arello-mobile:moxy:1.5.3'
compile 'com.arello-mobile:moxy-app-compat:1.5.3'
kapt 'com.arello-mobile:moxy-compiler:1.5.3'
...
Ребята, к сожалению проблема в инкрементальной сборке kapt. Давайте создадим issue в баг трекере и понаставим плюсов. Хотя скорее всего они и сами знают об этой проблеме
There was created related issue: https://discuss.kotlinlang.org/t/kapt-cannot-find-self-generated-class/4771
This is known kapt/gradle issue: https://youtrack.jetbrains.com/issue/KT-20341 . And there is some quick fix:
android {
compileOptions {
incremental = false
}
}
Похоже, что incremental можно включать обратно.
Записал короткое двухминутное видео для иллюстрации проблемы http://take.ms/ovLac
В проекте используется java и kotlin (1.1.3-2)
Кусок build.gradle:
Кусок app/build.gradle: