• Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / tutorials / Android Studio tutorials syllabus Topics Course details #AndroidApplicationDevelopment / migrating to androidx (The library & dependency matching)

migrating to androidx (The library & dependency matching)

 

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

Table of Contents

Toggle
  • Step 2 open gradle.properties add & sync
    • Dependency Mapping
  • Step 3: Lets fix compile time errors by library class Mapping
    • 3.1 Refractor >> Migrate to Android Studio
  • Step 4: FIx runtime errors
  • Step 5: Layout library Modification

Step 2 open gradle.properties add & sync

android.useAndroidX=true
android.enableJetifier=true
//Jetifier helps migrate third-party dependencies to use AndroidX.

Dependency Mapping

change compile sdk 28 to 29
28 intended for android pie and below
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
More at android artifact mapping

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'
to

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

https://developer.android.com/jetpack/androidx/migrate/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;

 

android x library mapping
Note: Don;t tempt to modify the code / methods. (just a library issues)
CTRL+SHIFT+R to replace

Step 4: FIx runtime errors

Step 5: Layout library Modification

Duration: few hours.
I tried for 90%  used the updated source code by someone else
import android.support.design.widget.TabLayout;
android.support to android.x
Class mappings
android.support.design.widget.TabLayout
to
com.google.android.material.tabs.TabLayout
android.support.v7.widget.Toolbar
to
androidx.appcompat.widget.Toolbar
android.support.v7
to
androidx.appcompat
import androidx.core.app.Fragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
to
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
com.android.support:support-fragment would need to be replaced there with
androidx.fragment:fragment,
import android.support.v4.app.FragmentManager;
to
androidx.fragment.app.FragmentManager
import androidx.core.app.Fragment;
import androidx.core.app.FragmentManager;
import androidx.core.app.FragmentStatePagerAdapter;
core to fragment
import androidx.core.widget.DrawerLayout;
to
androidx.drawerlayout.widget.DrawerLayout
from
androidx.core.widget.SwipeRefreshLayout;
to
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
from
import androidx.core.view.PagerAdapter;
import androidx.core.view.ViewPager;
to
androidx.viewpager.widget.ViewPager
androidx.viewpager.widget.PagerAdapter
Required type:
android.app.AlertDialog.Builder
Provided:
androidx.appcompat.app.AlertDialog.Builder
fragmentactivity cannot be converted to appcompatactivity
This seems to be an import problem.
import android.app.Fragment;
import android.support.v4.app.Fragment;
androidx.fragment.app.FragmentManager
fallback
from
import androidx.appcompat.app.AlertDialog;
to
import android.app.AlertDialog;
import androidx.fragment.app.AlertDialog;
Required type fragment activity provided appcompat activity
cast to  import androidx.appcompat.app.AppCompatActivity;
Activity <- FragmentActivity <- AppCompatActivity <- ActionBarActivity
* Activity is the basic one.
* Based on Activity, FragmentActivity provides the ability to use Fragment.
* Based on FragmentActivity, AppCompatActivity provides features to ActionBar.
adancedwebiew jaa & webfragmentja.
186
actity to fragment actiity
found
androidx.fragment.app.FragmentActivity
Required
androidx.appcompat.app.AppCompatActivity
Found
import homeagment.app.FragmentActivity;
‘WebToAppWebClient(androidx.appcompat.app.AppCompatActivity, android.webkit.WebView)’ in ‘home.jsit.landrecord.widget.webview.WebToAppWebClient’ cannot be applied to ‘(androidx.fragment.app.FragmentActivity, home.jsit.landrecord.widget.AdvancedWebView)’
Static interface methods are only supported starting with Android N (–min-api 24): androidx.browser.trusted.TrustedWebActivityDisplayMode androidx.browser.trusted.TrustedWebActivityDisplayMode.fromBundle(android.os.Bundle)
Stack trace:
 missing “compileOptions” configuration in the AndroidManifest.xml file.
build.gradle App module
android{
   compileOptions {
     sourceCompatibility JavaVersion.VERSION_1_8
     targetCompatibility JavaVersion.VERSION_1_8
   }
}
    java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException:
