I have created Android library as Android Studio module. Added as dependency to my root module. While coding I can import any class from library package but while I\'m tryin
For Android Studio 2.2.2
Yes, in library module, it can't use the apply plugin: com.android.application
statement in the module definition, yes, use apply plugin: com.android.library
instead. (still in lib module)
But then you have to do the following:
Also while naming your lib module avoid capitals.
The answer above is somewhat lacking If you project java add in Kotlin getting get this error
Project build.gradle add
ext.kotlin_version = ‘1.3.21’
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Apps build.gradle
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Referance : https://medium.com/mindorks/enabling-kotlin-support-for-a-current-only-java-android-project-98c75e04384a
If you have a library module, it can't use the apply plugin: 'com.android.application'
statement in the module definition, or the build will silently fail as you're seeing. use apply plugin: 'com.android.library'
instead.
A bug has been filed to request that the build system fail loudly instead of silently when this happens: https://code.google.com/p/android/issues/detail?id=76725
In build-gradle app, add this row:
implementation project(":your_name_library_here")
If you are facing this issue while using Kotlin and have
kotlin.incremental=true
kapt.incremental.apt=true
in the gradle.properties, then you need to remove this temporarily to fix the build.
After the successful build, you can again add these properties to speed up the build time while using Kotlin.
Reference: https://stackoverflow.com/a/58951797/3948854