the Errors
Your app currently targets API level 27 and must target at least API level 28 to ensure that it is built on the latest APIs optimised for security and performance. Change your app’s target API level to at least 28. Find out how.
Changing Dependency version to 28
implementation ‘com.android.support:support-v4:28.0.0’
implementation ‘com.android.support:appcompat-v7:28.0.0’
implementation ‘com.android.support:customtabs:28.0.0’
implementation 'com.android.support:design:28.0.0' Sync error
This project uses AndroidX dependencies, but the ‘android.useAndroidX‘ property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.versionedparcelable:versionedparcelable:1.0.0, androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.core:core:1.0.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.browser:browser:1.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
Affected Modules: app
Step 2 open gradle.properties add & sync
Dependency Mapping
Old | New |
com.android.support:support-v4 | androidx.legacy:legacy-support-v4 |
com.android.support:appcompat-v7 | androidx.appcompat:appcompat |
com.android.support:customtabs | androidx.browser:browser |
com.android.support:design | com.google.android.material:material-rc01 |
com.android.support:swiperefreshlayout | androidx.swiperefreshlayout:swiperefreshlayout |
android.support.v7.widget.Toolbar | androidx.appcompat.widget.Toolbar |
android.support.v7.app.AppCompatActivity | androidx.appcompat.app.AppCompatActivity |
android.support.design.widget.TabLayout | com.google.android.material.tabs.TabLayout |
androidx.core.widget.DrawerLayout | androidx.drawerlayout.widget.DrawerLayout |
androidx.core.view.PagerAdapter | androidx.viewpager.widget |
androidx.core.view.ViewPager | androidx.viewpager.widget |
implementation ‘com.android.support:support-v4:28.0.0’
implementation ‘com.android.support:appcompat-v7:28.0.0’
implementation ‘com.android.support:customtabs:28.0.0’
implementation 'com.android.support:design:28.0.0'
implementation ‘androidx.legacy:legacy-support-v4:1.0.0’
implementation ‘androidx.browser:browser:1.2.0’
implementation ‘androidx.appcompat:appcompat:1.1.0’
implementation ‘com.google.android.material:material:1.1.0’
implementation “androidx.swiperefreshlayout:swiperefreshlayout:1.1.0”
Step 3: Lets fix compile time errors by library class Mapping
3.1 Refractor >> Migrate to Android Studio
Its not accurately adds new libraries. later you need find the libraries and fix it manually.
Step 1: refractor migrate to androidx
step 2: click on do refractor
Step 3: rebuild project
class mapping
all mappings here
Old | New |
import androidx.core.widget.DrawerLayout; import android.support.v7.widget.Toolbar; import android.support.v7.app.AppCompatActivity;
Artifact Mappings
old libraries
import android.support.customtabs.CustomTabsIntent;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager;
Step 4: FIx runtime errors
Step 5: Layout library Modification
import androidx.core.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
android.support.design.widget.TabLayout
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.core.app.Fragment; import androidx.core.app.FragmentManager; import androidx.core.app.FragmentStatePagerAdapter;
Restart the IDE
“File” -> “Invalidate Caches…”, and select “Invalidate and Restart” option to fix this.