react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

Android build failed: getCurrentActivity() is not public in ReactContext

Open alprtv opened this issue 8 years ago • 5 comments

Description: Android build failed with error: getCurrentActivity() is not public in ReactContext. iOs works is fine for mu. In RN 0.56 ReactContext is public. Maybe the reason is in node_modules/react-native-onesignal/android/libs', not found but I did not find folder 'libs' in previous releases react-native-onesignal. Gradle sync was finished with warning:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Environment Android Studio 3.1.4

package.json

"react": "16.4.1",
"react-native": "0.56.0",
"react-native-onesignal": "^3.2.6"

build.gradle

ext {
    minSdkVersion = 16
    compileSdkVersion = 27
    buildToolsVersion = "27.0.3"
    targetSdkVersion = 27
    supportLibVersion = "27.1.1"
}

Steps to Reproduce Issue:

  1. react-native run-android

ERROR:

> Task :react-native-onesignal:compileDebugJavaWithJavac FAILED
Putting task artifact state for task ':react-native-onesignal:compileDebugJavaWithJavac' into context took 0.0 secs.
file or directory '/Users/purrweb/Documents/1/Demo/node_modules/react-native-onesignal/android/libs', not found
file or directory '/Users/purrweb/Documents/1/Demo/node_modules/react-native-onesignal/android/src/debug/java', not found
Up-to-date check for task ':react-native-onesignal:compileDebugJavaWithJavac' took 0.009 secs. It is not up-to-date because:
  Task has failed previously.
All input files are considered out-of-date for incremental task ':react-native-onesignal:compileDebugJavaWithJavac'.
Compiling with source level 1.7 and target level 1.7.
file or directory '/Users/purrweb/Documents/1/Demo/node_modules/react-native-onesignal/android/libs', not found
:react-native-onesignal:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
file or directory '/Users/purrweb/Documents/1/Demo/node_modules/react-native-onesignal/android/src/debug/java', not found
Compiling with JDK Java compiler API.
/Users/purrweb/Documents/1/Demo/node_modules/react-native-onesignal/android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java:111: error: getCurrentActivity() is not public in ReactContext; cannot be accessed from outside package
      Context context = mReactApplicationContext.getCurrentActivity();
                                                ^
Note: /Users/purrweb/Documents/1/Demo/node_modules/react-native-onesignal/android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

:react-native-onesignal:compileDebugJavaWithJavac (Thread[Daemon worker Thread 9,5,main]) completed. Took 0.533 secs.

FAILURE: Build failed with an exception.

alprtv avatar Sep 03 '18 06:09 alprtv

@alprtv Did you find a solution for this? I'm getting the same error in RN 0.57.0

urikphytech avatar Sep 20 '18 07:09 urikphytech

@alprtv @urikphytech found something?

dabush-eliel avatar Sep 24 '18 03:09 dabush-eliel

@dabush-eliel sorry, can't pin point what fixed it. I believe I was getting the error with a fresh 0.57.0 project, but when upgrading to my existing 0.55.4 project to 0.57.0 I didn't get it...

urikphytech avatar Sep 25 '18 03:09 urikphytech

Guys. I have same error on React-Native 0.57.0. Any solution?

mnlbox avatar Sep 25 '18 06:09 mnlbox

I do not know what was the reason, but I deleted all libs and one by one install libs again.

alprtv avatar Sep 27 '18 06:09 alprtv