React-native: Android java.lang.IllegalAccessError Method void android.support.v4.net.ConnectivityManagerCompat

Created on 25 Feb 2016  ·  96Comments  ·  Source: facebook/react-native

It appears that the NetInfo Module is trying to access ( com.facebook.react.modules.netinfo.NetInfoModule ) ConnectivityManagerCompat ( java.lang.IllegalAccessError: Method 'void android.support.v4.net.ConnectivityManagerCompat ) method of android support lib v4 and that method is private?
java.lang.IllegalAccessError: Method 'void android.support.v4.net.ConnectivityManagerCompat. I am using RN .18, so I am not sure if this is not an issue in RN .20, but I wanted to post it just incase someone else is running across this issue. Stack Trace :8ball:

Also I do have the network permission in the manifest.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

02-25 10:51:50.355 23140-23174/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4 Process: package.name, PID: 23140 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:307) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.net.ConnectivityManagerCompat.<init>()' is inaccessible to class 'com.facebook.react.modules.netinfo.NetInfoModule' (declaration of 'com.facebook.react.modules.netinfo.NetInfoModule' appears in /data/app/package.name-2/base.apk) at com.facebook.react.modules.netinfo.NetInfoModule.<init>(NetInfoModule.java:55) at com.facebook.react.shell.MainReactPackage.createNativeModules(MainReactPackage.java:62) at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:751) at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:688) at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:84) at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:177) at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:162) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:818) ```

Help Wanted Locked

Most helpful comment

com.android.support:appcompat-v7:23.2.1 change to com.android.support:appcompat-v7:23.0.1, fixed it

All 96 comments

I am also hitting this error when I try to run my app on android. The app crashes right after fetching the js bundle. Running on iOS has no problems.

Even checking out older versions of my app that are deployed and working in production still does not fix the issue, I simply cannot run android! Strangely, one of my co-workers has no problems running android. Also, if I react-native init a brand new project it also has no problems running on android. I'm completely mystified as to what could be going on.

I've included logcat output if that helps. It appears to be hitting the same error as described by @tuneZola :

02-27 23:08:42.546  1721  1747 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
02-27 23:08:42.546  1721  1747 E AndroidRuntime: Process: com.chillinmobile, PID: 1721
02-27 23:08:42.546  1721  1747 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at android.os.AsyncTask$3.done(AsyncTask.java:309)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)
02-27 23:08:42.546  1721  1747 E AndroidRuntime: Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.net.ConnectivityManagerCompat.<init>()' is inaccessible to class 'com.facebook.react.modules.netinfo.NetInfoModule' (declaration of 'com.facebook.react.modules.netinfo.NetInfoModule' appears in /data/app/com.chillinmobile-1/base.apk)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.modules.netinfo.NetInfoModule.<init>(NetInfoModule.java:55)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.shell.MainReactPackage.createNativeModules(MainReactPackage.java:67)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:793)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:730)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:91)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:184)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:169)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at android.os.AsyncTask$2.call(AsyncTask.java:295)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-27 23:08:42.546  1721  1747 E AndroidRuntime:    ... 4 more

I am also hitting this error

I found this issue only after I updated com.android.support:appcompat-v7 from 23.1.1 to 23.2.0 in app/build.gradle

@pdiaz Interesting! I had com.android.support:appcompat-v7:23.0.1 listed in my app/build.gradle dependencies. I tried updating that to 23.1.1 to see if that would help resolve my issue, but unfortunately I am still getting the crash caused by the IllegalAccessError

@pdiaz I noticed that also with the support version update, but I didn't want to have a specific build version dependency. Most people have something like this in there dependency list "com.android.support:support-v4:23.+". Also, this is an issue that will start to show up for more people once they upgrade or use RN for the first time. Changing to a specific build version is just a temporary solution.

I has same problem when i upgrade android support package to 23.2

+1 Tried with android support package v23.1 & v23.2

cc @bestander

The issue is that the ConnectivityManagerCompat constructor is now private in version 23.2

Oh snap, I'll look into that tomorrow

+1 same issue here

+1 same issue here

Has anyone been able to fix the issue by changing their version of the android support package? I cannot get around the issue no matter which version I use (23.0.1, 23.1, 23.2)

