Reputation: 704
I have created a custom Class which extends ImageView. It was working perfectly fine until AndroidX shows up.
Here, the java code
import android.content.Context;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.widget.RelativeLayout;
import androidx.appcompat.widget.AppCompatImageView;
public class CloseView extends AppCompatImageView {
public CloseView(Context context) {
super(context);
init();
}
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4: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'
}
Android shows 2 errors for this file
Has anyone able to fix this issue?
Upvotes: 5
Views: 21255
Reputation: 3873
You should completely migrate to AndroidX to use its classes
AndroidX
in Gradle settings:android.useAndroidX=true
android.enableJetifier=true
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
instead of
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
See: https://developer.android.com/jetpack/androidx/migrate
Edit:
AndroidX is the newest replacement to all the previous numbered support libraries. Read more about it here before you start using it.
Upvotes: 25