eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Library incompatible with AndroidX #48

Closed Robyer closed 5 years ago

Robyer commented 5 years ago

Hi, I use your library (v2.2.2) and when I try to update to version 3.0 or 3.1, my Gradle sync fails with error:

Failed to transform file 'pinentryedittext-1.3.3.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform

I see the issue in PinEntryEditText library https://github.com/alphamu/PinEntryEditText/issues/40 and solution is to use version 2.0 to properly support Android Jetpack.

Could you update the library to use the new version? Thanks.

eltos commented 5 years ago

Does com.github.eltos:simpledialogfragments:patch-48-SNAPSHOT solve this for you?

Robyer commented 5 years ago

@eltos Yes, the error is gone with this version.

eltos commented 5 years ago

Renamed this to com.github.eltos:simpledialogfragments:androidx-SNAPSHOT

eltos commented 5 years ago

Reopen this because :testApp:assembleRelease fails now (see https://travis-ci.org/eltos/SimpleDialogFragments/jobs/505708032)

eltos commented 5 years ago
Execution failed for task ':testApp:processReleaseManifest'.
> Manifest merger failed: Attribute application@appComponentFactory
        value=(android.support.v4.app.CoreComponentFactory)
        from [com.android.support:support-compat:28.0.0-rc01] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
        value=(androidx.core.app.CoreComponentFactory).

There seams to be a conflict between androidx and the support libraries. Probably some further migration from support to androidx is required. Unfortunately I have no experience with androidx yet, can you help @Robyer?

Robyer commented 5 years ago

@eltos Hmm, so using that newer PinEntryEditText basically forces user to use AndroidX if he wants to use the library. Question is what would you like to do - do you still want to support old Support Library? If yes, you will be stuck with that old PinEntryEditText version and old Support Library. Then you can have separate build which uses solely AndroidX instead of Support Library.

Or you can keep current build as last version to support Support Library and then continue with newer versions of your library on AndroidX. Android recommends using AndroidX for new projects and provides Support Library only for compatibility with old apps/libs.

Nice about AndroidX is that you can use old libraries that still use Support Library in AndroidX project and just let Android Studio (their Jettifier tool) convert the code in old libraries automatically to use AndroidX (see https://developer.android.com/jetpack/androidx/migrate). But obviously it isn't always working as I've experienced now with the PinEntryEditText. If you don't want to fully switch to AndroidX yet, there is at least workaround so I can use your library in AndroidX project by specifying the newer PinEntryEditText dependency manually and it should work (unless author changed API that you call from your library - I haven't tried that as I'm not using PinEntryEditText at all, but building and use of your color dialogs works):

dependencies {
    ...
    // FIXME: Workaround to force use newer version of PinEntryEditText in SimpleDialogFragment to make use in project with AndriodX working.
    implementation 'com.alimuzaffar.lib:pinentryedittext:2.0.6'
    implementation 'com.github.eltos:simpledialogfragment:3.1'
}
eltos commented 5 years ago

The Article you linked says

Only the package and Maven artifact names changed; class, method, and field names did not change.

From my understanding that means the actual implementation does not have to be changed, only dependencies and import statements. So it should be easy to provide two branches and builds of the library (the one with the support library that already exists and the new AndroidX) for the short term. In the long term I will probably end supporting the support library and only continue development with AndroidX.

I tried the migration as described in the article you linked @Robyer. It looks like that worked out just fine, so we have a fully AndroidX supporting version of the library and testApp in the androidx branch now.

eltos commented 5 years ago

See release Version 3.1 with AndroidX

Robyer commented 5 years ago

Nice :) Perhaps you can update also Usage in readme, so people know they have this opportunity to select 2 different artifacts of the library.

Robyer commented 5 years ago

@eltos I'm sorry, I'm bit confused about the note in readme:

Check the release page for releases using androidX, otherwise

Does it mean that there won't be maven artifact to be used via Gradle for AndroidX version of your library? I thought you will just have two artifacts, like 'com.github.eltos:simpledialogfragment:3.1' (for support library) and 'com.github.eltos:simpledialogfragment:3.1-androidx' (for androidx). On releases page there is nothing more than zip with sources and APK with demo app.

eltos commented 5 years ago

Sure there are, I'm just using JitPack as of now. Please check the Badges in the release notes. They link to JitPack or bintray where you will find the maven artefact name.

Robyer commented 5 years ago

Aha, I completely missed the badges. I was looking for textual example similar to the existing one. Thanks :)