@Traviskn No, I was not able to fix it either by specifying those earlier version. I did a gradle clean, but it still seems to import the new version. I think its because I have other dependencies like the FB SDK that always imports the latest.

If you are using the react-native-dialogue module the material-dialogue dependency will not compile without support v23.2. (all their tags point to the latest commit).

to property downgrade your support version download this https://dl-ssl.google.com/android/repository/support_r23.0.1.zip and extract it into $ANDROID_HOME/extras/android/support

One temporary fix you can do is exclude the package from your other dependencies in your app/gradle.build. This is an example of ours.

dependencies {
    // INCLUDE THE SUPPORT VERSION YOU WANT TO USE
    compile "com.android.support:support-v4:23.0.1"
    // EXCLUDE IT FROM THE REST
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile ( project(':RNWebView') ) { exclude module: 'support-v4' }
    compile ( project(':Orientation') ) { exclude module: 'support-v4' } 
    compile ( project(':react-native-google-analytics-bridge') ) { exclude module: 'support-v4' }
    compile "com.facebook.react:react-native:0.18.+"
    compile ( "com.facebook.android:facebook-android-sdk:4.+" ) {
        exclude module: 'bolts-tasks'
        exclude module: 'bolts-applinks'
        exclude module: 'support-v4'
    }
}

You should be able to go to your android folder and run

./gradlew app:dependencies

and all of the support packages should be listed as version 23.0.1. You might have to be a clean before that.

@Anthonyzou we don't instantiate ConnectivityManagerCompat, so constructor visibility should not make a difference.
But anyway, I am debugging this

Looks like it is a breaking change in android support library.
We don't have capacity to fix this right now, a Pull Request with a fix that would work both for 23.1 and 23.2 would be very much appreciated.
Otherwise please post / vote on it at https://productpains.com/product/react-native. This way the most important issues for the community get surfaced.

@tuneZola Using a resolutionStrategy is a cleaner approach to force the version across all sub-projects.

subprojects {
  configurations.all {
    resolutionStrategy {
      // https://github.com/facebook/react-native/issues/6152
      force 'com.android.support:support-v4:23.0.1'
    }
  }
}

Closing based on @astuetz's comment. Let's reopen of its still not working

@astuetz @satya164 This is great news! Do you know what version of react native that fix will be available in?

@Traviskn It's fixed in 0.22.0-rc already :)

@knowbody I think the fix for this Android-specific bug should be included in the 0.22.0-rc release notes as well. (Although the commit message doesn't really sound like a major bugfix)

@astuetz done

@knowbody thanks! :)

where can I find 0.22-rc? Doesn't seem to be on maven central, jcenter or sonatype snapshots

The jars are now included in the npm package.
just npm install [email protected]

thanks. btw the version is 0.22.0-rc4, I was able to use by copying it out from the android subdirectory into my local ~/.m2 maven repo

I have upgraded to [email protected]. But I am still facing this issue.

The fix in [email protected] worked for me. Thanks to whomever fixed it for the timely fix!

Sent from my iPhone

On Mar 21, 2016, at 4:01 AM, shraddha1704 <[email protected]notifications@github.com> wrote:

I have upgraded to [email protected]:[email protected]. But I am still facing this issue.

You are receiving this because you commented.
Reply to this email directly or view it on GitHubhttps://github.com/facebook/react-native/issues/6152#issuecomment-199163814

com.android.support:appcompat-v7:23.2.1 change to com.android.support:appcompat-v7:23.0.1, fixed it

when intergrating with android project, only "compile 'com.facebook.react:react-native:0.20.+'" works.

I'm on [email protected], gradle dependency : 'com.facebook.react:react-native:0.20.+' and appcompat: 'com.android.support:appcompat-v7:23.2.0'. Still getting this error while trying to integrate into existing app.

same issue as @sarajmunjal

@sarajmunjal @jjding1986 you have to either use the com.facebook.react:react-native:+ dependency or manually change the dependency to the exact version of React Native you have defined in your package.json like com.facebook.react:react-native:0.22.2

