Upgraded to Espresso 2.1 and now getting dependency conflict - android

While setting up Espresso 2.1 and the latest version of the Android Testing Support Library, I encountered the next Warning upon building:
Confilct with dependency 'com.android.support:support-annotations'.
Resolved versions for app and test app differ
My build.gradle file is:
apply plugin: 'com.android.application'
android {
...
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
...
}
dependencies {
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
}

Actually I found an existing issue:
we built against the old 22.0.0 and didn't upgrade to 22.1.0.
The runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0)
I told gradle which version of support-annotations it needs to resolve to by adding the following line to my dependencies list:
androidTestCompile 'com.android.support:support-annotations:22.1.0'
and the warning is gone.

#appoll Here Stephan Linzner added workaround for that.
Above I've added his comment to this issue, which explains solution:
we are aware of the issue. The gist is that the runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0). The correct way to solve this right now, is to tell Gradle which version of support-annotations it needs to resolve to.

Related

Deprecated Gradle features making it incompatible with Gradle 5.0. Android Studio 3.2

My android app Gradle build is not syncing, since I updated my android studio to 3.2. I have updated everything in the dependencies and still getting the same error. Here are the dependency files that I use ( Including third-party libraries)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myappid"
minSdkVersion 19
targetSdkVersion 28
versionCode 32
versionName "3.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.11"
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'
implementation 'com.android.support:cardview-v7:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-crash:28.0.0-alpha1'
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 "org.jetbrains.anko:anko:$anko_version"
implementation 'com.github.GrenderG:Toasty:1.2.5'
implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
implementation 'com.daimajia.easing:library:2.1#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.gms:google-services:4.2.0'
implementation 'com.github.sd6352051:NiftyDialogEffects:v1.0.3'
implementation 'net.steamcrafted:load-toast:1.0.12'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha1';
}
//apply plugin: 'com.google.gms.google-services'
//classpath 'com.google.gms:google-services:4.2.0'
However, I am getting the following error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
I have tried most things available through Google/Youtube searches. Implemented few answers given in StackOverflow too. But at the end of the day, it's the same error. What I am missing.
Please advice, how to resolve the issue. Thank you
So the problem doesn't necessarily needs to be in your application level build.gradle script (the one you posted). It can also be in the project level one or even in the maven-publish-aar.gradle one (if you have it). This means, you could be using deprecated Gradle features on any Gradle script.
I have updated everything in the dependencies and still getting the same error.
Most likely, the warning will be gone once you identify and replace any deprecated Gradle feature that's causing you this trouble. To do this, it will help you to actually add the mentioned --warning-mode=all flag to your Gradle command line options (on your Android studio compiler settings):
This will print the proper warnings for you to be aware of what are the specific deprecated features your app is using.
In my case (for example), I just added the enableFeaturePreview('STABLE_PUBLISHING') setting on the settings.gradle file and that did the magic (I'm using publishing{}).
Also, I know you asked this near a month ago, but, it might be useful for other people facing the same issue.
Had same issue yesterday extended to the #Hugo Allexis Cardona answer even after replacing deprecated Gradle feature having same issue because Old build folder is remains there so what I did is Remove app/build folder and sync gradle again and it work for me Thanks #Hugo Allexis Cardona
Delete App/Build Folder
The Problem is because of the inconsistency of external dependencies.
The Issue can be Easily Solved by migrating to Yarn Package Manager
Delete Node Modules
Delete Package.json.lock
yarn install
OR
Try Deleting android/app/build folder
The run the project by react-native run-android
I found easiest way to solve this issue. Go to projectName/android directory and in terminal enter the following command
./gradlew clean
And then, go to main project directory by entering following command
cd ..
And then start the project
react-native run-android
In my case
I Followed Hugo's answer
Changed the location of project.
Tried another android device [Build and success install]
Tried on my android device [Build and success install]

Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018 [duplicate]

This question already has answers here:
Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'
(24 answers)
Closed 4 years ago.
In Android Studio version 3.1 dependencies compile word is replaced to implementation. dependencies with Warning in android studio 3.1:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
buildTypes {
release {
// shrinkResources true
// minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
comment shrinkResources true and minifyEnabled true it is working for me
As the error states, you have to replace compile with implementation in dependencies since compile is obsolete.
Please check here for example.
The warning is because since Gradle 3.4 (Android Studio 3.1 is using Gradle >= 4.6) is introducing new configurations:
Gradle 3.4 introduced new Java Library plugin configurations that
allow you to control whether a dependency is published to the compile
and runtime classpaths of projects that consume that library. The
Android plugin is adopting these new dependency configurations, and
migrating large projects to use them can drastically reduce build
times. The following table helps you understand which configurations
you should use.
As the warning says, the compile configuration will be removed from gradle at the end of 2018.
replace all the 'compile's with 'implementation' in the (Module:app)
(in your code it looks like this ) :
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

All com.android.support libraries must use the exact same version specification : 27.0.2

After updating targetSdkVersion to 27 I got this error message.
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 25.2.0. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:support-media-compat:25.2.0
I understand that I should update com.android.support:support-media-compat but I dont know how because I am not using it in build.gradle , I tried to update SDK tools but the problem is still remaining . bellow is build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.ex"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
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'
implementation 'com.google.android.gms:play-services-ads:11.6.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bloder:magic:1.1'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
}
I have checked manually the libraries in project -> .myidea-> libraries then I found that I have two libraries using the old version :
com_android_support_support_media_compat_25_2_0
com_android_support_support_v4_25_2_0
then just by adding this line in builde.gradle
implementation 'com.android.support:support-v4:27.0.2'
The error is gone now.
I encountered the exact same problem. You are not using in your build.graddle but some library that you included in your build.graddle is using. Therefore, you need to override them, which are pointed in warning, in your build.graddle
I have gotten this error before. Try clicking build on Android Studio Toolbar.
Clean Build
After Step 2, Click Rebuild Project.
Update
If not, try explicitly adding implementation com.android.support:support-media-compat:27.0.2 to the build
What you are dealing with appears to be transitive dependencies. In other words just as you use gradle so you don't have to re-invent the wheel the maker of the dependency you are using also uses dependencies. It appears the problem is with this dependency 'com.github.bloder:magic:1.1' because it depends on 'com.android.support:appcompat-v7:23.1.1'. I found this out by visiting the repository pom description for blogger magic. In android studio I could also have also clicked on the gradle tab on the right and found one of the dependency task and found the conflict this way. Now that we know the problem excluding a transitive dependency may help checking to see if all dependencies are up to date may help or not using blogger magic at all may help. This problem is difficult, I know. Just hope this helps.
I encountered similar problem when updated the gradle. I implicitly declared the error written support library. I had to perform this implicitly for 3 more support libraries. This error does not solve by implicitily declaring a support library. If u want to solve the problem immediately, then replace all 27.0.2 to 25.2.0 in com.android.support.* libraries.
As you already seen the all answers and comments above but this answer is to clear something which a new developer might not get easily.
./gradlew -q dependencies app:dependencies --configuration compile
The above line will save your life with no doubt but how to get the exact point from the result of above line.
When you get the all dependency chart or list from the above command then you have to search the conflicting version number which you are getting in your code. please see the below image.
in the above image you can see that 23.4.0 is creating the problem but this we not able to find in our gradle file. So now this version number(23.4.0) will save us. When we have this number then we will find this number in the result of above command result and directly import that dependency directly in our gradle file. Please see the below image to get the clear view.
you can clearly see that com.android.support:cardview-v7:23.4.0 and com.android.support:customtabs:23.4.0 are using the version which is creating the problem. Now just simply copy those line from dependency
list and explicitly use in our gradle file but with the updated version link
implementation "com.android.support:cardview-v7:26.1.0"
implementation "com.android.support:customtabs:26.1.0"
Please refer this to see the original answer
https://stackoverflow.com/a/49169228/4156595

Incompatible plugins for android-apt after upgrading to Android Studio 2.3

After upgrading from 2.2 to 2.3 I see this warning
and when I try to compile the project I see this compilation error
How can i solve this issue without downgrading to a previous gradle version?
Is there any update of android-apt that can solve this issue?
The android-apt plugin has been deprecated.
Check here for the migration guide:
As of the Android Gradle plugin version 2.2, all functionality that was previously provided by android-apt is now available in the Android plugin.
You can remove android-apt by following the migration guide to get the equivalent functionalities.
The important parts from the migration guide:
Make sure you are on the Android Gradle 2.2 plugin or newer.
Remove the android-apt plugin from your build scripts
Change all apt, androidTestApt and testApt dependencies to their new format:
dependencies {
compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}
Also in the Android Gradle plugin there is an explicit check for this, which is what you are seeing:
using incompatible plugins for the annotation processing android-apt
Future Android Gradle plugin versions will not be compatible with the way android-apt works, which is the reason for that check.
For me, I was having this error while using Contentful's Vault library which specifies that you include:
apply plugin: 'com.neenbedankt.android-apt'
and
compile 'com.contentful.vault:core:2.1.0'
apt 'com.contentful.vault:compiler:2.1.0'
What you need to do is DELETE apply plugin: 'com.neenbedankt.android-apt'
and then CHANGE:
compile 'com.contentful.vault:core:2.1.0'
apt 'com.contentful.vault:compiler:2.1.0'
to
annotationProcessor 'com.contentful.vault:compiler:2.1.0'
annotationProcessor 'com.contentful.vault:core:3.0.1'
You can always check https://github.com/contentful/vault for the latest versions
Remove apt plugin
Change:
apt -> compile
testApt -> testAnnotationProcessor
androidTestApt -> androidTestAnnotationProcessor
In your build.gradle (app), add to defaultConfig:
vectorDrawables.useSupportLibrary = true
Piggybacking on #Gabriele Mariotti here since his answer is pretty spot on and implies this but doesn't state it. Gradle also does not suggest this as a valid option though it is as well. The testing equivalent for androidTestApt and testApt is androidTestAnnotationProcessor and testAnnotationProcessor.
Example:
testApt "com.google.dagger:dagger-compiler:$daggerVersion"
androidTestApt "com.google.dagger:dagger-compiler:$daggerVersion"
Should be changed to
testAnnotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
In case the annotation processor has arguments, one also might have to change this:
apt {
arguments {
KEY "VALUE"
}
}
to this:
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = ['KEY': 'VALUE']
}
}
}
}

