Coder Social home page Coder Social logo

Comments (9)

louisch avatar louisch commented on August 25, 2024 6

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)

from react-native-geolocation.

douglaszaltron avatar douglaszaltron commented on August 25, 2024 5

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

from react-native-geolocation.

matt-oakes avatar matt-oakes commented on August 25, 2024 4

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

from react-native-geolocation.

skippone avatar skippone commented on August 25, 2024 3

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.

from react-native-geolocation.

msqar avatar msqar commented on August 25, 2024 1

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!

from react-native-geolocation.

janicduplessis avatar janicduplessis commented on August 25, 2024 1

Published version 2.0.2 that supports RN 0.60

from react-native-geolocation.

douglaszaltron avatar douglaszaltron commented on August 25, 2024

Tks! @matt-oakes

from react-native-geolocation.

msqar avatar msqar commented on August 25, 2024

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

from react-native-geolocation.

karltaylor avatar karltaylor commented on August 25, 2024

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?

from react-native-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.