Android Studio:An alert box showed when I try to add RecyclerView - android

Warning text is:
This operation requires the library androidx.recyclerview:recyclerview:+.
Problem: Inconsistencies in the existing project dependencies found.
Version incompatibility between:
- androidx.appcompat:appcompat:1.1.0#aar and:
- androidx.appcompat:appcompat:1.1.0#aar
With the dependency:
- androidx.annotation::1.1.0 versus:
- androidx.annotation::2.0.0
The project may not compile after adding this library. Would you like
to add it anyway
After I chose OK and added the RecyclerView,I still can't use it because when I selected the added RecyclerView it shows No component selected in the Attributes.

Add this in your app.gradle
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.android.support:recyclerview-v7:29.0.0'
or you can add the Google Material Design Lib using
implementation 'com.google.android.material:material:1.0.0'
So you can use all Material Components like CardView, SnackBar, etc
Hope this will help!

Related

adding com.android.support:design:28.0.0 dependency

I am trying to add Floating Edit text to my app. For this have added 'com.android.support:design:28.0.0' dependency to my build.gradle (;app).
I'm getting this following error if try to run the project.
if need to refactor>Migrate to androidX :(please guide me to the process)
You don't need this dependency since you are using the Material components library (it is a drop-in replacement for Android's Design Support Library).
Just remove it.

implementing card view in build.gradle

I am trying to implement card view by implementing it in my build.gradle.
However while doing this, I am getting an error. It is saying
"Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX... less... (Ctrl+F1)"
I understand how to do it but am not sure if I should since I am not getting any build errors and my gradle is still syncing. Can someone tell me whats going on?
You are using androidx libraries together with a very old version of support library of cardview.
Remove the dependency of support library
//implementation 'com.android.support:cardview-v7:16.0.4'
and add:
implementation 'androidx.cardview:cardview:1.0.0'
More info about androidx here.
You have another option.
Just add the MaterialCard included in the official Material Components library:
implementation 'com.google.android.material:material:1.1.0-alpha10'
and in your xml you can use:
<com.google.android.material.card.MaterialCardView
...>
Just open your project and make the compile and target version to 28 , then sync then go to refractor on toolbar of studio , there you will see migrate to android x just tap on that. It will resolved all your issue.

dependency "androidx.core:core-ui" not found

When adding constraint layout group to my project, Android studio auto add the dependency in gradle:
implementation 'androidx.core:core-ui:+'
But I've got this error message:
Failed to resolve: androidx.core:core-ui:+
I couldn't find any way to add corresponding androidx dependency, the only solution I know so far is using support lib but It against the guideline to move everything to androidx.
com.android.support:support-core-ui:28.0.0
Is there any androix dependency which includes the ConstraintLayout Group?
Use this in your app gradle file instead...
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0-alpha1'
Try adding this to your build.gradle file implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
constraint layout does not show up for me to drag it into the layout editor(3.2 canary) but I can use it by writing the code in xml and adding this library. For any other dependencies, try writing the specific dependency in gradle, it appears core-ui for androidx not working yet.
Edit:
There should be a download icon next to the dependencies you don't have. You can click on it and there will be a pop up stating the dependency name. In Studio 3.2 Canary on windows, it is not adding these dependencies automatically, which is why my solution is to implement the dependency in build.gradle manually.

Import new Android Design Support library

Hi i'am trying to import the new android support library like this com.android.support:support-design:22.0.0 but i got this error after sync the gradle : failed to find
You have to update your Android Support Repository in SDK Manager, then just add this dependency to your build.gradle:
compile 'com.android.support:design:22.2.0'
com.android.support:support-design:22.0.0 is wrong.
dependencies {
implementation 'com.android.support:design:28.0.0'
}
New Android Design Libraries usually start with androidx word, such as:
AppCompat androidx:
implementation 'androidx.appcompat:appcompat:1.2.0'
CardViex androidx:
implementation 'androidx.cardview:cardview:1.0.0'
However be careful because everything is not start with androidx. For example, old design dependency is:
implementation 'com.android.support:design:28.0.0'
But new design dependency is:
implementation 'com.google.android.material:material:1.1.0'
Recyclerview dependency is:
implementation 'androidx.recyclerview:recyclerview:1.2.0'
So, you have to search and read carefully.
The docs has it wrong.
It should actually be 'com.android.support:design:22.2.0'
as mentioned in their official blog.
With gradle 3 it should be:
dependencies {
implementation 'com.android.support:design:27.0.2'
}
You can use:
compile 'com.android.support:design:22.2.0'
I built a complete example. I hope it helps! https://github.com/erikcaffrey/AndroidDesignSupportLibrary
Remember now is available!
Android Support Library, revision 22.2.1 (July 2015)
ctrl+alt+shift+s in the androidstudio window...
project structure window will appear..
click the app in the menu bar at the left then click dependencies..
then add `com.android.support:design:26.1.0
implementation 'com.android.support:design:28.0.0'
Click on 'File' --> 'Project Structure' (or CTRL+ALT+SHIFT+S) --> Select 'Dependencies' --> Click on '+' in the 'All Dependencies' section --> Select '1.Library Dependency'--> here you can search for any library to implement in your android studio project.
i was facing the same problem actually this is old one.
Just replace it with the following code:
implementation 'com.google.android.material:material:1.1.0'

material support library, can't find Cardview/Recycleview

I have searched the internet but i couldn't find my answer. How can I use Card view/Recycle view they are not in my layout palette or i can't use them manually and I am using eclipse
The CardView and RecycleView are not by default in the AppCompat library. You should include the CardView and RecycleView libraries manual to your project.
Reference: https://developer.android.com/training/material/lists-cards.html#Dependencies
Gradle (using Android Studio):
dependencies {
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
}
In the layout palette there is a section called "Custom" click on the "CustomView" and you shall see all the imported views from the dependencies added in the gradle file.
my problem when adding the library was the same as this guys problem
Unable to add library to android project
so I fixed it.

Categories

Resources