Reputation: 2568
I'm migrating my Android to target 28 and use Android X instead of the Android support libraries. I've changed most of the references in my project to use Android X.
Unfortunately, when I do a build, it complains about the support library reference used in a file under "build" but those are generated and can't be edited.
What am I supposed to do now?
here's the hierarchy of the bug:
app/build/generated/source/apt/debug >
com/company/projectname/databinding/FragmentColorItemBinding.java >
error: package android.support.v7.widget does not exist
Obvs, I tried to manually change it but I get this error:
Files under the "build" folder are generated and should not be edited.
So I can't change it to reference Android X instead.
What can I do to get my build to compile?
It complains on this line btw:
public final android.support.v7.widget.CardView colorThumbnail;
On that file. I want to use the new CardView but not sure how?
EDIT:
dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('libs/android-binding-v0.6-preview.jar')
implementation 'com.flurry.android:analytics:8.2.0@aar'
implementation files('libs/ormlite-android-5.0.jar')
implementation files('libs/ormlite-core-5.0.jar')
implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'io.reactivex:rxjava:1.1.5'
implementation 'io.reactivex:rxandroid:1.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
def appCenterSdkVersion = '2.0.0'
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
}
Upvotes: 1
Views: 373
Reputation: 1186
If you are in Android Studio, It is really simple to complete the migration process. Just go to Refactor -> Migrate to AndroidX
. Otherwise, you will have to find the /gradle.properties
file and add these two lines:
android.useAndroidX=true
android.enableJetifier=true
After doing this first part, you need to change the reference in the CardView import statement to the CardView in your java files to this:
import androidx.cardview.widget.CardView;
...
public final CardView colorThumbnail;
Also make sure all the references in your xml files are correct too!
Upvotes: 1