Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

error: cannot find symbol import android.support.v4.app.ActivityCompat #335

Open
LydiaF opened this issue Jul 20, 2019 · 15 comments
Open

error: cannot find symbol import android.support.v4.app.ActivityCompat #335

LydiaF opened this issue Jul 20, 2019 · 15 comments

Comments

@LydiaF
Copy link

LydiaF commented Jul 20, 2019

Version

Tell us which versions you are using ( you can see the versions in your package.json ):

react-native-audio : 4.3.0
react-native : 0.60.4
react : 16.8.6
using react-native-sound ? No

Expected behaviour :

gradlew assembleRelease builds the Android project.

Actual behaviour

Project build fails with this error:

> Task :react-native-audio:compileReleaseJavaWithJavac FAILED
/Users/xxxx/Code/xxxx/xxxx/node_modules/react-native-audio/android/src/main/java/com/rnim/rn/audio/AudioRecorderManager.java:30: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
                             ^
  symbol:   class ActivityCompat
  location: package android.support.v4.app
/Users/xxxx/Code/xxxx/xxxx/node_modules/react-native-audio/android/src/main/java/com/rnim/rn/audio/AudioRecorderManager.java:31: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
                                 ^
/Users/xxxx/Code/xxxx/xxxx/node_modules/react-native-audio/android/src/main/java/com/rnim/rn/audio/AudioRecorderManager.java:105: error: cannot find symbol
    int permissionCheck = ContextCompat.checkSelfPermission(getCurrentActivity(),
                          ^
  symbol:   variable ContextCompat
  location: class AudioRecorderManager
3 errors

Steps to reproduce

  1. Create a react native (v0.60.4) project
  2. Install react-native-audio
  3. Build the Android project: cd android && ./gradlew assembleRelease
@TNChalise
Copy link

Can anyone suggest the fix ? Going through same problem.

@jakehon1993
Copy link

jakehon1993 commented Jul 22, 2019

global search and replace "android.support.v4.content.ContextCompat" by "androidx.core.app.ActivityCompat"

@TNChalise
Copy link

Is it good to migrate to AndroidX ?

@deepakpapola
Copy link

@LydiaF did you fixed it

@arrygoo
Copy link

arrygoo commented Jul 29, 2019

I have the same issue

@LydiaF
Copy link
Author

LydiaF commented Jul 30, 2019

@deepakpapola Unfortunately not.

@arrygoo
Copy link

arrygoo commented Jul 30, 2019

@deepakpapola @LydiaF try npx jetify before running your app, seems to fix the issue for now (you need to install it as a local dependency first)

@kiran-mantana
Copy link

Any Update on this issue, Facing the same issue in 0.59.1

@narek11
Copy link

narek11 commented Aug 15, 2019

same issues here with RN 0.59.2 and react-native-audio 4.1.3

@DaveLomber
Copy link

@jakehon1993 many libs have a support for RN60 and still use support v4, so the issues is not with this

@ntkzwane
Copy link

ntkzwane commented Sep 24, 2019

I also experienced this, but only when building using gradle directly (running react-native run-android built successfully without issues. I realised this is because run-android runs jetify as part of the build. If you're using ./gradlew assembleRelease, you need to run manually

npx jetify

or if you're using yarn

yarn jetify

or straight up

./node_modules/.bin/jetify

just before you build the project.

@LucasMonteiro1
Copy link

Maybe PR #330 fixes that

@xgAnd
Copy link

xgAnd commented Nov 21, 2019

this reason is migrate to AndroidX.you can annotation the error import.most condition the IDE can import the right package.but sometimes if the module has more than one package the IDE can't import.you just select the module which is androidx is right.

@dnazirso
Copy link

dnazirso commented Jan 3, 2020

As mentioned by @xgAnd , if in some way you choose to migrate to AndroidX, you need to select the corresponding module in which case you have to
replace :
import android.support.v4.app.NotificationCompat;
with :
import androidx.core.app.NotificationCompat;
and i assume it is the case everywhere you used to import android.support.v4. modules

@AliRehman7141
Copy link

android.support.v4.content.ContextCompat

I didn't found any

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests