迁移到AndroidX

修改gradle.properties

# 当前项目启用Androidx
android.useAndroidX=true
# 将依赖包迁移到androidx
android.enableJetifier=true

点击:Refactor > Migrate to AndroidX,如下图


迁移到AndroidX_第1张图片
迁移.png

点击迁移的时候提示是否备份。如果已经备份就不需要勾选了。

点击编辑运行项目。
问题:
v4包问题:
import android.support.v4.view.ViewPager
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.AccessibilityDelegateCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewConfigurationCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.support.v4.view.accessibility.AccessibilityRecordCompat;
import android.support.v4.widget.EdgeEffectCompat;
import android.support.v4.app.DialogFragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.content.FileProvider;
改为:
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.MotionEventCompat;
import androidx.core.view.VelocityTrackerCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.ViewConfigurationCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityRecordCompat;
import androidx.core.widget.EdgeEffectCompat;
import androidx.fragment.app.DialogFragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.fragment.app.FragmentTransaction;
import androidx.core.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;

v7包问题:
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSmoothScroller;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.AppCompatImageView
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.GridLayoutManager;
android.support.v7.widget.AppCompatSeekBar
import android.support.v7.app.AppCompatActivity;
改为:
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.appcompat.widget.AppCompatSeekBar;
import androidx.appcompat.app.AppCompatActivity;

注解问题:
import android.support.annotation.Nullable;
import android.support.annotation.IntDef;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.IdRes;
import android.support.annotation.FloatRange;
import android.support.annotation.IntRange;
改为:
import androidx.annotation.Nullable;
import androidx.annotation.IntDef;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.IdRes;

bind:
import android.databinding.BindingAdapter;
改为:
import androidx.databinding.BindingAdapter;

support库:
android.support.constraint.ConstraintLayout
改为:
androidx.constraintlayout.widget.ConstraintLayout

你可能感兴趣的:(迁移到AndroidX)