I've an Android app in Android Studio. I'm using Gradle Version = 4.6, Android Tools Plugin Version=3.2.1. It has a app module (main) and a library module. And I hope all buildTypes depend on the same configuration.
my build.gradle(app):
dependencies {
api project(path: ':lib', configuration: 'custom')
}
But it is ERROR:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :lib.
Try to replace your code like below
implementation project('path: ':lib', configuration: 'custom'')
Related
I am migrating my Android project to Gradle 4.4 and Android Gradle plugin 3.1.2.
It has a library module which depends on parceler library and defines its dependency as follows:
build.gradle of library module:
...
// parceler for serialization (https://github.com/johncarl81/parceler)
implementation "org.parceler:parceler-api:1.0.4"
annotationProcessor "org.parceler:parceler:1.0.4"
...
This seems to compile well and generates my aar file.
Further, my main app module also has a direct dependency on parceler module and contains above lines as dependencies in its build.gradle, along with above aar file.
build.gradle of main app module:
...
api(group: 'com.example.mylibrary', name: 'mylibrary', version: "1.0.7", ext: 'aar') {
transitive = true;
changing = true
}
// parceler for serialization (https://github.com/johncarl81/parceler)
implementation "org.parceler:parceler-api:1.0.4"
annotationProcessor "org.parceler:parceler:1.0.4"
...
Everything works until I try to generate my APK, which fails with the following error.
D8: Program type already present: org.parceler.Parceler$$Parcels$1
Task :MPCApp:transformDexArchiveWithDexMergerForRelease FAILED
When I expand my library project in Android studio, I see Parcels.class under org.parceler package. But it seems similar file is also generated by main app module under the same package which is causing the clash.
Upgrade to the latest (currently 1.1.10) - We got rid of the Parcels generated class.
When compiling with latest Android Studio 3.0 (gradle 4.1) I get
Unable to resolve dependency for ':app#fullReleasenoproguard/compileClasspath': Could not resolve project :aFileChooser.
I fixed it changing in build.gradle from
dependencies {
compile project(':aFileChooser')
}
to
dependencies {
implementation project(path: ':aFileChooser', configuration: 'default')
}
Getting the below error when trying to build flavour types of my lib modules.
Error:(210, 0) Gradle DSL method not found: 'flavourOneReleaseCompile()'
Possible causes:<ul><li>The project 'MyProject' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Fix plugin version and sync project</li><li>The project 'MyProject' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
build file
android{......}
configurations{
flavorOneDebugCompile{}
flavorOneReleaseCompileCompile{}
flavorTwoDebugCompile{}
flavorTworeleaseCompile{}
}
dependencies {
flavorOneDebugCompile project(path: ':lib', configuration: 'flavorOneDebug')
flavorOneReleaseCompile project(path: ':lib', configuration: 'flavorOneRelease')
flavorTwoDebugCompile project(path: ':lib', configuration: 'flavorTwoDebug')
flavorTwoReleaseCompile project(path: ':lib', configuration: 'flavorTwoRelease')
}
Im using
classpath 'com.android.tools.build:gradle:1.3.1'
i was following this guide on how to target specific build flavours
https://developer.android.com/studio/build/gradle-tips.html#target-specific-builds-with-dependency-configurations
You are using spelling mistake flavorOneReleaseCompileCompile in
configurations{
flavorOneDebugCompile{}
flavorOneReleaseCompileCompile{}
flavorTwoDebugCompile{}
flavorTworeleaseCompile{}
}
Try replacing flavorOneReleaseCompileCompile with flavorOneReleaseCompile
i have created an android library AAR in android studio 2.1.3 in which i use the following dependencies:
compile 'com.google.android.gms:play-services-vision:9.4.0+'
compile 'com.google.android.gms:play-services-wearable:9.4.0+'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
now i am using this aar in an application but those dependencies were failing unless i add them to the dependencies of the new app.
i search here and i found that i need to add the following line:
compile (project(':LIBNAME-release')) {transitive = true}
but this didn't work. is there something i missed? or is it related to the obfuscation i did to the aar file? or is it a must to add these dependencies to the app?
Try to compile you project first:
dependencies {
compile project(':Name-Of-Your-Project')
}
This is Ashton Engberg's suggestion from that post
I am trying to use a Library from a Module, but built that library in specified Flavor.
dependencies {
compile project(':library_module_1')
compile project(':library_module_2', configuration: 'flavor_1')
}
What am I doing wrong?