Questions tagged [androidx]

New Android extension libraries (AndroidX) which represents an Android Support Library.

New package structure to make package structure clearer which packages are bundled with the Android operating system, and which are packaged with Android app's APK. Going forward, the android.* package hierarchy will be reserved for Android packages that ship with the operating system; other packages will be issued in the new androidx.* package hierarchy.

Existing packages are being refactored to use the new hierarchy. Historical artifacts—those versioned 27 and earlier, and packaged as android.support.* —will remain available on Google Maven; however, all new development will occur in the new androidx.*-packaged artifacts versioned starting from 1.0.0.

Release blog

Official Google Doc

AndroidX release notes

AndroidX refactoring

2486 questions
329
votes
8 answers

AndroidJUnit4.class is deprecated: How to use androidx.test.ext.junit.runners.AndroidJUnit4?

For my instrumentation tests I was using @RunWith(AndroidJUnit4.class) from import androidx.test.runner.AndroidJUnit4; in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4 from import…
Marcel Gangwisch
  • 8,856
  • 4
  • 23
  • 32
309
votes
10 answers

What is AndroidX?

I am reading about a room library of Android. I see they changed package android to androidx. I did not understand that. Can someone explain, please? implementation "androidx.room:room-runtime:$room_version" annotationProcessor…
217
votes
7 answers

How to set RecyclerView app:layoutManager="" from XML?

How to set RecyclerView layoutManager from XML?
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
196
votes
13 answers

Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes?

I am developing a news app but I am getting following errors in from gradle console (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:28.0.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in…
Sweden Edgar
  • 2,039
  • 2
  • 8
  • 8
168
votes
7 answers

How to disable swiping in ViewPager2?

Is it possible to enable-disable swiping in new android viewpager2 component?
murgupluoglu
  • 6,524
  • 4
  • 33
  • 43
149
votes
13 answers

Proper implementation of ViewPager2 in Android

I came to know about ViewPager2 and tried to implement it, but didn't find any proper example. Can anyone tell me how can I use it. I am looking for proper usage, not an example.
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
147
votes
16 answers

Failed to resolve variable '${animal.sniffer.version}' when migrate to AndroidX

I'm using Android Studio 3.2 Beta5 to migrate my project to AndroidX. When I rebuild my app I got these errors: ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}' ERROR: [TAG] Failed to resolve variable '${junit.version}' Full…
143
votes
13 answers

how to get viewModel by viewModels? (fragment-ktx)

I am working with Single viewModel for the Activity and all of its fragment. So to initialise viewmodel if have to write this setup code in onActivityCreated of all the fragment's override fun onActivityCreated(savedInstanceState: Bundle?) { …
143
votes
6 answers

What is Jetifier?

What is Jetifier? For example, to create a new project using the androidx-packaged dependencies, this new project needs to add the following line to the gradle.properties file: android.enableJetifier=true So what does it mean - "enable jetifier"?
Ksenia
  • 3,453
  • 7
  • 31
  • 63
126
votes
10 answers

The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. for androidx

I upgraded my android studio to 3.4 canary and now I cannot successfully build anymore due to the following error: The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten.…
Tnaffh
  • 1,313
  • 2
  • 8
  • 12
114
votes
6 answers

AndroidX:Appcompat I:art error android.view.View$OnUnhandledKeyEventListener

In a newly created project with Androidx:appcompat:appcompat:1.0.0-rc01, I'm getting the java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList I had also added…
Mohan Rex
  • 1,674
  • 2
  • 17
  • 22
104
votes
18 answers

Get current fragment with ViewPager2

I'm migrating my ViewPager to ViewPager2 since the latter is supposed to solve all the problems of the former. Unfortunately, when using it with a FragmentStateAdapter, I don't find any way to get the currently displayed…
guillaume-tgl
  • 2,749
  • 3
  • 23
  • 30
102
votes
12 answers

How to use TabLayout with ViewPager2 in Android

I want to use com.google.android.material.tabs.TabLayout component with Android's new ViewPager implementation androidx.viewpager2.widget.ViewPager2. However, the setupWithViewPager(..) method provided by TabLayout supports only the old ViewPager…
101
votes
5 answers

BottomSheetBehavior not in androidX libraries

I was using the BottomSheetBehavior with the original support library: implementation 'com.android.support:design:27.1.1' When I migrated to use the new androidx libraries though the BottomSheetBehavior is missing. The mapping from the above…
Jim Leask
  • 6,159
  • 5
  • 21
  • 31
96
votes
10 answers

Crash on Android 10 (InflateException in layout/abc_screen_simple line #17)

My application works fine from Android 4.3 until Android 9 Pie, but my application doesn't work on Android 10 (Q API 29) and crashes. This is my logcat - why this is happening? java.lang.RuntimeException: Unable to start activity …
user11453013
1
2 3
99 100