Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Androidx instead of using support library #37

Closed
douglaszaltron opened this issue Jun 3, 2019 · 9 comments
Closed

Add support for Androidx instead of using support library #37

douglaszaltron opened this issue Jun 3, 2019 · 9 comments
Labels

Comments

@douglaszaltron
Copy link

@douglaszaltron douglaszaltron commented Jun 3, 2019

AndroidX will replace the Support Libraries.

AndroidX is the open-source project that the Android team uses to develop, test, package, version and release libraries within Jetpack.

AndroidX is a major improvement to the original Android Support Library. Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases. AndroidX fully replaces the Support Library by providing feature parity and new libraries.
See: https://developer.android.com/jetpack/androidx/

AndroidX is the replacement for Google Support Libraries. Android P is the transition phase for this. The next version of Android is likely to support only AndroidX. This library fails on android builds that use the new compileSdkVersion.

@douglaszaltron douglaszaltron changed the title feat(androidX): upgrading to sdk 28 and androidx Add support for Androidx instead of using support library Jun 3, 2019
@matt-oakes

This comment has been minimized.

Copy link
Member

@matt-oakes matt-oakes commented Jun 3, 2019

Thanks for adding these. We will do this, but we don't want to do it until it's necessary. You can read the details about why here:

react-native-community/discussions-and-proposals#129

@douglaszaltron

This comment has been minimized.

Copy link
Author

@douglaszaltron douglaszaltron commented Jun 3, 2019

@louisch

This comment has been minimized.

Copy link

@louisch louisch commented Jul 10, 2019

This is needed now for react-native 0.60. I'm getting support library errors when trying to compile with this library:

.../node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java:21: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
                                 ^
.../node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java:274: error: cannot find symbol
    int finePermission = ContextCompat.checkSelfPermission(getReactApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION);
                         ^
  symbol:   variable ContextCompat
  location: class GeolocationModule
2 errors
3 warnings

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-community_geolocation:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

    at checkExecSyncError (child_process.js:616:11)
    at execFileSync (child_process.js:634:15)
    at runOnAllDevices (.../node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (.../node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:137:41)
    at .../node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:103:12
    at processTicksAndRejections (internal/process/task_queues.js:82:5)
    at async Command.handleAction (.../node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:166:7)
@douglaszaltron

This comment has been minimized.

Copy link
Author

@douglaszaltron douglaszaltron commented Jul 10, 2019

@louisch Give a look on this repo will help you! https://github.com/mikehardy/jetifier

@msqar

This comment has been minimized.

Copy link

@msqar msqar commented Jul 24, 2019

I'm under the same issue with RN 0.60.

Do I need to upgrade to AndroidX mandatory?

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/marian-mac/Documents/dev/app/node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java:21: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
                                 ^
/Users/marian-mac/Documents/dev/app/node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java:274: error: cannot find symbol
    int finePermission = ContextCompat.checkSelfPermission(getReactApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION);
                         ^
  symbol:   variable ContextCompat
  location: class GeolocationModule
2 errors
@skippone

This comment has been minimized.

Copy link

@skippone skippone commented Jul 30, 2019

If you want to avoid using jetifier as suggested by @louisch, you can apply a patch to this package using patch-package.

The patch (for version 1.4.2) should be saved as patches/@react-native-community+geolocation+1.4.2.patch file with the following contents:

diff --git a/node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java b/node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java
index b846a447..3112e3d5 100644
--- a/node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java
+++ b/node_modules/@react-native-community/geolocation/android/src/main/java/com/reactnativecommunity/geolocation/GeolocationModule.java
@@ -18,7 +18,7 @@ import android.location.LocationProvider;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
-import android.support.v4.content.ContextCompat;
+import androidx.core.content.ContextCompat;
 import com.facebook.common.logging.FLog;
 import com.facebook.react.bridge.Arguments;
 import com.facebook.react.bridge.Callback;

Personally I do not understand why this package, which was actually removed from RN 0.60 as part of Lean core effort, does not support AndroidX out of the box. It just does not make sense since RN 0.60 actually requires AndroidX.

@msqar

This comment has been minimized.

Copy link

@msqar msqar commented Jul 30, 2019

I made it work yesterday! had to manually install every dependency from react-native-community, including this one, async-storage, etc. Took me like 1 week to make my app work on RN 0.60. Thanks!

@karltaylor

This comment has been minimized.

Copy link

@karltaylor karltaylor commented Aug 13, 2019

As @douglaszaltron said here #37 (comment). Running npx jetify before running ./gradlew assembleRelease resulted in a successful build.

But I agree with @skippone. I would prefer to avoid patch-package. I am confused why you don't want to support AndroidX out of the box. Confused and curious 😊 can you explain why?

@janicduplessis

This comment has been minimized.

Copy link
Collaborator

@janicduplessis janicduplessis commented Aug 18, 2019

Published version 2.0.2 that supports RN 0.60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.