Reputation: 10259
I'd like to migrate my app from using Android Support Libraries to AndroidX components.
This is my build.gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.test.myapplication"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
/*
implementation "com.android.support:appcompat-v7:28.0.0-beta01"
implementation "com.android.support:design:28.0.0-beta01"
implementation "com.android.support:preference-v7:28.0.0-beta01"
implementation "com.android.support:cardview-v7:28.0.0-beta01"
implementation "com.android.support.constraint:constraint-layout:1.1.2"
*/
implementation "androidx.appcompat:appcompat:1.0.0-beta01"
implementation "com.google.android.material:material:1.0.0-beta01"
implementation "androidx.preference:preference:1.0.0-beta01"
implementation "androidx.cardview:cardview:1.0.0-beta01"
implementation "androidx.constraintlayout:constraintlayout:1.1.2"
implementation "androidx.legacy:legacy-support-v4:1.0.0-beta01"
implementation 'com.dmitrymalkovich.android:progress-fab:1.6'
implementation 'cat.ereza:customactivityoncrash:2.2.0'
}
In the dependencies section you can see the old dependencies as comment. With the AndroidX dependencies I got the following error while building the app:
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/behavior_peekHeight\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/plinzen/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/5f1c73d5e36b65b3011573345597f31d/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/plinzen/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/5f1c73d5e36b65b3011573345597f31d/res/values/values.xml","position":{"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975}}],"original":"","tool":"AAPT"}
I assume it might be some kind of collision with my other two dependencies since both are still using the Android Support Libraries, like ./gradlew app:dependencies
states:
implementation 'com.dmitrymalkovich.android:progress-fab:1.6'
implementation 'cat.ereza:customactivityoncrash:2.2.0'
+--- com.dmitrymalkovich.android:progress-fab:1.6
| \--- com.android.support:design:23.3.0
| +--- com.android.support:appcompat-v7:23.3.0 -> 27.0.1
| | +--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:support-core-utils:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- android.arch.lifecycle:runtime:1.0.0
| | | +--- android.arch.lifecycle:common:1.0.0
| | | \--- android.arch.core:common:1.0.0
| | +--- com.android.support:support-fragment:27.0.1
| | | +--- com.android.support:support-compat:27.0.1 (*)
| | | +--- com.android.support:support-core-ui:27.0.1
| | | | +--- com.android.support:support-annotations:27.0.1
| | | | \--- com.android.support:support-compat:27.0.1 (*)
| | | +--- com.android.support:support-core-utils:27.0.1 (*)
| | | \--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:support-vector-drawable:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | \--- com.android.support:animated-vector-drawable:27.0.1
| | +--- com.android.support:support-vector-drawable:27.0.1 (*)
| | \--- com.android.support:support-core-ui:27.0.1 (*)
| +--- com.android.support:support-v4:23.3.0
| | \--- com.android.support:support-annotations:23.3.0 -> 27.0.1
| \--- com.android.support:recyclerview-v7:23.3.0
| +--- com.android.support:support-v4:23.3.0 (*)
| \--- com.android.support:support-annotations:23.3.0 -> 27.0.1
\--- cat.ereza:customactivityoncrash:2.2.0
\--- com.android.support:appcompat-v7:27.0.1 (*)
Is there a way to solve my issue?
Can I simply exclude the (sub-) dependencies in my build.gradle
? I have some doubts, because the package names are different between AndroidX and Android Support.
Edit: I enabled Jetifier in my project gradle.properties
like suggested by Commonsware, but I still got the same error:
android.useAndroidX=true
android.enableJetifier=true
Upvotes: 2
Views: 3289
Reputation: 10259
I did not recognize that AndroidX requires Android Studio 3.2
as minimum version. I was still working on Android Studio 3.1
, that's why the Jetifier was not working. After that my code compiles.
Upvotes: 3