Giter VIP home page Giter VIP logo

Comments (25)

Bua-C avatar Bua-C commented on June 26, 2024 7

if you have the same problem with me

> Task :@react-native-community_netinfo:compileDebugJavaWithJavac FAILED C:\Users\Com02\Desktop\GTD SHOPS\node_modules\@react-native-community\netinfo\android\src\main\java\com\reactnativecommunity\netinfo\ConnectivityReceiver.java:14: error: package android.support.v4.net does not exist import android.support.v4.net.ConnectivityManagerCompat; ^ C:\Users\Com02\Desktop\GTD SHOPS\node_modules\@react-native-community\netinfo\android\src\main\java\com\reactnativecommunity\netinfo\ConnectivityReceiver.java:78: error: cannot find symbol promise.resolve(ConnectivityManagerCompat.isActiveNetworkMetered(getConnectivityManager())); ^ symbol: variable ConnectivityManagerCompat location: class ConnectivityReceiver 2 errors
how to fix it
npx jetify
in project folder
and run the project
npx jetify

from react-native-netinfo.

presencewebdesign avatar presencewebdesign commented on June 26, 2024 5

After I have migrated to AndroidX and install react-native-community/netinfo

I get the following error when I build

image

I've obviously not setup something correctly but not sure what it could be?
@matt-oakes you mention running a command after an npm install, what is the command?

I have added the following if that's what you mean

android.enableJetifier=true
android.useAndroidX=true

This has nothing to do with it however thought I would let you know. I noticed when you run the command react-native link @react-native-community/netinfo

This creates an entry in the android/settings.gradle like this

include ':@react-native-community_netinfo'
project(':@react-native-community_netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')

However in the documentation it says to add it like this

include ':react-native-community-netinfo'
project(':react-native-community-netinfo').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/netinfo/android')

from react-native-netinfo.

matt-oakes avatar matt-oakes commented on June 26, 2024 3

👋 Thanks for the extra information.

  1. Can you confirm if you followed the full instructions to migrate to AndroidX here: https://developer.android.com/jetpack/androidx/migrate
  2. Please provide the full contents of android/settings.gradle, android/build.gradle and android/app/build.gradle.

from react-native-netinfo.

matt-oakes avatar matt-oakes commented on June 26, 2024 1

Sorry, I should have asked for you gradle.propertiestoo. It should include these lines:

android.useAndroidX=true
android.enableJetifier=true

If converting back to non-AndroidX is fixing the issue, it sounds like you are not setting up Jetifier correctly. This is the Android build tool which translates any transient dependencies on the old support library to the new AndroidX variants, as described here. If this library is not working when you're making the change, then it's likely that Jetifier is not set up correctly.

Just to note though, that I've not yet tried this process myself, so I could be mistaken. This is based off the reading of the migration document from Google.

I'm going to close this issue now, but I'll look into converting this library to AndroidX.

from react-native-netinfo.

jamesmcn1 avatar jamesmcn1 commented on June 26, 2024 1

@matt-oakes @mikehardy I re ran npx jetifier and it built successfully locally and on CI which is great. Thanks for this useful tool - great work!

My only concern is that It is not ideal to keep running this tool on every yarn or deployment on CI. I guess the only solution is to wait for various package dependencies to migrate over to the new mappings.

I see theres an outstanding PR (https://github.com/react-native-community/react-native-netinfo/pull/115/files) to replace import android.support.v4.net.ConnectivityManagerCompat. This is the last package giving me problems so I hope once this is released, i can remove the npx jetifier step.

Big thanks again guys for all your time and effort :)

from react-native-netinfo.

SiyabongaNzulwana avatar SiyabongaNzulwana commented on June 26, 2024 1

Hi guys, has anyone found a solution to this error? error: package android.support.v4.net does not exist error: cannot find symbol variable ConnectivityManagerCompat

from react-native-netinfo.

rogueturnip avatar rogueturnip commented on June 26, 2024

I have gone through the migration steps, I believe it's all correct. Here are the file contents:

settings.gradle.txt
build.gradle.txt
app-build.gradle.txt

from react-native-netinfo.

rogueturnip avatar rogueturnip commented on June 26, 2024

I've tried a few other things. Given the error was for ConnectivityManagerCompat I tried adding support-compat and also androidx.core to the app/build.gradle. Still didn't do anything, it can't find the library.

from react-native-netinfo.

rogueturnip avatar rogueturnip commented on June 26, 2024

So the source of my problems seems to be that the @react-native-communit/slider module requires the root supportLibVersion to be an androidx version. This seems to break things with other apps (specifically netinfo using the support libs).

I'm rolling back things to see if this fixes the problems.

