React-native-navigation: Migrate to androidx

Created on 18 Apr 2019  路  19Comments  路  Source: wix/react-native-navigation

Issue Description

Hey,
I am integrating react-native in an existing android project which is build using AndroidX lib instead of the android support library. I am getting below error while building project

Task :react-native-navigation:compileReactNative57_5DebugJavaWithJavac FAILED
/Users/anshul/Documents/work/winzoReactWinzo/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/anim/NavigationAnimator.java:7: error: package android.support.annotation does not exist
import android.support.annotation.RestrictTo;

Environment

  • React Native Navigation version: "^2.17.0-snapshot.282",
  • React Native version: ^0.59.5
  • Platform(s) Android
  • Device info Google Pixel
Android accepteenhancement

Most helpful comment

Alright published 3.0.0-alpha.8, try it 馃憤

All 19 comments

I have the same issue

Same here

Same here, this is what happens after AndroidX merge.

I've tried replacing the android packages with androidx packages but there's so many there's no way I'm doing that

EDIT: Worth mentioning that it works on my Mac which has not been merged to AndroidX yet, this on the Windows machine which has been merged unfortunately.

EDIT2: A few packages in my setup seem to respond negatively to the merge, I guess since most of the old packages don't know which the new packages are so they can't be replaced when refactoring and therefore we are having this problem

androidx

I'm having the same issue. I'm trying to use react-native-navigation and react-native-camera and I'm no able to build because react-native-camera is using AndroidX.
Is there any solution to use while native-navigation is not AndroidX yet?

I'm having the same issue. I'm trying to use react-native-navigation and react-native-camera and I'm no able to build because react-native-camera is using AndroidX.
Is there any solution to use while native-navigation is not AndroidX yet?

Hey, my app is also using it but as far as I'm aware there is not a problem with that package.

It should be possible as a _temporary_ solution to
A. Just remove all of react-native-navigation and replace it with react-navigation
B. Find a fork that works for AndroidX (I've also tried this but it didn't help in my case.)

Of course that would mean you would have to replace all of the react-native-navigation code with code that works for react-navigation

EDIT: I believe the problem lies in the fact that Android Studio offers a way to migrate the project to AndroidX but they don't offer a way to revert this process which leaves your project in a locked state if one of the packages don't support AndroidX yet

@Lakeyour even as a temporary measure this is not a good solution.

Has anyone had a look at https://github.com/mikehardy/jetifier#usage-for-source-files

It converts all your dependancies to androidx, I am still having problems building the project but it has worked for some and can work for others, try npm i jetifier && npx jetify

@Lakeyour even as a temporary measure this is not a good solution.

Has anyone had a look at https://github.com/mikehardy/jetifier#usage-for-source-files

It converts all your dependancies to androidx, I am still having problems building the project but it has worked for some and can work for others, try npm i jetifier && npx jetify

I haven't tried jetifier, I simply went over to my mac and continued my work there since the mac hadn't been merged to AndroidX yet so there was no problem there.

Although thanks for mentioning it.

You can also try @jumpn/react-native-jetifier, just ping me if you have any issues integrating it (I'm the author)

We've officially migrated to RN 0.60 and AndroidX in version 3 which is now in alpha. You're more than welcome to try it and report any issues - 3.0.0-alpha.2. If there no issues are reported, I'll publish it next week.

Having the same issue at the moment, will give 3.0.0-alpha.2 a go and let you know how I get on @guyca .

@dooleyb1 Try 3.0.0-alpha.6 instead

@guyca Using 3.0.0-alpha.6 now, app builds successfully using npx jetify && npm run android. However, when I try to launch the app on an emulator it crashes upon startup (after loading files from Metro Bundler).

From further debugging using adb logcat I have found the following error that seems to be relating to react-native-navigation.

07-24 09:33:24.516  4194  4194 E AndroidRuntime: Process: com.bounce.bounceapp, PID: 4194
07-24 09:33:24.516  4194  4194 E AndroidRuntime: java.lang.NullPointerException: Attempt to read from field 'com.reactnativenavigation.parse.TopBarOptions com.reactnativenavigation.parse.Options.topBar' on a null object reference

Have this problem too.
I'm trying to run on the device and get the error:

java.lang.NullPointerException: Attempt to read from field 'com.reactnativenavigation.parse.TopBarOptions com.reactnativenavigation.parse.Options.topBar' on a null object reference
 at com.reactnativenavigation.parse.Options.withDefaultOptions(Options.java:94)
 at com.reactnativenavigation.presentation.StackPresenter.applyInitialChildLayoutOptions(StackPresenter.java:128)
 at com.reactnativenavigation.viewcontrollers.stack.StackController.addInitialChild(StackController.java:340)
 at com.reactnativenavigation.viewcontrollers.stack.StackController.createView(StackController.java:332)
 at com.reactnativenavigation.viewcontrollers.stack.StackController.createView(StackController.java:40)
 at com.reactnativenavigation.viewcontrollers.ViewController.getView(ViewController.java:171)
 at com.reactnativenavigation.viewcontrollers.ChildController.getView(ChildController.java:33)
 at com.reactnativenavigation.viewcontrollers.ParentController.getView(ParentController.java:75)
 at com.reactnativenavigation.viewcontrollers.navigator.RootPresenter.setRoot(RootPresenter.java:37)
 at com.reactnativenavigation.viewcontrollers.navigator.Navigator.setRoot(Navigator.java:136)
 at com.reactnativenavigation.react.NavigationModule.lambda$setRoot$0$NavigationModule(NavigationModule.java:91)
 at com.reactnativenavigation.react.-$$Lambda$NavigationModule$t-qP4peMa7q7-e5wwxed0CVSRl4.run(Unknown Source:8)
 at android.os.Handler.handleCallback(Handler.java:873)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:201)
 at android.app.ActivityThread.main(ActivityThread.java:6810)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Yesterday on alfa.4 worked fine

@guyca do you have any idea what might be causing this? Seems to be others experiencing the same issue. It's preventing us building our Android version. Thanks! 馃槃

Checking

@JerakRus @dooleyb1 Fixed in 3.0.0-alpha.7

@guyca Unreal, thank you! Will let you know how the update get's on.

Alright published 3.0.0-alpha.8, try it 馃憤

@guyca It's good news, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yayanartha picture yayanartha  路  3Comments

yedidyak picture yedidyak  路  3Comments

bdrobinson picture bdrobinson  路  3Comments

tmaly1980 picture tmaly1980  路  3Comments

henrikra picture henrikra  路  3Comments