I don't really understand why my appcompat version is not accepted
Please help
click to see image
This is a warning, your app will still run.
One or more of your transitive dependencies is requesting different version of of the Android Support Library that you are not requesting directly yourself, resulting in this conflict. You will need to run a Gradle dependency report and find out what is causing the problem, then manually request those artifacts yourself with your desired version (presently, 27.0.1).
I think in your case facebook is using old version, you should try updating facebook dependency version to latest.
You can see this answer as well.
You have probabelly some libraries that use older versions of some others support libraries (not especially AppCompat), so you have to override them manually in the gradle to get rid of this warning.
You have to repeat this until the warning disapear :
When you see the hint, copy and past the library and update the version number : for example if in the hint you have
"blablabla... example include blablabla...
com.android.support:support-core-ui:26.0.1"
Add this to the dependencies section of the build.gradle script :
implementation 'com.android.support:support-core-ui:27.1.1'
Related
When you reference a dependency directly in gradle, IntelliJ gives a lint warning if there is a newer version. i.e. implementation 'com.library:name:1.0.0' gives a warning that version 1.0.1 is available.
If, however, you reference the library via a gradle ext. property, it does not give that warning. i.e. implementation deps.library.name does not give a warning. Is there any way I can still get that warning while referencing previously defined libraries?
In my case I have several modules that re-use a lot of the same libraries, so it's important to be able to define all the libraries and their versions in one place and then just refer to them from each module that needs them. But this causes me to no longer be told by the IDE when there are new version. How can I fix this?
This is actually a feature of Android Studio and indeed it does not support all the ways a dependency can be defined in Gradle.
An equivalent can be achieved with the plugin gradle-versions-plugin through its dependencyUpdates task.
com.android.support:appcompat-v7:28.0.0-rc02
com.android.support:design:28.0.0-rc01 -> should be rc02, but there's no rc02 actually.
error:
app/build.gradle:74: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).
Found versions 28.0.0-rc02, 28.0.0-rc01. Examples include com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:cardview-v7:28.0.0-rc01 [GradleCompatible]
I know it's a warning, we have turned to warn as the errors in CI in order to avoid the potential dead crashes, well, any solution except turn off option for CI?
issue
UPDATE
Design library version 28.0.0-cr02 published.
OLD ANSWER
According to this link
https://mvnrepository.com/artifact/com.android.support/design?repo=google
design:28.0.0-rc02 not yet published.
So all you can do for now is use the previous version for appcompat and wait until design library new version28.0.0-cr02 release.
So for now use this :
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
I don't know why... But they(sdk devs) behaving like Microsoft..
"Ohh..It compiles, lets ship it".
They just launch and don't care about bugs.. after updating to latest libs every time, first thing i get is..
"Layout editor preview errors.".
i hope it will be easy next time. :/
Keep track of the library here, until its published, use rc01 for other ones.
https://mvnrepository.com/artifact/com.android.support/design?repo=google
That's why I use stable versions always
If you are developing an app, you don't want to face these type of errors.
At the time of answering the current most stable version is 27.1.1 and second 28.0.0-rc02.
I suggest use 27.1.1 until 28 stable version release.
implementation 'com.android.support:appcompat-v7:27.1.1'
Sync again
No need of Invalidate/ Restart, Just restart would be okay. Or closing project and reopening from recent would be faster then restart.
Track the support library release.
Replace your
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
with
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
Looks like this should no longer be an issue. Looking at the link below, i think that whatever hiccups were encountered by OP are no longer relevant.
https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0-rc02
About the error message "All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes)." The solution is outlined here (the answer by João Paulo Paiva).
To rid yourself of the error message, you have to basically include each package name mentioned in the warning - com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:cardview-v7:28.0.0-rc01
Essentially, manually add the following lines to your build.gradle
implementation com.android.support:animated-vector-drawable:28.0.0-rc02
implementation com.android.support:cardview-v7:28.0.0-rc02
You may encounter more such warnings - the solution is to keep subsequently adding the libraries/dependencies mentioned (and updating the version to 28.0.0-rc02 as well) until the warnings go away. I had this issue, and after the first lot, I didn't get any more, but YMMV!
1.Go to project/.idea/libraries folder on your file system and see which libraries are different.
2.You will have to manually include these libraries with the same version in your build.gradle file.
3.Then, sync your project
In Your Case:-
Add This Dependency :-
implements 'com.android.support:cardview-v7:28.0.0-rc02'
Add all dependency with Latest version which shows in error message.
I close this ticket, the problem has been solved that Google has updated design library to 28.0.0-rc02 .
Previously my gradle used to look like this and worked fine (apart from few registered bugs)
implementation 'com.dji:dji-sdk:4.3.2'
Now, after changing to
implementation 'com.dji:dji-sdk:4.4.0'
the Camera and other files cannot be recognized anymore. I am attaching a screenshot of the unrecognized imports.
However when I am trying to add
//dji-drones-sdk
implementation 'com.dji:dji-sdk:4.4.0'
provided 'com.dji:dji-sdk-provided:4.4.0'
I am getting "could not download dji-sdk-provided.jar"
Screenshot attached
All the examples and github codes are in version 4.3.2. Can anyone help me out?
Here is the link to the dji sdk
I have found the issue. After Gradle 3.4, the "provided" is replaced by "compileOnly"
I quote,
Gradle adds the dependency to the compilation classpath only (it is not added to the build output). This is useful when you're creating an Android library module and you need the dependency during compilation, but it's optional to have present at runtime. That is, if you use this configuration, then your library module must include a runtime condition to check whether the dependency is available, and then gracefully change its behavior so it can still function if it's not provided. This helps reduce the size of the final APK by not adding transient dependencies that aren't critical. This configuration behaves just like provided (which is now deprecated).
Hence using compileOnly in place of provided will do the trick.
Here is a link to the gradle changes documentation
Let say I have added Facebook and Twitter dependencies in my app.
com.facebook.android:facebook-android-sdk:4.22.1
com.twitter.sdk.android:twitter:2.1.0
When i look at Gradle tree, They come up with bunch of other transitive dependencies.
Now If Facebook uses com.android.support:support-annotations:24.1.1 and twitter uses com.android.support:support-annotations:25.0.3
Then which version gradle will use.
In gradle tree, It shows -> in front of older version of dependency. I learnt that this means gradle will use the newer version, and will not use the older version.
But this can be a problem, because some libraries are meant to run on the specific versions, and i have faced this problem.
In one of article i found out how npm manages these dependencies conflicts, but i am still unsure how gradle will manage between different version of same library.
You can't have different versions of the same library inside an apk.
As you mentioned, by default, Gradle puts the newest one to the build. If you want to specify a concrete version of the library that should be used in your project, you can add a direct compile (or implementation / api for Android Gradle Plugin v3+) statement with a required version to get one.
Also, you can force version using a special syntax, but it can lead to some problems later. You can find more information about version conflicts resolution in this post
Is there an easy way to get gradle to update dependencies to their latest available version?
For build reproducibility all my dependencies are defined with a version number like this in my build.gradle file:
dependencies {
compile 'namespace:package1:version'
compile 'namespace:package2:version'
compile 'namespace:package3:version'
}
Periodically I want to update every package to their latest version. Typically this is the first thing I do for a new sprint after making a release.
It's a real pain doing this manually for each package. Ideally I would like a command to update the build.gradle file for me but at the very least a command that prints out which package needs an update and what the latest version number is.
In ruby land I would run bundler update.
This is all I've been able to come up with. I will happily accept another answer if there is a less manual method of doing this.
In Android studio I replace every dependency version with a plus example: compile 'namespace:package1:+'
Sync or build the project which will cause all the dependencies to be resolved to their latest version.
In Android Studio place the cursor on each dependency line in build.gradle and press alt+enter a menu pops up and you can select Replace with specific version
Add to build.gradle:
plugins {
id 'com.github.ben-manes.versions' version '0.17.0'
}
Then you can do gradle dependencyUpdates to get a report of new versions. Unlike the eponymous Maven plugin, there doesn't seem to be a way of automatically updating the build.gradle yet.
More documentation: https://github.com/ben-manes/gradle-versions-plugin
It is not a really good practice as libraries can include changes that may break your code.
A common "tolerated" syntax for
compile 'namespace:package:major_version.minor_version.revision'
would be like
compile 'namespace:package:1.0.+'
considering revision is used by the library authors as bug fixes and improvements updates
Note:
I just did that and you could do
compile 'namespace:package:+'
Edit:
A Proof Of Concept of my latest comment you may want to test.
This was made in 5 minutes, so don't expect it to be perfect nor flexible.
I suffer from it, too. And the best way to check dependencies, even manually, is to go through Project Structure and search for the dependency name and see if there is a newer version.
The problem that this query only checks for the dependencies present in the Maven repository. At least it already goes for Google's.
Note: If you choose to add the dependency with the new version, this will add a duplicity in the your App Gradle, so be sure to delete the old dependency row.
###################
Another possible quick fix is through the command line:
./gradlew app:dependencies
This will generate an output like the one below. Note that the asterisk points to a possible new existing version.