thanks @astuetz ,but it does not resolve my problem.
I resolve it by adding:
subprojects { configurations.all { resolutionStrategy { // https://github.com/facebook/react-native/issues/6152 force 'com.android.support:support-v4:23.0.1' } } }
to my project build.gradle just as @ben-manes posted

@jjding

I solve this problem by remove _NetInfoModule_ when init time in _MainReactPackage_ (extends this class), cause I don't need this native module im my usage

@jjding1986 @chujj Both solutions are definitely not ideal. I just created a new project using React Native 0.22.2 and AppCompat 23.2.0, worked without any problems.

Make sure you're really up-to-date with your React Native dependency, you can either just check the contents of the following folder:
node_modules/react-native/android/com/facebook/react/react-native/
and see if the name of the folder in there matches the version of React Native you're using (has to be >= 0.22.0-rc)
or you just run rm -rf node_modules/ and npm install again

One more thing you could try is clearing your gradle caches. you can find the folder in your home directory:
On Windows: %USER_HOME%.gradle/caches
On Mac/Unix: $HOME/.gradle/caches/

thanks for your patience @astuetz.
the latest version I can get from maven central is 0.20.1, so I used

compile 'com.facebook.react:react-native:0.20.1' 

in module(this module has one Activity that uses React Native) 's build.gradle, and my package.json looks like this

"dependencies": {
    "react": "^0.14.8",
    "react-native": "^0.23.0"
  }

and the folder in node_modules/react-native/android/com/facebook/react/react-native/ is 0.23.0.

I also defined

libSupportV4 = 'com.android.support:support-v4:23.2.1'
libRecyclerView = 'com.android.support:recyclerview-v7:23.2.1' 
libSupportAnnotation = 'com.android.support:support-annotations:23.2.1' 

in my project's build.gradle and use them in other sub modules under the project, and I met this issue.

when I add

subprojects {
    configurations.all {
        resolutionStrategy {
            // https://github.com/facebook/react-native/issues/6152
            force 'com.android.support:support-v4:23.0.1'
        }
    }
}

into my project's build.gradle, the issue gone.
I also created a new simple project using React Native with

compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.facebook.react:react-native:0.20.1'

in my app's build.gradle, and react-native is the only 3rd-party dependency imported in it.

and

"dependencies": {
    "react": "^0.14.8",
    "react-native": "^0.22.2"
  }

in package.json, everything is ok.

I think my issue maybe caused by other 3rd-party libs which reference support-v4.

@astuetz I tried in a fresh project with latest versions for both node and gradle dependencies. Still getting the same error. Seems to work only if I downgrade android support lib version to 23.0.1 .

@jjding1986 you shouldn't use the react native dependency hosted on Maven Central any more, as the version there won't be updated any more.
Instead, the aar (android lib) is now distributed directly with the react-native npm package, that's what the node_modules/react-native/android/com/facebook/react/react-native/ folder is for. It contains a local maven repository, which always has the latest react native aar inside. (in your case 0.23.0)
So try to change compile 'com.facebook.react:react-native:0.20.1' to compile 'com.facebook.react:react-native:0.23.0'
Also, make sure that in your root gradle file (build.gradle inside your projects' android folder) contains the following lines:
https://github.com/facebook/react-native/blob/master/local-cli/generator-android/templates/src/build.gradle#L19-L22

This worked finally! Thanks a lot @astuetz for your help and your patience :)

PS:I think it makes sense to update this page: https://facebook.github.io/react-native/docs/embedded-app-android.html#content with some information about the local maven repository. I wish to raise a PR to update this documentation. Should I do it right away or file a separate issue to track this and then follow up with the PR?

Go with pr directly

On Wednesday, 13 April 2016, Saraj Munjal [email protected] wrote:

This worked finally! Thanks a lot @astuetz https://github.com/astuetz
for your help and your patience :)

PS:I think it makes sense to update this page:
https://facebook.github.io/react-native/docs/embedded-app-android.html#content
with some information about the local maven repository. I wish to raise a
PR to update this documentation. Should I do it right away or file a
separate issue to track this and then follow up with the PR?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/facebook/react-native/issues/6152#issuecomment-209677515

I think @Kennytian is right, this only works if you set compile 'com.android.support:appcompat-v7:23.0.1' and use compile 'com.facebook.react:react-native:+'. If you try to use version 23.4.0 or 23.3.0 it does not work.

@astuetz : Hi Andreas, sorry for tagging you explicitly, but could you place take a look at this issue https://github.com/facebook/react-native/issues/7751 once..
Thanks in advance,
Regads,
Vishal

Oh, My God!
The problem has been bothering me for a day. I tried all the ways,I found my 'Extra' need to update!!! Repalce or update this file

image

 everything is ok! and I still love react-native 

Had this problem today, it turns out that I was using reactnative 0.20.1 from a remote maven repo instead of the one in node_modules. Using 0.28.0 fixed it.

i fix using 0.28.0

I change the compile lib:
compile 'com.android.support:appcompat-v7:23.0.1'

I am still facing this issue for:

build.gradle:

compile 'com.android.support:appcompat-v7:23.0.1'
com.facebook.react:react-native:+

Package.json:
"dependencies": {
"react-native": "^0.30.0"
}

Please help!

@sandyjoins02 Can I suggest to use compile "com.facebook.react:react-native:0.30.0" instead? This should ensure the correct version is used.

Its telling failed to resolve com.facebook.react:react-native:0.28.0

On Tue, Aug 2, 2016 at 3:08 PM, Wang Guan [email protected] wrote:

@sandyjoins02 https://github.com/sandyjoins02 Can I suggest to use compile
"com.facebook.react:react-native:0.30.0" instead? This should ensure the
correct version is used.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/6152#issuecomment-236854231,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALMwcEOJbkKJ9TJHRQ4PPtr99fxbTB2Qks5qbw__gaJpZM4HjE37
.

@sandyjoins02 try to update Android SDK , maybe the extra is too old

the same issue as @sandyjoins02 has described above

Can some one kindly suggest exact configurations, I have already invested couple of days working around, no luck yet.

@sandyjoins02, stackoverflow would be a better place to get help about proper configuration.

which version can solve this issue? if I dont want to use 23.0.1 ?

Having the same issues as above, nothing seems to fix. @sandyjoins02 @lagner @echodjb have you found a fix?

I have the same issue here! Tried all the solutions above and still the error appears.... Need Help!!

@IriscShih I found out my issue was because I was forking react-native and not properly building it back out.

I am getting the same issue. The only solution is in my Android application revert back the support library to the version the version 23.0.1? My app currently uses the 24.2.1 version of the support library, so reverting to 23.0.1 is not an easy/feasible solution.

I am trying to integrate React Native with my current application. I am following these instructions, but I am getting this error when I try to start the activity with the native code.

 Theme: themes:{default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com.android.systemui.navbar=overlay:system}
 java.lang.RuntimeException: An error occurred while executing doInBackground()
     at android.os.AsyncTask$3.done(AsyncTask.java:309)
     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
     at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
     at java.util.concurrent.FutureTask.run(FutureTask.java:242)
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
     at java.lang.Thread.run(Thread.java:818)
  Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.net.ConnectivityManagerCompat.<init>()' is inaccessible to class 'com.facebook.react.modules.netinfo.NetInfoModule' (declaration of 'com.facebook.react.modules.netinfo.NetInfoModule' appears in /data/app/*****.debug-2/base.apk)
     at com.facebook.react.modules.netinfo.NetInfoModule.<init>(NetInfoModule.java:55)
     at com.facebook.react.shell.MainReactPackage.createNativeModules(MainReactPackage.java:67)
     at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:793)
     at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:730)
     at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:91)
     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:184)
     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:169)
     at android.os.AsyncTask$2.call(AsyncTask.java:295)
     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
     at java.lang.Thread.run(Thread.java:818) 

