0

This import statements in the MainActivity are giving errors(after migration to androidx), what to do?

import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import android.support.design.widget.NavigationView;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
Zoe
  • 27,060
  • 21
  • 118
  • 148
Subhasish Nath
  • 124
  • 1
  • 14
  • 1
    You have to replace the import statements to comply with AndroidX libraries version. For more details, check this: https://developer.android.com/jetpack/androidx/migrate – Sneh Pandya Jun 18 '19 at 04:51
  • while migrating to androidx, package names should be changed in every class automatically, why that didn't happen? I'm confused. – Subhasish Nath Jun 18 '19 at 04:57
  • 1
    https://stackoverflow.com/a/55849025/4649110 – Basi Jun 18 '19 at 04:58

2 Answers2

4

Please remove your all appcompat-v7 and other implementation for androidx you need androidx libraries like below

import com.google.android.material.floatingactionbutton.FloatingActionButton
import androidx.appcompat.widget.Toolbar
import androidx.appcompat.app.AppCompatActivity
Zoe
  • 27,060
  • 21
  • 118
  • 148
Vipul Prajapati
  • 1,183
  • 9
  • 11
2

As Vipul Prajapati said, I manually changed all the package names by going to: https://developer.android.com/jetpack/androidx/migrate

searching for my existing package and then replacing by androidx specific ones.

I also made the following changes to my

gradle.properties

file.

android.useAndroidX=true
android.enableJetifier=true
Subhasish Nath
  • 124
  • 1
  • 14