from react-native-netinfo.

rogueturnip avatar rogueturnip commented on June 26, 2024

I rolled back @react-native-community/slider to 1.0.4 which didn't include androidx and fixed up a few other items related to running the migration and I'm building again.

from react-native-netinfo.

ryanlntn avatar ryanlntn commented on June 26, 2024

I'm getting this same error but I'm not using AndroidX. For me it shows up when I add @react-native-firebase/[email protected] to the project.

from react-native-netinfo.

betko avatar betko commented on June 26, 2024

Hi @ryanlntn ! I faced up the same issue like you. After I added the latest alpha version of the @react-native-firebase/app I got the same error message. Did you find any solution for this issue?

from react-native-netinfo.

ryanlntn avatar ryanlntn commented on June 26, 2024

@betko I just ended up downgrading to 5.x for now. I'll likely give it another go once it's out of alpha.

from react-native-netinfo.

ThomasStubbe avatar ThomasStubbe commented on June 26, 2024

I got exactly the same issue. Needed to update to androidX because of react-native-video.

from react-native-netinfo.

brenohq avatar brenohq commented on June 26, 2024

same error

from react-native-netinfo.

matt-oakes avatar matt-oakes commented on June 26, 2024

A tool has been built which might help with these issues. Can you all have a look at the instructions here and let me know if it fixes the issue for you:

https://github.com/mikehardy/jetifier#usage-for-source-files

from react-native-netinfo.

jamesmcn1 avatar jamesmcn1 commented on June 26, 2024

Same issue for me - I just migrated to compileSdkVersion 28 for react-native-video. I've successfully migrated the project across to android X and this appears to be the last barrier to a successful build (for now at least). Im using react-native 0.57.8 and and react-native-netinfo 2.0.10.

@matt-oakes I've tried using the steps on jetifier without success. Any ideas?

Build.gradle:

buildscript {
    ext {
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

from react-native-netinfo.

matt-oakes avatar matt-oakes commented on June 26, 2024

@jamesmcn1 Make sure you run the Jetifier command after every npm install or yarn add. It changes the files in your node_modules and running those will override it changes.

You can also run ./gradlew app:dependencies in your android folder to see what dependencies you have. You can search for "androidx" and "support" to see if there is still a mixture of both.

It's possible that the Jetifier tool is not working for you as it's pretty experimental. If it doesn't work for one of the libraries you use, you can open an issue on the dependency over there and @mikehardy will take a look.

from react-native-netinfo.

mikehardy avatar mikehardy commented on June 26, 2024

So I don't get buried, I added a troubleshooting section on jetifier: https://github.com/mikehardy/jetifier#troubleshooting - there are a couple of classes of issue that will always be problems in the underlying libraries, and you'll need to open pull requests with them - please use that section before opening jetifier issues.

I recommend running jetify as a postinstall hook (after patch-package if you use it) so you don't forget to re-apply

from react-native-netinfo.

mikehardy avatar mikehardy commented on June 26, 2024

As of yesterday jetifier has a reverse mode, which gives libraries like this an avenue to support their support-library users (via education to use jetifier -r, mostly) without branching. So libraries should be able to "safely" convert at this point. "Safely" is in scare-quotes because there will be inevitable github issues as library consumers require education

from react-native-netinfo.

mikehardy avatar mikehardy commented on June 26, 2024

I am familiar with that error.
Without details I'd only be speculating on why you're getting it.
Are you still on support libraries and using jetifier -r, or are you AndroidX and your dependencies are messed up? No idea

from react-native-netinfo.

SiyabongaNzulwana avatar SiyabongaNzulwana commented on June 26, 2024

I am familiar with that error.
Without details I'd only be speculating on why you're getting it.
Are you still on support libraries and using jetifier -r, or are you AndroidX and your dependencies are messed up? No idea

@mikehardy our project is using androidX and the dependancies seems to be messed up, some use andoidX, some don't.

from react-native-netinfo.

mikehardy avatar mikehardy commented on June 26, 2024

Okay, then you've got to get them all aligned, and pointed to AndroidX. There are a bunch of ways that can go wrong, but in general you can diagnose by running cd android && ./gradlew :app:dependencies and examining the output to see what module is calling in the support library, then investigating that module to see how you can make it stop doing that. This is out of scope for netinfo though I think - it should be working here...

from react-native-netinfo.

matt-oakes avatar matt-oakes commented on June 26, 2024

Yes. This library has been updated to work with AndroidX. The issue is likely coming from another library which has not been updated.

from react-native-netinfo.

Bua-C avatar Bua-C commented on June 26, 2024

sorry ***

Run the project

react-native run-android

from react-native-netinfo.

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.