TL;DR: Check that react native is being fetched from node_modules, not maven central or otherwhere.

I was scratching my head over why I was still getting this issue, checked and double-checked my dependency in package.json, checked the actual folder in "node_modules/react-native/android/com/facebook/react/react-native", until I glanced at the breadcrumbs while inspecting NetInfoModule in android studio: whaddaya know! 0.20.1. Oh right! React native 0.20.1 is still accessible on jcenter, and I had jcenter defined before node_modules in my repositories.

Same here, one thing to help debug is specify the version in the build.gradle file when importing the React Native. Since the latest version are not in Maven central it will throw an error.

I'm getting the exact same problem as @SandroMachado

@LiamInJapan did you try to specify the version in the app\build.gradle?

android {
compileSdkVersion 23
buildToolsVersion "24.0.3"

defaultConfig {
    applicationId "xxxx"
    minSdkVersion 18
    targetSdkVersion 23

Replace:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

by

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.37"  // From node_modules
}

@SandroMachado Below Change:

compile "com.facebook.react:react-native:0.37" // From node_modules

Not able to resolve dependency, here is the error:

Error:Failed to resolve: com.facebook.react:react-native:0.37

I am trying to integrate with existing project using v24 of support libs and downgrading libs is not an option.

@ishan-dhingra you find your issue. You are not importing React Native from the node_modules folder.

Make sure you defining the maven local repository folder correctly at you android/build.gradle:

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

@SandroMachado Thanks for quick response, I have this already in place.

Problem was with dependency version, it should be:

compile "com.facebook.react:react-native:0.37.0" // From node_modules

Notice the '.0'

Trying this now... Does this need any other changes in package.json. Mine looks like this:

"dependencies": {
    "react": "^0.14.8",
    "react-native": "^0.22.2"
  }

It does feel that if you maintained a table of relevant value sets somewhere, a lot of issues would be resolved (and the documentation would be a lot clearer)

This gives me a lot of compilation errors:

Error:(11, 26) error: cannot find symbol class LifecycleState
Error:(33, 34) error: cannot find symbol method onPause()
Error:(42, 34) error: cannot find symbol method onResume(ReactActivity,ReactActivity)
Error:(51, 34) error: cannot find symbol method onDestroy()
Error:(95, 43) error: cannot find symbol variable LifecycleState
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

Trying:

"dependencies": {
    "react": "^0.14.8",
    "react-native": "^0.37.0"
  }

followed by

rm -rf node_modules/ && npm install

Then a project refresh, then a build. I get the same errors.

Essentially, the process lined out in this doc is broken I believe... Unless maybe I need to update react version number too? (Which comes back to what I was saying earlier about a table of compatible version numbers)

@LiamInJapan New package name for LifecycleState class: com.facebook.react.common.LifecycleState

Thanks @ishan-dhingra

I still have these:

Error:(33, 34) error: cannot find symbol method onPause()
Error:(42, 34) error: cannot find symbol method onResume(ReactActivity,ReactActivity)
Error:(51, 34) error: cannot find symbol method onDestroy()
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

@LiamInJapan This seems to be a Compile time Java error, check if you are extending class and overriding function properly.

Ok, I'll check (although this is what is in the documents... Actually come
to think of it I think I know what it is)

