I am new to android development, and I have been using the command line tools to create an android project. I followed all the instructions given in the tutorial at android
If you are using latest Android Studio, then v7 libraries contradict with AndroidX, only you have to do is:
In Project files go in gradle.properties
Find outandroid.useAndroidX=true
then set it toandroid.useAndroidX=false
Find outandroid.enableJetifier=true
then set it toandroid.enableJetifier=false
Rebuild your project, all will working fine.
I just got this error today and this is how I fixed.
Note: in my case, the error occured after I migrated one of my old projects to androidx and so imports hard to be androidx related. I am using android studio.
Note: You may run into other issues, so everytime I run into an error, I check other called classes and makes sure their imports are correct. What I do mostly is press ctrl+shift+R, and put the old import in the first field and the correct import on the second field and then replace all. This way, I replace all imports that in the project at once.
You can use ctrl+shift+f to find where imports are used.
For those who migrated to androidx, here is a list of mappings to new packages: https://developer.android.com/jetpack/androidx/migrate#class_mappings
Use implementation 'androidx.appcompat:appcompat:1.0.0'
Instead support library implementation 'com.android.support:appcompat-v7:28.0.0'
I'm a beginner but what I did for my code to work was to import androidx hence replacing the android.v7 then I erased the support.v7 line and my code worked. I'm sorry I couldn't explain in more technical terms but that's what worked for me. Actually the Java codes were codes I copied from an old tutorial hence the error encountered. Hope this helps.
If the issue reported from MainActivity.java then replace
import android.support.v7.app.AppCompatActivity;
with
import androidx.appcompat.app.AppCompatActivity;
For AndroidX implement following lib in gridle
implementation 'androidx.palette:palette:1.0.0'
and import following class in activity -
import androidx.palette.graphics.Palette;
for more info see class and mapping for AndroidX https://developer.android.com/jetpack/androidx/migrate/artifact-mappings https://developer.android.com/jetpack/androidx/migrate/class-mappings