cooperka / react-native-snackbar

:candy: Material Design "Snackbar" component for Android and iOS.
Other
815 stars 150 forks source link

Android X compatibility #175

Closed jmdrew closed 3 years ago

jmdrew commented 3 years ago

Unable to build android.useAndroidX=true android.enableJetifier=true

version: 2.3.0

Issue:

/node_modules/react-native-snackbar/android/src/main/java/com/azendoo/reactnativesnackbar/SnackbarModule.java:129: error: package android.support.design.R does not exist
22-Dec-2020 10:58:14    
22-Dec-2020 10:58:14            TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);

SnackbarModule.java - Line 129 TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);

cooperka commented 3 years ago

Thanks for the report @jmdrew, I'll welcome a PR if this library needs any changes.

rimselis commented 3 years ago

Getting the same error on "react-native-snackbar": "^2.2.3"

    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
    }
jmdrew commented 3 years ago

Getting the same error on "react-native-snackbar": "^2.2.3"

    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
    }

In your gradle.properties do you have: android.useAndroidX=true android.enableJetifier=true

Also if you are building using CI, you need to run npx jetify before the gradlew build command.

Our issue was we never ran jetify to convert the libraries to Android X before building, but I will put a PR in to fix the issue anyway.

rimselis commented 3 years ago

In your gradle.properties do you have: android.useAndroidX=true android.enableJetifier=true

Also if you are building using CI, you need to run npx jetify before the gradlew build command.

Our issue was we never ran jetify to convert the libraries to Android X before building, but I will put a PR in to fix the issue anyway.

android.useAndroidX=trueand android.enableJetifier=true is there. I'm building using Android Studio, no CI at this stage

abhijithvijayan commented 3 years ago

@cooperka Any fix on this issue? I am also running into this issue now when I upgraded to RN 0.63.4

rimselis commented 3 years ago

I have followed this fix and it solved the issue. Not sure how permanent this is https://stackoverflow.com/questions/52873056/cant-resolve-android-support-design-after-migration-to-androidx/52873231

abhijithvijayan commented 3 years ago

@rimselis Cool, let me check it out.

Update: I feel like that one is a temporary solution. As it seems the library needs to have a fix landed to make it permanent fix.

cooperka commented 3 years ago

Can anyone confirm that downgrading React Native resolves the issue? It doesn't appear to be a change to THIS library causing the issue, but rather trying to upgrade something else that uses Android X.

If anyone finds a backwards-compatible fix, please submit a PR ❤️

grenaria commented 3 years ago

Running npx jetify solved the issue for me, thanks @jmdrew !

abhijithvijayan commented 3 years ago

Actually, that did solve the issue for me too. But its not a permanent solution is it?

rkbhochalya commented 3 years ago

@cooperka looks like this issue was introduced in PR #171. There is no need to use legacy support library to get reference to snackbar text view. I have submitted a PR (#177) which fixes this issue and also cleans code and improves runtime efficiency (a little bit ;)).