The plugins mentioned below are there in the gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
the following dependency is also added in the same
implementation 'androidx.recyclerview:recyclerview:1.1.0'
Added this one as well;
implementation 'com.android.support:recyclerview-v7:25.3.1'
the error is appearing when I am writing recyclerView in the OnCreate Funtionenter image description here
Could you please suggest, how the error can be resolved.
do check the apt version of rein the
app-> project structure-> dependencies-> + symbol -> library dependencies
try it
Related
This is my setup:
AndroidStudio Lombok Plugin is installed
Enable Annotation Processing is checked in AndroidStudio Settings
Gradle wrapper is using version 4.6
I am using kotlin version 1.2.71
I am using com.android.tools.build:gradle:3.2.1
I tried "Invalidate cache / Restart AndroidStudio" after each change
Lombok dependencies are defined like this:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
dependencies {
compileOnly "org.projectlombok:lombok:1.18.2"
kapt "org.projectlombok:lombok:1.18.2"
}
When I build the app, I get the followin error:
Annotation processors must be explicitly declared now.
The following dependencies on the compile classpath are found to
contain annotation processor.
Please add them to the annotationProcessor configuration.
- lombok-1.18.2.jar (org.projectlombok:lombok:1.18.2)
I also tried this dependency setup:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
dependencies {
compileOnly "org.projectlombok:lombok:1.18.2"
annotationProcessor "org.projectlombok:lombok:1.18.2"
}
But then I get "cannot find symbol"-errors all over the place, because no getters/setters are generated by lombok.
Annotation processors must be explicitly declared now. The following
dependencies on the compile classpath are found to contain annotation
processor.
Please add them to the annotationProcessor configuration.
- lombok-1.18.2.jar (org.projectlombok:lombok:1.18.2)
Try adding it as annotationProcessor:
annotationProcessor 'org.projectlombok:lombok:1.18.2'
However, read this: Is it possible to use Lombok with Kotlin?
Lombok does not run on your source code, but on the AST. Anyway, it is
an annotation processor that is run at compile-time by the Java
compiler. The Kotlin compiler does not use these annotation
processors. See also the answer
https://stackoverflow.com/a/35530223/2621917 straight from the horse’s
mouth.
I have problems when i import a kotlin class from another module, but there is no problem with Java class . I configed kotlin in my project. Below is my 'data' module library, and i want to import Kotlin classes from 'domain' module.
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
...
dependencies {
...
implementation project(':domain')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71'
...
}
When I build the project, it´s giving me lot of error messages 'Unresolved reference: ...' . But the IDE itself doesn´t have a problem. The errors will disappear if i remove all kotlin importing and their object.
Thank you!
I missed something in 'domain' library
Here is my resolve : (add these code in 'domain' library )
// thieu 2 cai lol ni se bi loi ko the import kotlin file
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
For me I am adding:
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
to the module. And after that it works.
I have problems referencing my android library modules in my projects. Beside the main app module I use to have an android library module with either util stuff or as data module. I reference it in app module like that:
dependencies {
implementation project(":data")
}
When I build the project, it´s giving me lot of error messages 'Unresolved reference: ...' for all stuff that I reference in the app module to the android library module. But the IDE itself doesn´t have a problem, Intelligent finds all classes, interfaces etc., imports are fine, nothing is red. The android library module itself builds and creates aar-file in the output. It´s the compileDebugKotlin task that fails
Any general idea what may be related to that?
Found the problem, my android library module was missing the kotlin configuration:
apply plugin: 'kotlin-android'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion:<version>"
}
Although I used kotlin .kt files in it, it could build without and also
Tools -> Kotlin -> 'Configure Kotlin in projects'
had told me 'All modules with Kotlin files are configured'
Your module's build.gradle file should have:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
dependencies {
...
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
...
}
In my case It was apply plugin: 'kotlin-android',
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
and also added it on build.gradle
androidExtensions {
experimental = true
}
If it is a kotlin module make sure to add in its build.gradle file
apply plugin: 'kotlin'
I was using CoroutineWorkers and in my case I had to add work-runtime-ktx dependency to use it
implementation "androidx.work:work-runtime-ktx:2.4.0"
I want to use Realm with Kotlin using this Kotlin Realm Extention library. I have added mavenCentral() repository and compile "com.github.vicpinm:krealmextensions:1.2.0" to app.gradle.
When I run my app, I got this error:
java.lang.IllegalArgumentException: Feature is not part of the schema for this Realm. Did you added realm-android plugin in your build.gradle
I have tried to add apply: realm-android in app.gradle but it's not working (beside I think it should have been called from inside the library). I also add Realm.init(baseContext) in my Activity since the query action requires it.
Your plugin order needs to be
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
I am migrating a big project that contains more than 5 dependency libraries from Eclipse to Android Studio.
I ain't able to run compile
'com.google.android.gms:play-services:8.3.0' if I put
com.android.library but able to run by setting it to
com.andriod.application.
Please Help
here is the screenshot
Your gradle file starts like so:
apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
and in "dependencies" you place your dependency:
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}