This question already has answers here:
Android Studio keeps refusing to resolve com.android.support:appcompat-v7:29.0.1
(6 answers)
Closed 3 years ago.
When I am trying to make new activity in Android Studio
these errors happen, before this error I created few activities normally (without any errors):
The following classes could not be found:
- android.support.constraint.ConstraintLayout ( Add constraint-layout library dependency to the project, Fix Build Path, Edit XML, Create Class)
- android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)
- android.support.v7.widget.Toolbar (Fix Build Path, Edit XML, Create Class)
Dependency library:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:support-v4:29.+'
implementation 'com.android.support:design:29.+'
implementation 'com.android.support:appcompat-v7:29.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.mikhaellopez:circularimageview:3.2.0'
implementation 'com.google.android.gms:play-services-base:11.0.1'
implementation 'com.google.android.gms:play-services-basement:11.0.1'
implementation 'com.google.android.gms:play-services-safetynet:11.0.1'
implementation 'com.google.android.gms:play-services-tasks:11.0.1'
}
Looks like you are trying to use AndroidX libraries and Support libraries in same project. Migrate to AndroidX from menu, it will replace package names and dependencies.
Your project is adding widgets from Support libraries instead of AndroidX which is causing this issue.
If you still get errors, replace old package names from the ones in the list:
https://developer.android.com/jetpack/androidx/migrate
You've mixed up AndroidX dependency with AppCompat. Either migrate it to AndroidX from Refactor -> Migrate to AndroidX or use AppCompat.
As in your code, you have used both dependencies for Constraint Layout. The simplest solution for your problem is to remove the line
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Related
I just had to move my android application to androidx because of several problems. Now I have the problem, that the App is "greyed out" in the Desginer (See Screenshot):
Screenshot
In the designer there is a error message:
The following classes could not be found:
- android.support.constraint.ConstraintLayout ( Add constraint-layout library dependency to the project, Fix Build Path, Edit XML, Create Class)
I would assume there is a missing class for the constraint Layout, but that is not the case. That is my build.gradle file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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'
implementation 'com.google.android.gms:play-services-ads:19.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
}
Do you have any idea?
I already tried everything on the internet, make app, rebuild, sync with gradle files, trying different versions of the constraint layout.
Looks like you are trying to use AndroidX libraries and Support libraries in same project. Migrate to AndroidX from menu, it will replace package names and dependencies.
Your project is adding widgets from Support libraries instead of AndroidX which is causing this issue.
If you still get errors, replace old package names from the ones in the list: https://developer.android.com/jetpack/androidx/migrate
Looks like you are trying to use android.support.constraint.ConstraintLayout while adding a dependency to androidx.constraintlayout:constraintlayout. Just use the latter in your XML.
try adding the material design dependency
implementation 'com.google.android.material:material:1.1.0'
your appcompat should also be:
implementation 'androidx.appcompat:appcompat:1.1.0'
you are using androidx constaint layout dependency but your other dependencies aren't compatible
I'm trying to make an app that uses google maps API.
But there seems to be an error in regards to libraries, that are incompatible.
It says
'Found versions 28.0.0 and 26.1.0 examples including
com.android.support:animated_vector_drawable:28.0.0 and
com.android.support:support-media-compact:26.1.0
Would this have an effect on calling R.id by any chance?
I've tried clean and rebuild, and invalid cache reset.
I tried to add the files as version 28.0.0 in dependency and received 2 errors:
Failed to resolve: com.android.support:support-media-compact:28.0.0
Failed to resolve: com.android
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compact:28.0.0'
implementation 'com.android.support:animated_vector_drawable:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.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'
}
I would've thought that rewriting the versions would have fixed the problem but 'com.android.support:appcompat-v7:28.0.0' is still underlined in red.
Using the Gradle View plugin http://plugins.jetbrains.com/plugin/7150-gradle-view, I determined the issue is that play-services-location:16.0.0 has a dependency on com.android.support:support-media-compat:26.1.0. One technique I found to remove the warning is described here: https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html
which led me to add this to my gradle file:
implementation("com.android.support:appcompat-v7:28.0.0") {
force = true
}
Here you can see the latest libraries update available : link to go . And if you face again an error, you have to post the Logcat.
Add all the dependencies (that is said to be conflicting with existing libraries) with same version no. of which it is conflicting with.
I'm attempting to use org.json.XML to convert an XML file into JSON in my Android app. As the included org.json classes provided by Android do not include org.json.XML, I added it as a dependency in my build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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.3'
implementation 'com.android.volley:volley:1.1.1'
implementation group: 'org.json', name: 'json', version: '20180813'
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'
}
However, when I attempt to run my app it fails with the following error:
java.lang.NoSuchMethodError: No direct method <init>(Ljava/io/Reader;)V in class Lorg/json/JSONTokener; or its super classes (declaration of 'org.json.JSONTokener' appears in /system/framework/core-libart.jar)
at org.json.XMLTokener.<init>(XMLTokener.java:57)
at org.json.XML.toJSONObject(XML.java:516)
at org.json.XML.toJSONObject(XML.java:548)
at org.json.XML.toJSONObject(XML.java:472)
In addition build.gradle has the warning:
json defines classes that conflict with classes now provided by Android. Solutions includes finding newer versions or alternative libraries that do not have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar.
This is the same issue as presented in this question, but the answer provided does not work as org.json.XML is not included by default with Android.
Given the above, is it possible to rewrite my build.gradle to either ignore the included org.json library or to only import org.json.XML? Or will I have to look at using another library such as https://github.com/smart-fun/XmlToJson instead?
As you can see, i think all the support libraries have same version then why this error?
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.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'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
}
I think there may be 2 reasons:
1) When you hover over the error it will probably tell you which library has the wrong version, and maybe it's not even present in your dependencies, but probably one of your libraries is internally using it, so you need to specify them separately with the same version.
2) Or it may be due to the fact that one of the libraries (it's probably firebase) is compiled against a different version of the support library and that's causing the conflict. So you need your support libraries to match the support library that firebase is compiled against. For example look at how Glide explains it here:
Support Library Version - Glide uses support library version 27.
If you need or would prefer to use a different version of the support library you should exclude "com.android.support" from your Glide dependency in your build.gradle file.
So to check, if you delete the firebase dependency it will probably build. If that's the case, then you need to check against which version your version of firebase is compiled and use that.
Last night, I did two things with my android code and now it does no longer work.
The two things I did was:
Add my first adview with the corresponding gradle implementation
Update Android Studio to the latest version (3.1.1)
Now the app can not build because of version mixing in the library versions. My gradle tells me that on the lines
implementation 'com.android.support:appcompat-v7:27.1.1'
and
implementation 'com.google.firebase:firebase-core:12.0.1'
I have no idea on how to fix this and nothing I search for gives me the answer on what to do. Is there a way to auto-generate the needed gradle for my app, or could anyone please point me in the direction of were to start when fixing this?
Thanks beforehand, my gradle dependencies are below.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-database:12.0.1'
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
}
just try this one ,
"com.android.support:support-v13:27.1.1"
reference link
https://developer.android.com/topic/libraries/support-library/packages.html#v14-preference