Reputation: 773
I'm added the RecycleView to my XML like this:
<androidx.recyclerview
android:id="@+id/recycleViewTest"
android:layout_width="match_parent"
android:layout_height="match_parent" />
My dependencies in build.gradle are defined like this:
dependencies
{
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation "androidx.recyclerview:recyclerview:1.0.0-alpha1"
}
The project compiles, but it crashes when I run it and I get the following exception:
Caused by: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class androidx.recyclerview
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class androidx.recyclerview
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.recyclerview" on path: DexPathList[[zip file "/data/app/
My compileSdkVersion is set to 28. Any suggestions please?
UPDATE:
I added to the dependencies:
implementation 'com.android.support:recyclerview-v7:28.0.0-beta01'
So my dependency section look like this now:
dependencies
{
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:recyclerview-v7:28.0.0-beta01'
}
But now I'm getting a new error:
Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0-alpha1] AndroidManifest.xml:22:18-86
is also present at [com.android.support:support-compat:28.0.0-beta01] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:6:5-21:19 to override.
So I added the following attribute:
tools:replace="android:appComponentFactory"
To the the application tag like this:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:replace="android:appComponentFactory"
android:theme="@style/AppTheme">
But now I'm getting another error:
Manifest merger failed with multiple errors, see logs
Upvotes: 2
Views: 1852
Reputation: 61
If you switch to AndroidX, you need to change
android.useAndroidX = true
and android.enableJetifier = true
in gradle.properties consistently and for all parts that did belong to the support library before. You cannot mix support library with androidx, otherwise the Manifest merger will complain as in your case.
To switch the RecycleView in particular, change
implementation 'androidx.recyclerview:recyclerview:1.0.0'
androidx.recyclerview.widget.RecyclerView
mappings can be found in "Migration to AndroidX" guide here.
Upvotes: 2
Reputation: 18276
androidx.recyclerview is a package name, you need the package+classname of a View to inflate it trough XML, I looked for you but the package androidx.recyclerview has now views.
If you intended to use the RecyclerView ( https://developer.android.com/guide/topics/ui/layout/recyclerview )
The correct gradle statement is:
implementation 'com.android.support:recyclerview-v7:27.1.1'
and the XML tag is:
android.support.v7.widget.RecyclerView
Upvotes: 3