On Wed, Nov 16, 2016 at 6:26 PM, Ishan Dhingra [email protected]
wrote:

@LiamInJapan https://github.com/LiamInJapan This seems to be a Compile
time Java error, check if you are extending class and overriding function
properly.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/6152#issuecomment-260896059,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABlM9y5Jjw-25LxmDODzomMkRKwTSAfXks5q-sxTgaJpZM4HjE37
.

Liam Conroy
Freelance Software Engineer
Portfolio http://liaminjapan.github.io
Twitter https://twitter.com/LiamInJapan
LinkedIn https://jp.linkedin.com/in/liamconroy2008
AngelList https://angel.co/liam-conroy

So replacing with onHostPause, onHostResume e.t.c. gets it compiling, though there is a strikethrough on these function names (deprecated?).

Then I get a "Seem's you're trying to access 'ReactNative.Component' from the 'react-native' package "throwOnWrongReactAPI" exception...

Again these are using samples from the documentation... I am following the instructions now

Ok I am finally at Hello World, though I think this is the longest "Hello World" I've ever experienced.

I still have the depreciated issue mind regarding the onHostXXXX functions (onDestroy e.t.c. don't work) which makes me think I still have a versioning issue:

"dependencies": {
    "react": "^15.3.2",
    "react-native": "^0.37.0"
  }
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.facebook.react:react-native:0.37.0'

Any advice appreciated!

I am facing the same issue. Can someone help?

I've solved the problem changing In my project's build.gradle file what follows
maven {
// All of React Native (JS, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
in
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "/MyAbsolutePathToTheApplicationRoot/node_modules/react-native/android"
}

Then you have to solve some compiling errors related to the OnPause, OnResume...that are changed in onHostPause, onHostResume and that's it. A pain in the ass anyway!

@StefanoCremona I was able to get rid of the error with this, however when I run the app I get

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Could not connect to development server.

I did this adb reverse tcp:8081 tcp:8081, even then it's not working. Did you come across this?

84m gp 2jp 93x 8v j 01
4ppwom_55zrsl2 zf241peu
no a39cfq6tu 1 3 8 h72m
l rot rolzttbaj 3bc0

"dependencies": { "react": "^0.14.7", "react-native": "^0.26.2" }

02-09 19:44:03.409 12389-12475/com.kenny.embedded E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.kenny.embedded, PID: 12389 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:321) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:833) Caused by: java.lang.UnsatisfiedLinkError: could find DSO to load: libreactnativejni.so at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:213) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:178) at com.facebook.react.bridge.JSCJavaScriptExecutor.<clinit>(JSCJavaScriptExecutor.java:25) at com.facebook.react.bridge.JSCJavaScriptExecutor$Factory.create(JSCJavaScriptExecutor.java:20) at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:183) at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:169) at android.os.AsyncTask$2.call(AsyncTask.java:307) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)  at java.lang.Thread.run(Thread.java:833) 

