GCX-HCI / ThirtyInch

a MVP library for Android favoring a stateful Presenter
Apache License 2.0
1.03k stars 101 forks source link

Support for AndroidX #148

Closed passsy closed 6 years ago

passsy commented 6 years ago

I tried to convert a project to AndroidX and failed. Most problems are caused because the TiActivity extends android.support.v7.app.AppCompatActivity and not the new androidx.appcompat.app.AppCompatActivity resulting in crashes like this:

     Caused by: java.lang.ClassCastException: androidx.appcompat.widget.ContentFrameLayout cannot be cast to android.support.v7.widget.ContentFrameLayout
        at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:486)
        at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
        at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
        at com.leicacamera.oneleicaapp.scaffold.ScaffoldActivity.onCreate(ScaffoldActivity.kt:75)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)

It could be a bug of the android.enableJetifier which is not able to convert the packages correctly.

Anyhow we should come up with a solution and think about the right time to move to AndroidX.

passsy commented 6 years ago

The problem could also be a result of the compileOnly dependency of appcompat. We could try to use api.

StefMa commented 6 years ago

compileOnly is the wrong way, you are right. But using api is also wrong since we don't share any AppCompat APIs. We should go with implement in anyway...

On Wed, Jul 4, 2018, 6:18 PM Pascal Welsch notifications@github.com wrote:

The problem could also be a result of the compileOnly dependency of appcompat https://github.com/grandcentrix/ThirtyInch/blob/f125b846d733a10cbb74773a08ca625b204c8478/thirtyinch/build.gradle#L35. We could try to use api.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grandcentrix/ThirtyInch/issues/148#issuecomment-402520243, or mute the thread https://github.com/notifications/unsubscribe-auth/AJwYe5PIDf-fAec9eOhY9WtTAgzniyU3ks5uDOrVgaJpZM4VC0SD .

passsy commented 6 years ago

I think api is correct because we are extending Fragment and Activity and therefore they are part of our public API.

But it turns out AndroidX works with ThirtyInch (except for #149) and we don't have issues due to the provided. I made a mistake when setting it up resulting in this strange crash.

passsy commented 6 years ago

fixed in 0.9.0