React-native-geolocation-service: Androidx Fix RN 0.60, Jetifier Compliance

Created on 11 Jul 2019  路  6Comments  路  Source: Agontuk/react-native-geolocation-service

In order to support React Native 0.60, library maintainers need to upgrade their android files to support androidx. This change can make a library unusable for users who have not upgraded their own app for androidx. The consensus solution for this issue is to update the build.gradle so that a library like jetifier can replace the non-compliant code.

For this app to be jetifier compliant, the following code in build.gradle needs to change from

compileOnly('com.facebook.react:react-native:+') 

to

implementation('com.facebook.react:react-native:+') {
        exclude group: 'com.android.support'
    }

Afterwards, all users need to do is run npx jetify to update the code before running react-native run-android
The link below is an example of a successful PR implementing the above.
https://github.com/react-native-community/react-native-maps/commit/62bb953c19e55adb29200ecff9981eb5e594a7b3?diff=unified

@Agontuk could you please add these changes to your next commit? I am unable to submit a PR to address this issue myself.

Most helpful comment

I've pushed a fix for RN60 in a separate branch https://github.com/Agontuk/react-native-geolocation-service/tree/rn60-fix. Can you try and see if it works ?

All 6 comments

Same issue arises to me when I upgrade my react-native version.
This issue is arising due to react-native update for support of AndroidX

Go to
~/node_modules/react-native-geolocation-service/android/build.gradle

and do the changes on
dependencies { ... compileOnly "com.facebook.react:react-native:+" }

to

dependencies { ... implementation('com.facebook.react:react-native:+') }

I've pushed a fix for RN60 in a separate branch https://github.com/Agontuk/react-native-geolocation-service/tree/rn60-fix. Can you try and see if it works ?

I am trying to install this library and it simply crashes when build, and do not give me any error messages. I tried to install the above branch.

Thank you @Agontuk I can confirm that in my project (RN 0.60.0) this fix did make a difference (I get compile error in 2.0.1 and it compiles fine when on rn60-fix branch).

Thank you @Agontuk I can confirm that in my project (RN 0.60.0) this fix did make a difference (I get compile error in 2.0.1 and it compiles fine when on rn60-fix branch).

You can now use version 3.0.0 from npm.

Closing this since the issue is fixed in 3.0.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lyseiha picture lyseiha  路  6Comments

ravirajn22 picture ravirajn22  路  4Comments

rodrigofbm picture rodrigofbm  路  9Comments

joecaraccio picture joecaraccio  路  11Comments

lingxiao-Zhu picture lingxiao-Zhu  路  3Comments