Excuse me? Thank you !

I solved this problem by using the complete maven path in the app's build.gradle.

I had put this maven path in the Projects build.gradle before by mistake. Putting it into app's build.gradle worked.

I am also hitting this error

app gradle

 compileSdkVersion = 25
 buildToolsVersion = "24.0.3"
 compile 'com.android.support:appcompat-v7:23.0.1'
 complie 'com.android.support:support-v4:23.0.1'
 compile "com.facebook.react:react-native:+" // From node_modules.

package.json

"dependencies": {
    "react": "^15.4.2",
    "react-native": "^0.41.0"
  }

keep the supportV7 version with the compileSdkVersion version

I'm hitting this with React Native 0.41.2, I don't have a appcompat-v4 dependency in my build.gradle file, I do have:

compile 'com.android.support:appcompat-v7:23.3.0'

ah, but one of my dependencies uses:

compile 'com.android.support:support-v4:22.2.1'

@NoTraceOfSnow I can't implement ReactApplication as it is not found - using compile "com.facebook.react:react-native:+" // From node_modules.

Am I missing something?

"dependencies": {
    "react": "^15.4.2",
    "react-native": "^0.41.2"
}

compileSdkVersion 25
buildToolsVersion "24.0.3"

compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'

@haemi your project has download this about the reactnative file? i have a good idea ,you can init a Official project ,View all files and you can find difference in the project,copy the difference file to you self project.if you can improt reactnative in you project you can link me , i will try my beast .my QQ email [email protected] and you project has this picture files
1487663126 1

@NoTraceOfSnow thanks for your quick response! I can import React into my project, I also have the node_modules folder with it's subfolders. But when I want to show my ReactNative-Activity, I get the error from above (java.lang.IllegalAccessError: Method 'void android.support.v4.net.ConnectivityManagerCompat.<init>()').

Then I wanted to try what you wrote here (https://github.com/facebook/react-native/issues/6152#issuecomment-268145298), but I can't do the implements ReactApplication...

@haemi eee.... do you start your server? and i think you lost some file .
fng1eayuw2s9x 9ds 7 6 gthis is the office project ,i think you can see the office project file one by one.wish you success

is this in build.gradle correct?

allprojects {
    repositories {
        ...
        maven {
            // All of React Native (JS, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
    ...
}

shouldn't it be ReactAndroid at the end? I do not have a react-native/android directory...

so sorry i am sleep last night ,yes,you should it be . i will tell you how to lead reactnative into your project.
first
second
you should find the data.txt with you appgridle diffrence and copy in you project
data.txt
and you must keep version like this picture
third
foru
Wish you success

I suspect this is caused by gradle picking up the wrong version of react-native,
see PR here: https://github.com/facebook/react-native/pull/14743

Was this page helpful?
0 / 5 - 0 ratings