Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why gradlew assembleDebug doesn't run jetifier, while react-native run-android run jetifier?

I've set android.useAndroidX = true and android.enableJetifier = true on gradle.properties. But when I run react-native run-android I see:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1902 file(s) to forward-jetify. Using 4 workers...

But when I change dir to android dir, and run ./gradlew assembleDebug, I didn't see such thing. Hence my build breaks everywhere where there's android.support.* library imported.

> Task :react-native-app-auth:compileDebugJavaWithJavac FAILED
.../node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/
RNAppAuthModule.java:10: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
.../node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java:11: error: cannot find symbol
import android.support.customtabs.CustomTabsCallback;
                                 ^
  symbol:   class CustomTabsCallback
  location: package android.support.customtabs
.../node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java:12: error: cannot find symbol
import android.support.customtabs.CustomTabsClient;
                                 ^
  symbol:   class CustomTabsClient
  location: package android.support.customtabs

(25 more errors)

Why is this happening? How can I fix this? Is there any way to externally force gradlew to run jetifier?

like image 794
Chen Li Yong Avatar asked Sep 17 '19 06:09

Chen Li Yong


1 Answers

I found the answer. So that your gradle build includes the jetifier-ed codes of your libraries, the step is simple.

  1. Run react-native run-android first. This will jetifier the libraries and put them in the build folder.
  2. Run ./gradlew assembleDebug. This will grab your jetifier-ed code in the build folder into APK without complaining anymore.

My case is that I run ./gradlew assembleDebug before I ever run react-native run-android after I clone the project. Deleting build folder in android folder also resulting the same situation.

like image 168
Chen Li Yong Avatar answered Oct 12 '22 00:10

Chen Li Yong