Starting in version 17.0.0
if you update your Admob library in gradle then you need to add this in your manifest.
implementation ‘com.google.android.gms:play-services-ads:19.3.0’
in manifest file
   <application>
      <!– TODO: Replace with your real AdMob app ID –>
      <meta-data
          android:name=”com.google.android.gms.ads.APPLICATION_ID”
          android:value=”ca-app-pub-################~##########”/>
  </application>
Application id: package name /app id mostly same unless you change it.
AdMob app ID: add to admob
   <application>
<meta-data
          android:name=”com.google.android.gms.ads.APPLICATION_ID”
          android:value=”ca-app-pub-xxxxxxx~xxxxxx”/>
  </application>
google ad manager instead of admob
then
        <meta-data
            android:name=”com.google.android.gms.ads.AD_MANAGER_APP”
            android:value=”true”/>
class library match
android.app.AlertDialog.Builder
inconvertible types; cannot cast ‘androidx.fragment.app.Fragment‘ to ‘com.package.name.drawer.DrawerFragment‘
androidx.core.app.fragment not found
import androidx.core.app.Fragment; to androidx.drawerlayout.widget.DrawerLayout
import androidx.core.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
androidx.appcompat
android.support.design.widget.TabLayout
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.core.widget.SwipeRefreshLayout;
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.core.app.Fragment;
import androidx.core.app.FragmentManager;
import androidx.core.app.FragmentStatePagerAdapter;
Cannot Resolve Symbol ‘App’
Select tools>-android>-SDK manager
update available click apply

Restart the IDE

“File” -> “Invalidate Caches…”, and select “Invalidate and Restart” option to fix this.

tutorials

  • Core Java Tutorial Free online
  • HTML & CSS Tutorials
  • Php tutorials
  • ubuntu tutorials installation download issues etc
  • redis install ubuntu 20.04 with wordpress php redis mysql configuration
  • [INTRO] Ethical hacking / cyber Security / Penetration testing Tutorial -{updates frequently}
  • Android Studio tutorials syllabus Topics Course details #AndroidApplicationDevelopment
    • Options Menu
    • JSON parsing
    • Handling Views
    • RelativeLayout
    • ActionBar
    • ListView
    • Custom List View
    • Dialogs
    • AlarmManager
    • Notifications
    • Vibration
    • WebView
    • Fragments Runtime
    • SQLiteDatabase
    • Bluetooth
    • WiFi
    • Google Maps
    • Handling Activity Back Button
    • AsyncTask
    • Runtime Permissions
    • Logging
    • Activity Lifecycle
    • Toast
    • Service
    • Database with Cursor Adapter
    • SharedPreferences
    • Location
    • Libraries
    • Webservices
    • Creating Activity class
    • Creating XML
    • Registering Activity in AndroidManifest.xml:
    • Steps for creating an Android application:
    • Handling button clicks
    • Identifying Views
    • Getting Text from Views
    • intent with Data
    • Intent
    • Resources Handling in Android
    • Intent with Result Data
    • Broad cast Receiver
    • Fragment
    • Handling Button click by using On Click Listener:
    • Material Design
    • RecyclerView
    • JSON
    • Rename Android Package [with images & video 2020]
    • migrating to androidx (The library & dependency matching)
    • adsense on webview , adsense & admob policies & implementation
  • AUdio Editing Background Noise removal (Audacity, Adobe Premiere Addition, Camtasia Filmora Windows Obs)
  • what is vpn vs proxy vs tor, http vs https, http2, tcp vs udp, kali linux sql source code injection
  • how to create a website free of cost on google
  • CCNA Syllabus pdf (CCNA / CCNP vs devops vs mcsa /MCSE)
  • Redis performance metrics & tuning for nginx apache ubuntu & debian
  • xampp tutorials 2021 installation errors fix wordpress phpmyadmin mysql apache
  • new relic installation linux (infrastructure agent , php, mysql , nginx)
  • new relic mysql install integration - 2 ways fix problems
  • new relic php agent install in 3 steps
  • aws load balancer tutorial
  • git branches merge fetch pull conflicts

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy