0

Android Studio 3.4.2

build.gradle:

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

in app/build.gradle:

    def AAVersion = '4.6.0'
def KOTLIN_COROUTINE_VERSION = '1.2.1'

    dependencies {
        annotationProcessor "org.androidannotations:androidannotations:$AAVersion"

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

        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') { transitive = true; }
        implementation 'com.google.android.material:material:1.1.0-alpha07'
        implementation 'com.google.code.gson:gson:2.8.5'
        implementation "org.androidannotations:androidannotations-api:$AAVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$KOTLIN_COROUTINE_VERSION"
        implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINE_VERSION"

    }

I has activity (java class) annotate by org.androidannotations.annotations.EActivity

Here snippet:

import android.app.Activity;
import android.os.Bundle;
import org.androidannotations.annotations.EActivity

@EActivity
public class LoginActivity extends Activity {

}

And another java activity (SplashActivity.java) that call this LoginActivity like this:

import android.app.Activity;
import android.os.Bundle;
import org.androidannotations.annotations.EActivity

@EActivity
public class SplashActivity extends Activity {


Intent intent = new Intent(thisActivity, LoginActivity_.class);
startActivity(intent);

Nice it's work fine.

Now I migrate only LoginActivity to Kotlin class (LoginActivity.kt)

like this:

import org.androidannotations.annotations.Background
import org.androidannotations.annotations.EActivity

@EActivity
open class LoginActivity : Activity() {

}

and now SplashActivity.java has compile error in this line:

Intent intent = new Intent(thisActivity, LoginActivity_.class);

error message:

Cannot resolve symbol 'LoginActivity_'

P.S. If I remove "_" than compile success:

Intent intent = new Intent(thisActivity, LoginActivity.class);

But I need to use LoginActivity_

6
  • should it have or have not that "_" symbol after the name. LoginActivity or LoginActivity_ Commented Jul 12, 2019 at 14:03
  • @coroutineDispatcher I update my post Commented Jul 12, 2019 at 14:05
  • then rename it to LoginActivity_ where is the problem Commented Jul 12, 2019 at 14:06
  • @coroutineDispatcher Class "LoginActivity_" is generate class. It's generate by annotation lib Commented Jul 12, 2019 at 14:09
  • you should call the LoginActivity_ after you perform build. And how can you be sure if that's generated. Is that a library or is that a personal library you are developing Commented Jul 12, 2019 at 14:12

1 Answer 1

1

You have to use kapt instead of annotationProcessor to handle Kotlin files. Any annotation processor may or may not correctly handle them; for androidannotations in particular there is documentation on Kotlin support.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.