Situation:
Create the simplest project
Add to the project module as File -> New -> New module "Phone & Tablet Module"
Add the dependency on the module
And get errors:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :testmodule.
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve project :testmodule.
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve project :testmodule.
Unable to resolve dependency for ':app#release/compileClasspath': Could not resolve project :testmodule.
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve project :testmodule.
Below are the project files:
Project:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module: app
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.pawga.test00"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(path: ':testmodule')
}
Module: testmodule
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.pawga.testmodule"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
gradle-wrapper.properties
#Mon Jun 25 22:51:52 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
settings.gradle
include ':app', ':testmodule'
Note:
If the module type is "Android Library" (Point "two" above), then there are no such errors.
For such a simple project, where everything is by default, there should not be such errors. What's wrong?
Try this, replace:
implementation project(':testmodule')
To:
implementation project(path:':testmodule', configuration: 'default')
Go to
File -> Settings -> Build, Execution, Deployment -> Gradle menu.
You will see "Offline work" options. Uncheck it. And it's ok.
It looks like your plugin needs to be changed to apply plugin: 'com.android.library' instead of 'com.android.application'
See this post for more
information. Hope that helps.
Try online mode for gradle. Hope it helps(I had the same problem, so more chances).
##REMOVE THE FOLLOWING FROM THE BUILD GRADLE##
>>implementation 'com.android.support:appcompat-v7:28.+'
>>implementation 'com.android.support.constraint:constraint-layout:1.0.2'
>>androidTestImplementation 'com.android.support.test:runner:1.0.1'
>>androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
>>SEE ATTACHED PICTURE
>>[STUDIO ERRORS][1]
>>[1]: https://i.stack.imgur.com/DY6sz.png
Related
I am totally new to Android and struggling past 2days with my build.
I get the following message
Build failed
Could not find androidx.lifecycle:compiler:2.2.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/androidx/lifecycle/compiler/2.2.0/compiler-2.2.0.pom
- https://jcenter.bintray.com/androidx/lifecycle/compiler/2.2.0/compiler-2.2.0.pom
Required by: project :app
I updated my studio and gradle plugins and versions of dependencies, but none seem to work. I am using Gradle Plugin: 4.0.1 and Gradle: 6.1.1
My project gradle is as follows
buildscript {
repositories {
google()
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And my app gradle is as follows
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xxxx.xxxxxx"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
def room_version = "2.2.0"
def lifecycle_version = "2.2.0"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
// Lifecycles only (without ViewModel or LiveData)
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
// Saved state module for ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
// Annotation processor
annotationProcessor "androidx.lifecycle:compiler:$lifecycle_version"
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
}
In the idea.log i find the line
testKnownPluginVersionProvider - 'gradle' plugin missing from the offline Maven repo, will use default 4.0.1
repeating regularly and the gradle-wrapper properties file is as follows
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Remove the following line if you are using Java 8:
annotationProcessor "androidx.lifecycle:compiler:$lifecycle_version"
migrate my application to android x and gradle 5
the moment that I send to generate the apk or to install gives me this error
Caused by: java.lang.NoClassDefFoundError: com/android/tools/r8/dex/ApplicationReader
Build.graddle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "gortiz.com.goapp"
minSdkVersion 18
targetSdkVersion 28
versionCode 37
versionName '2.0.37'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true;
}
implementation 'androidx.appcompat:appcompat:1.+'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.+'
implementation 'androidx.mediarouter:mediarouter:1.+'
implementation 'androidx.core:core:1.+'
implementation 'androidx.multidex:multidex:2.+'
implementation 'com.google.android.material:material:1.+'
implementation 'commons-io:commons-io:2.5'
implementation 'androidx.constraintlayout:constraintlayout:1.+'
implementation 'androidx.legacy:legacy-support-v4:1.+'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.github.satyan:sugar:1.5'
implementation 'com.squareup.picasso:picasso:2.5.0'
implementation 'me.panavtec:wizard:1.2'
implementation 'com.github.johnkil.print:print:1.2.+'
implementation 'com.github.bmelnychuk:atv:1.2.+'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
testImplementation 'junit:junit:4.12'
implementation 'androidx.recyclerview:recyclerview:1.+'
implementation ('com.google.firebase:firebase-messaging:17.3.4'){
exclude group: 'com.google.firebase', module: 'firebase-iid'
}
implementation 'com.google.android.gms:play-services-maps:17.+'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.7'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.android.gms:play-services-vision:18.+'
implementation 'com.google.firebase:firebase-config:18.+'
implementation 'com.google.firebase:firebase-iid:17.0.2'
implementation 'androidx.annotation:annotation:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
graddle.properties
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
Caused by: java.lang.NoClassDefFoundError: com/android/tools/r8/dex/ApplicationReader
The top level build.gradle seems to be missing a dependency on Android Gradle Plugin. Please add something like this (depending on the version you would like to use):
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
...
}
...
}
If you create an empty project in Android Studio that should all be in place.
I'm making two android apps on a Gradle project and managing dependency licenses with Hierynomus' gradle license plugin.
Then, I executed following commands:
$ ./gradlew downloadLicenses
$ cat ./build/reports/license/dependency-license.json
But the generated license reports are empty.
{"dependencies":[]}
I tried to fix the problem with the documents below:
https://github.com/hierynomus/license-gradle-plugin/issues/81
https://github.com/hierynomus/license-gradle-plugin/issues/103
https://github.com/hierynomus/license-gradle-plugin/issues/137
https://github.com/hierynomus/license-gradle-plugin/issues/174
but I couldn't resolve the problem.
Next, I tried to execute the task with --refresh-dependencies and --rerun-tasks options. Sadly, the problem hadn't fixed.
Those are my build scripts:
// build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.21'
ext.kotlin_coroutine_version = '1.1.1'
repositories {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.12.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "http://dl.bintray.com/jetbrains/spek" }
}
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.github.hierynomus.license'
downloadLicenses {
includeProjectDependencies = true
dependencyConfiguration = 'implementation'
ext.apacheTwo = license('Apache License, Version 2.0', 'https://opensource.org/licenses/Apache-2.0')
ext.bsd = license('BSD License', 'https://opensource.org/licenses/bsd-license')
aliases = [
(apacheTwo): [
'The Apache Software License, Version 2.0',
'Apache 2',
'Apache License Version 2.0',
'Apache License, Version 2.0',
'Apache License 2.0',
license('Apache License', 'https://www.apache.org/licenses/LICENSE-2.0')
],
(bsd): [
'BSD',
license('New BSD License', 'https://opensource.org/licenses/bsd-license')
]
]
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
defaultConfig {
applicationId "xyz.tech-frodo.testFirebaseApp.console"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
lintConfig file("lint.xml")
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-firestore:18.1.0'
implementation 'com.github.kittinunf.fuel:fuel:1.12.0'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlin_coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-annotations:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
// client/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "xyz.tech-frodo.testFirebaseApp.client"
minSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-firestore:18.1.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlin_coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"
implementation 'com.github.kittinunf.fuel:fuel:1.12.0'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.maps:google-maps-services:0.9.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'org.jetbrains.spek:spek-api:1.1.5'
testImplementation 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5'
testImplementation 'org.mockito:mockito-core:+'
testImplementation 'junit:junit:4.12'
testImplementation 'org.junit.platform:junit-platform-runner:1.1.0'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
No doubt I expected dependencies license reports of my project were generated under ${PROJECT_ROOT}/build/reports/license/. I found the reports are generated, however, those were empty.
Thanks!
It seems to be a problem with version 0.15.0 Fix getting licenses on Android.
For me, it worked with version 0.14.0 and some additional configurations:
// buil.gradle root
plugins {
id "com.github.hierynomus.license" version "0.14.0"
}
downloadLicenses {
dependencyConfiguration = 'implementation'
includeProjectDependencies = true
}
// build.gradle app
apply plugin: 'com.github.hierynomus.license'
configurations.implementation.setCanBeResolved(true)
configurations.api.setCanBeResolved(true)
Say I have a project, ProjectA, containing ClassInProjectA which I build into an .aar.
I also have a project, ProjectB, which uses ClassInProjectA internally.
public class ClassInProjectB {
public ClassInProjectB() {
new ClassInProjectA();
}
}
The build.gradle of ProjectB is as follows:
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation(name:'projA', ext:'aar')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I use implementation because ClassInProjectA is used only internally by ProjectB.
I then have a main app and wish to use ClassInProjectB.
The main app's build.gradle is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.project.projectc"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation(name:'projB', ext:'aar')
implementation(name:'projA', ext:'aar')
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
projB needs to be imported explicitly or I am unable to construct ClassInProjectB, due to the requirement for ClassInProjectA.
All is well, all compiles and ClassInProjectB can be constructed.
If the build.gradle of ProjectB is changed such that projA is an api requirement:
api(name:'projA', ext:'aar')
nothing changes in the build.gradle of the main app.
What is the advantage of the implementation keyword in this context? Is it purely that it allows me to replace ProjectB in the main app and avoid triggering a recompilation of Project A?
I'm also a little confused by this post, and this one, each of which imply that the main project shouldn't actually need to implicitly import ProjectA at all if ProjectB depends on ProjectA via the api keyword. Have I misunderstood something? edit: this would seem to be the case only if the dependencies are via submodules in the same project rather than exported .aar.
What is the advantage of the implementation keyword in this context? Is it purely that it allows me to replace ProjectB in the main app and avoid triggering a recompilation of Project A?
The only advantage of the implementation keyword, and indeed the reason why it was introduced, is that it can avoid full project rebuilds. This blogpost does a great job at explaining the details. To summarize, if :projectA has an implementation dependency on :projectB, then :projectA only needs to be recompiled if the interface of :projectB changes.
i use android studio 3.0 and some old java class Convert Java to Kotlin. after that Kotlin class cant import in java class!
in below you can see my gradle and a picture of my error.
module build.grade
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
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
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
in app level build.gradle in normally i use gradle code and in android 3.0 i think we need any thing
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.idehnavazan.beautifierclient"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.github.rey5137:material:1.2.2'
compile 'com.android.support:cardview-v7:25.3.1'
}
apply plugin: 'com.google.gms.google-services'
To work with Kotlin files you need to add Kotlin to your project.
project/build.gradle
buildscript {
ext.kotlinVersion = '1.1.51'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
project/module/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}
What's next
Since you're using support library 25.3.1 and Android plugin 3.0.0 your next question will probably be this: style attribute '#android:attr/windowEnterAnimation' not found.
I have added all kotlin classes in separate folder and it work for me!
Keep your java classes separate from kotlin. I was having
app:compileDebugJavaWithJavac Kotlin class calling from java: error: cannot find symbol
compile time error.
My issue was that I have imported a submodule using
testImplementation instead of implementation inside of module gradle file that is declaring your module as a dependency.
Changing the dependency declaration fixed it for me.
I am also new to kotlin/android and was using ViewBinding. I was renaming an xml-file when this type of error occured. I just added:
dataBinding {
enabled = true
}
to the build.gradle(module)-file and it now works. To be honest, I never understood the difference between view- and data-binding
kotlin/android and was using ViewBinding.
just add this inside build.gradle(module)-file
viewBinding{
enabled = true
}