Unable to resolve Android JUnit test runner

I am trying to add an instrumentation test to our project, but it seems that Gradle doesn't properly add the Android JUnit Test Runner to the project's classpath. The test depenencies of my gradle build file looks like this:
testCompile 'junit:junit:4.12'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
We are using the latest version of the support library (24.0.0), but the current version of the test runner (JUnit runner) and Espresso use version 23.1.0. To resolve the version conflict, I force the runner (and Espresso) to use the newer version (I understand the implications, but we can't use the older version):
androidTestCompile 'com.android.support:support-v4:24.0.0'
androidTestCompile 'com.android.support:appcompat-v7:24.0.0'
androidTestCompile 'com.android.support:support-v13:24.0.0'
androidTestCompile 'com.android.support:recyclerview-v7:24.0.0'
androidTestCompile 'com.android.support:design:24.0.0'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
and:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:24.0.0'
}
}
However, for some reason, Gradle doesn't add the runner package (under android.support.test). So
import android.support.test.runner.AndroidJUnit4;
throws an error: cannot resolve symbol 'runner'. Have cleared Android Studio's cache, restarted the IDE, cleared Gradle's cache (both project and global), all with no luck. Does anyone know what's going on?
try adding:
androidTestCompile 'com.android.support.test:rules:0.5'
This is my old question but thought it might help to explain the issue and the solution. The issue was with the name of the debug build variant: if you name your debug build variant anything but debug, make sure to notify Android's Gradle plugin by adding testBuildType "yourDebugBuildVariantName" to your build.gradle script (your app module's build.gradle not the project global) in the android{} section, or rename your debug build variant to just debug. If you have multiple debug build variants, you need to specify one of them on which you'd like to run your tests, like: testBuildType armDebug:
apply plugin: 'com.android.application'
...
android {
testBuildType "myDebug" <-
compileOptions { ... }
sourceSets { ... }
signingConfigs { ... }
}
Even with this explicit config, Gradle occasionally seems to have issues with running instrumentation tests. The best way to workaround this is to rename your debug build variant (the one you run your tests on) to debug if this is a feasible option for you.

Categories

Resources