This question already has answers here:
What is "deps" in "implementation deps.support.app_compat"?
(2 answers)
Closed 1 year ago.
I've downloaded a repository from github and in the dependencies I've founded this
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation deps.kotlin.stdlib
implementation deps.support.app_compat
implementation deps.support.design
implementation deps.support.core_ktx
implementation deps.constraint_layout
implementation deps.arch_core.runtime
// Navigation
implementation deps.navigation.runtime_ktx
implementation deps.navigation.fragment_ktx
implementation deps.navigation.ui_ktx
// Android Testing Support Library's runner and rules
androidTestImplementation deps.atsl.runner
androidTestImplementation deps.atsl.rules
androidTestImplementation deps.room.testing
androidTestImplementation deps.arch_core.testing
// Espresso UI Testing
androidTestImplementation deps.espresso.core
androidTestImplementation deps.espresso.contrib
androidTestImplementation deps.espresso.intents
}
So I've tried to instal those dependencies to my project but I got an error
A problem occurred evaluating project ':app'.
Could not get unknown property 'deps' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
So any ideas what this "desp" means?
This is a way (with ExtraPropertiesExtension) to keep build.gradle files as clean as possible with an external file like a version.gradle file in which there are all dependencies and their version.
buildscript {
apply from: 'versions.gradle'
...
}
You can find this version.gradle at the root of the project. This file is applied in the ./build.gradle
The developer decided to manage his dependencies in this way but you can find many others.
This article present 3 ways to do it.
I have a relatively new project that I'm trying to build. Gradle syncs fine, but whenever I try to build, I get an error like this:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Failed to transform artifact 'common.jar (com.android.tools:common:26.4.0)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}.
> Execution failed for JetifyTransform: C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools\common\26.4.0\539939e284fba9fe343b890a6e21c9333767c886\common-26.4.0.jar.
> Failed to transform 'C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools\common\26.4.0\539939e284fba9fe343b890a6e21c9333767c886\common-26.4.0.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
> Failed to transform artifact 'bundletool.jar (com.android.tools.build:bundletool:0.7.2)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}.
> Execution failed for JetifyTransform: C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools.build\bundletool\0.7.2\31f71b66edcbe41de0268e14c961a7799a03d42a\bundletool-0.7.2.jar.
> Failed to transform 'C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools.build\bundletool\0.7.2\31f71b66edcbe41de0268e14c961a7799a03d42a\bundletool-0.7.2.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
I only started this project a week ago, and have been using the stable branch of Android Studio and using Gradle plugin 3.5. So, anyone have any ideas how to fix this?
What I've tried:
Disabling Jetifier in gradle.properties left me with errors about old and new databinding dependencies.
Rolling back to Gradle plugin 3.4.2 gave the same error as above.
Adding android.jetifier.blacklist = pass to gradle.properties left me with the same errors as above.
Adding android.databinding.enableV2=true to gradle.properties left me with the same errors as above.
Running the "Migrate to AndroidX" refactor in Android Studio actually left me with this weird refactor preview:
Removing apply plugin: 'kotlin-kapt' from my app-level build.gradle left me with the same errors as above.
Cleaning and rebuilding doesn't work.
Invalidating and restarting doesn't work.
EDIT 1: Gradle dependencies, for the curious... I don't think I'm using anything particularly weird here.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Kotlin stuff
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
//Test tools
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//UI
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.activity:activity:1.1.0-alpha03'
//Lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha04'
//Moshi for serialization
implementation 'com.squareup.moshi:moshi:1.8.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.8.0'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-moshi:2.6.1'
//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.9.0'
//Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
implementation 'androidx.navigation:navigation-common-ktx:2.1.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
implementation "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0"
//Diff utils
implementation group: 'io.github.java-diff-utils', name: 'java-diff-utils', version: '4.0'
//Timber for logging
implementation 'com.jakewharton.timber:timber:4.7.1'
}
Edit 2: Copy-pasted my Gradle dependencies into a new empty project and got the same errors. Could it be one of these dependencies?
Edit 3: Commenting out various libraries from my build.gradle (Moshi, Retrofit, Timber, Glide) also had no effect. So, I probably should submit a bug report to Google. Until then, what's the workaround?
Edit 4: With suggestions from the comments, I tried deleting my .gradle folder and rolling back to an earlier version of the Material design library. Both had no effect, but the latter added something interesting to the build log:
> Transform artifact kotlin-build-common.jar (org.jetbrains.kotlin:kotlin-build-common:1.3.20) with DexingNoClasspathTransform
AGPBI: {"kind":"error","text":"Invoke-customs are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
You are not supposed to put the androidx.navigation:navigation-safe-args-gradle-plugin in your app level build.gradle. That needed to be removed.
Invoke-customs are only supported starting with Android O (--min-api 26).
This means, you'd need at least:
compileSdkVersion 26
targetSdkVersion 26
In my case i updated android studio, automatically it updated my gradle version and the build faled, returning the old version solved the problema.
Trying to create a simple app with FireStore and Google Authentication. Having problem with the gradle:
In project 'app' a resolved Google Play services library dependency
depends on another at an exact version (e.g. "[15.0. 1]", but isn't
being resolved to that version. Behavior exhibited by the library will
be unknown.
Dependency failing: com.google.android.gms:play-services-flags:15.0.1
-> com.google.android.gms:play-services-basement#[
15.0.1], but play-services-basement version was 16.0.1.
The following dependencies are project dependencies that are direct or
have transitive dependencies that lead to the art ifact with the
issue.
-- Project 'app' depends onto com.google.firebase:firebase-firestore#17.1.5
-- Project 'app' depends onto com.firebaseui:firebase-ui-auth#4.2.0
For extended debugging info execute Gradle from the command line with
./gradlew --info :app:assembleDebug to see the dep endency paths to
the artifact. This error message came from the google-services Gradle
plugin, report issues at https://
github.com/google/play-services-plugins and disable by adding
"googleServices { disableVersionCheck = false }" to your b uild.gradle
file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "myapp.com"
minSdkVersion 19
targetSdkVersion 27
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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 'com.google.firebase:firebase-firestore:17.1.5'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin
Project gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
Can somebody help me?
There are many answers here for individual solutions that do not really get down to the problem. Here is how to solve this in general:
As the original log output suggests, it is useful to run the build in the terminal with the following command:
./gradlew --info assembleDebug
This will give you a list of all dependencies that are involved in the conflict. It looks similar to this (I removed the package name stuff to make it a bit more readable):
Dependency Resolution Help: Displaying all currently known paths to any version of the dependency: Artifact(groupId=com.google.firebase, artifactId=firebase-iid)
-- task/module dep -> firebase-analytics#17.2.0
---- firebase-analytics:17.2.0 library depends -> play-services-measurement-api#17.2.0
------ play-services-measurement-api:17.2.0 library depends -> firebase-iid#19.0.0
-- task/module dep -> firebase-core#17.2.0
---- firebase-core:17.2.0 library depends -> firebase-analytics#17.2.0
------ firebase-analytics:17.2.0 library depends -> play-services-measurement-api#17.2.0
-------- play-services-measurement-api:17.2.0 library depends -> firebase-iid#19.0.0
-- task/module dep -> play-services-measurement-api#17.2.0
---- play-services-measurement-api:17.2.0 library depends -> firebase-iid#19.0.0
-- task/module dep -> firebase-iid#19.0.0
-- task/module dep -> firebase-messaging#17.1.0
---- firebase-messaging:17.1.0 library depends -> firebase-iid#[16.2.0]
-- task/module dep -> com.pressenger:sdk#4.8.0
---- com.pressenger:sdk:4.8.0 library depends -> firebase-messaging#17.1.0
------ firebase-messaging:17.1.0 library depends -> firebase-iid#[16.2.0]
From this list you get to know 2 things:
Where is the conflicting depedency found
What versions of the conflicting dependency are set up
In my case the conflicting dependency is firebase-iid: It's either #19.0.0 or #16.2.0
To fix this you must define the top-level dependency of the wrong firebase-iid explicitly in your build.gralde.
So in the upper log you can see that there are 2 examples of an out-dated version of firebase-iid#16.2.0. One comes from -- task/module dep -> firebase-messaging#17.1.0 the other one from a third-party library (pressenger). We don't have influence on the third-party library, so nothing to do here.
But for the other dependency, we have to declare it explicitly with the correct version:
implementation 'com.google.firebase:firebase-messaging:20.0.0'
Now the build works again. Happy ending :)
There's a known bug with Google Services 4.2.0 that may cause this. Downgrading your google-services version to 4.1.0 in your project's build.gradle may resolve the issue
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.1.0' //decreased from 4.2.0
}
}
The problem was it was missing a dependency.
Adding com.google.firebase:firebase-auth solved the issue.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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 'com.google.firebase:firebase-firestore:17.1.5'
// implementation'com.google.firebase:firebase-core:16.0.6'
// implementation'com.google.firebase:firebase-storage:16.0.5'
implementation'com.google.firebase:firebase-auth:16.1.0' => add this line
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
}
There was a bug related to google-services that was eventually fixed in version 4.3.3.
So you can either use 4.3.3 or the latest version (check here)
classpath 'com.google.gms:google-services:4.3.3' // or latest version
or downgrade to 4.1.0
classpath 'com.google.gms:google-services:4.1.0'
i added the latest version of firebase messaging to build.gradle (Module: app) in my project and problem solved
implementation 'com.google.firebase:firebase-messaging:20.0.0'
Your app/build.gradle might have these lemon color blocked on dependencies part in Android Studio like on the picture below,
These (lemon color blocks) mean it's not latest version of dependency. just put mouse on each block, then IDE (Android Studio) tells the numbers that have to be changed.
Updating all my Google Play Services libraries to the latest in ALL modules solved the issue for me. I don't see that you have any Google Play Services libraries, but I wanna leave this answer here to those that might find this useful.
My project was working fine (No build issues). All of a sudden, I got this error
"resolved Google Play services library dependency depends on another at an exact version.."
I figured out that it was because I was building offline.
If anyone gets the same error, check if you are building offline.
Thanks, but unfortunately, this didn't entirely work for me. I also had to add the following to my build.grade (Module:app)
implementation 'com.google.android.gms:play-services-flags:16.0.1'
implementation 'com.google.android.gms:play-services-basement:16.0.1'
The problem was fixed after upgrading this lib in my project's build.gradle:
classpath 'com.google.gms:google-services:4.3.3'
and these ones in the app module's build.gradle:
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-messaging:20.1.5'
After this, use Android Studio's Clean menu
I am using One Signal and caught this error once a time.
The reason was:
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
to put apply plugin for one signal before 'com.android.application'.
Maybe this will be useful for some other apply plugin too.
Add FCM to your App added Lower dependency Then I changed the dependency to the latest version this problem has solved.
compile 'com.google.firebase:firebase-messaging:17.3.4'
to
implementation 'com.google.firebase:firebase-messaging:20.0.0'
None of the other answers worked for me. My use-case is with React-Native 61+ trying to setup FCM and Analytics. What worked for me was using the latest google-services in android/build.gradle
dependencies {
classpath "com.android.tools.build:gradle:3.4.2"
classpath "com.google.gms:google-services:4.3.3" // Need the latest here
}
And then adding the gradle dependencies to android/app/build.gradle required for the products I'm using (in my case Analytics and Cloud Messaging) from here
dependencies {
...
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
...
}
I just tried #live-love's accepted answer myself and agree with the approach.
It might be more precise, however, to correct your dependencies according to the latest Google Services library version.
For my case, it happened when I just added/activated a Firebase service to the app.
You need to follow the latest version in project and Gradle app.
My app/build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
//Android Support Design Library
implementation 'com.android.support:design:27.1.1'
//RecyclerView
implementation 'com.android.support:recyclerview-v7:27.1.1'
// Support multidex
implementation 'com.android.support:multidex:1.0.3'
// Firebase Core
// implementation 'com.google.firebase:firebase-core:16.0.1'
//Firebase Authentication
implementation 'com.google.firebase:firebase-auth:19.3.1'
// Firestore Firestore
implementation 'com.google.firebase:firebase-firestore:21.4.3'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
// glide
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
// Circle ImageView
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
apply plugin: 'com.google.gms.google-services'
My project's build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Don't forget to sync the Gradle again.
The working solution for me was to remove "firebase-auth" and add "firebase-core" dependency. But after a couple of project rebuilds I started experiencing another compilation issue so I had to add the "firebase-auth" dependency in addition to the "firebase-core" in order to make it work:
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
Add the line below in you Project's build.gradle (See image below)
classpath 'com.google.gms:google-services:4.3.3'
Then update your Firebase related packages by going to :
File > Project Structure > Dependencies > app
Update Firebase modules to latest version (See the image below)
In my case I am using :
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-messaging:20.1.7'
implementation 'com.google.firebase:firebase-core:17.4.0'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
Don't forget to add :
apply plugin: 'com.google.gms.google-services'
See my Module's build.gradle file below.
The ML Kit library had versioning problems in the latest release.
Google Play services library dependency depends on another at an exact version error (thrown by the google-services plugin)
Here is the link to the solution.
https://firebase.google.com/support/release-notes/android#bom_v25-8-0
This is new thing happen to me that If your network is not secure and you are getting prompt of Untrusted Certificate.
If you will Accept or Reject, It will give this error until your network will not be secure.
You can work offline by checking Setting -> Gradle -> Offline Mode
If you used song haesuk answer, you need to do it for both build.gradle Project (classpath in dependencies), and in build.gradle app (implementations). Also do the same if you change builds for any libraries imported to the app.
I use suggestions provided by android studio and it changed implementations but did not change dependencies hence during build, there was a conflict between the two and it gave me same error.
I replicated the issue when I accidentally added com.google.firebase:firebase-ml-vision twice with different versions.
I resolved it by simply clearing the app-level dependencies block leaving just the default Android dependencies like so:
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'androidx.multidex:multidex:2.0.0'
}
This worked for me!
dependencies {
classpath "com.android.tools.build:gradle:3.4.2"
classpath "com.google.gms:google-services:4.3.3" // Need the latest here
}
dependencies {
...
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
...
}
In my case updating the firebase-bom and play services library to their latest version solved the issue:
In app level gradle :
implementation platform('com.google.firebase:firebase-bom:30.3.2')
In project level gradle :
classpath 'com.google.gms:google-services:4.3.13'
I've develop a project using zxing to scan the barcode. I had followed the tutorial from here, but unfortunately I got error when I tried to run the project to device. The error that I get is
This is the build.gradle(app)
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
// volley
compile 'com.android.volley:volley:1.0.0'
// butter knife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// picasso
implementation 'com.squareup.picasso:picasso:2.71828'
// QR Zxing Library
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
}
Below is External Libraries list.
After a day I tried to find out the solution, but everything failed. Then I decided to create a new project and copy the current source code together with build.gradle(app). Luckily no more error occurred when I run new project.
But I still don't know what the actual reason why I got that error before this, so I assume maybe some part of the old project are missing or have some bug on it.
Because at new project you change buildToolVersion
Reason : Its happened because being conflict between core.jar and zxing
Solution : Just change buildToolVersion and build , after that revert old toolVersion and build again !
After weeks of searching, the following steps help me resolve the issue like a charm:
1.Remove android platform.
2.Install cordova-plugin-facebook4
3.Create build.gradle in /plugins/cordova-plugin-facebook4/
4.Copy this
dependencies {
compile("com.facebook.android:facebook-android-sdk:4.37.0") {
exclude group: 'com.google.zxing'
}
}
to ../plugins/cordova-plugin-facebook4/build.gradle
5.Edit ../plugins/cordova-plugin-facebook4/plugins.xml change
to
6.Add platform android and build
I used to copy 'compile' dependencies to a specific folder using this simple gradle task :
task copyLibs(type: Copy) {
from configurations.compile
into "$project.rootDir/reports/libs/"
}
But it stopped working just after upgrading my Android project using gradle plugin 3.0.1 for Android Studio and Gradle tool to 4.1. As the dependency configuration 'compile' is now deprecated by https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations I changed it to 'implementation'. However, I am not able to use my copyLibs task as resolving configuration 'implementation' directly is not allowed as per Gradle build error output :
$ ./gradlew.bat clean build
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:copyLibs'.
> Resolving configuration 'implementation' directly is not allowed
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
See following my current build.gradle file for app module : apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "newgradle.com.testingnewgradle"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
}
task copyLibs(type: Copy) {
from configurations.implementation
into "$project.rootDir/reports/libs/"
}
build.dependsOn copyLibs
If I use 'compile' it works but I would like to be compliant with the latest recommendation on this plugin the usage.
I need help to upgrade my copyLibs task in order to work as before upgrading my enviromment.
I was using gradle plugin 2.2.3 for Android Studio and Gradle tool 2.14.1.
instead of using configurations.implementation, the best option is to use configurations.runtimeClasspath.
You can also think about:
compileClasspath
default
I make the configuration resolvable, so there is no exception when getting the dependencies
configurations.implementation.setCanBeResolved(true)
configurations.api.setCanBeResolved(true)
println configurations.implementation.resolve()
println configurations.api.resolve()
Another suggestion.
I created my custom config and then used it as configurations.customConfig:
configurations {
customConfig.extendsFrom implementation
}
The copy task must be correspondingly edited:
task copyLibs(type: Copy) {
from configurations.customConfig
into "$project.rootDir/reports/libs/"
}
It doesn't look as if there's a way to acquire the list of implementation dependencies and the compileClasspath mentioned at the Gradle ticket Rafael posted won't work if you're working with Android directly, like my case where I need the dependencies to be exported so that Unity3D can package them up for release.
So.. it looks like the only solution in this case is to use the deprecated compile type.
This probably won't help or have a better way to solve but...
You can put your dependencies in a way that is possible to copy doing the following:
android { ... }
// Add a new configuration to hold your dependencies
configurations {
myConfig
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
// Now you have to repeat adding the dependencies you want to copy in the 'myConfig'
myConfig fileTree(dir: 'libs', include: ['*.jar'])
myConfig 'com.android.support:appcompat-v7:26.1.0'
myConfig 'com.android.support:support-v4:26.1.0'
...
}
task copyLibs(type: Copy) {
// Now you can use 'myConfig' instead of 'implementation' or 'compile'
from configurations.myConfig
into "$project.rootDir/reports/libs/"
}
This also helps if you have a Jar task that stops placing the dependencies in to the jar file because you changed from compile to implementation.
You can use:
from {configurations.myConfig.collect { it.isDirectory() ? it : zipTree(it) }}
Instead of:
from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}
I started getting this error after upgrading from gradle 5.5 to 5.6, and it happens when I try to sync the project in intelliJ.
Thanks to this answer on another question, I solved it by applying the idea plugin to all projects and then running gradle cleanIdea and after that everything started working again.
Another day, another #inexplicable solution to a problem.
there is some documentation about this, at least at this moment. You can not directly use 'implementation' configuration, but only use one that extends this. Now you can create a custom configuration, but there are preconfigured extensions already, like 'compileClasspath'.
compileClasspath extends compileOnly, implementation
Compile classpath, used when compiling source. Used by task compileJava.
Documentation is here: https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management