简体   繁体   中英

Android Annotation with Kotlin

I can't run Android Annotation with Kotlin Android Project. When i try run my application with link to MainActivity_, my app is crashed. But i mark Activity class with @EActivity

Unable to instantiate activity ComponentInfo{ru.lionzxy.jetbrainsintership/ru.lionzxy.jetbrainsintership.MainActivity_}

I try add

kapt {
    generateStubs = true
    arguments {
        arg("androidManifestFile", variant.outputs[0].processResourcesTask.manifestFile)
    }
}

and

kapt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"

in my build.gradle file. Clean and build. And get this error:

Error:Execution failed for task ':app:kaptDebugKotlin'.

Compilation error. See log for more details

My log file in /app/build/outputs/logs/manifest-merger-debug-report.txt: https://gist.github.com/LionZXY/bf398a3b64f787a56d985a5a0ea03bfe

I don't understand why it not work. My full build.gradle: https://gist.github.com/LionZXY/4e672579fe89ad22cea07d2fe15a1621

Annotations are means of attaching metadata to code. Annotations are supported in Kotlin with kapt plugin.Please ensure kotlin latest version 1.3 +

You can apply plugin syntax in module-level build file as follows

apply plugin: 'kotlin-kapt'

Then you can add dependency

dependencies {
...
implementation 'androidx.room:room-runtime:2.1.0-alpha04'
kapt 'androidx.room:room-compiler:2.1.0-alpha04'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM