oney / react-native-gcm-android

GCM for React Native Android
MIT License
172 stars 76 forks source link

Native module AsyncStorageModule tried to override AsyncStorageModule #35

Closed onchainguy-btc closed 8 years ago

onchainguy-btc commented 8 years ago

Okay after I found out that #34 was my fault and related to another library I got that problem fixed. Now I really have a problem with this library together with react native 0.18.0

These are my gradle dependencies:

compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.18.+"
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
    compile project(':RNGcmAndroid')
    compile project(':react-native-system-notification')
    compile project(':react-native-image-picker')
    compile project(':react-native-contacts')

Build the application works but as soon as I run the application I get the typical react native red screen showing the following error message:

01-26 01:25:03.251  2720  2720 E unknown:React: java.lang.IllegalStateException: Native module AsyncStorageModule tried to override AsyncStorageModule for module name AsyncSQLiteDBStorage. If this was your intention, return true from AsyncStorageModule#canOverrideExistingModule()
01-26 01:25:03.251  2720  2720 E unknown:React:     at com.facebook.react.bridge.NativeModuleRegistry$Builder.add(NativeModuleRegistry.java:184)
01-26 01:25:03.251  2720  2720 E unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.processPackage(ReactInstanceManagerImpl.java:745)
01-26 01:25:03.251  2720  2720 E unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:681)
01-26 01:25:03.251  2720  2720 E unknown:React:     at com.facebook.react.ReactInstanceManagerImpl.access$600(ReactInstanceManagerImpl.java:80)
01-26 01:25:03.251  2720  2720 E unknown:React:     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:173)
01-26 01:25:03.251  2720  2720 E unknown:React:     at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:158)
01-26 01:25:03.251  2720  2720 E unknown:React:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
01-26 01:25:03.251  2720  2720 E unknown:React:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-26 01:25:03.251  2720  2720 E unknown:React:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
01-26 01:25:03.251  2720  2720 E unknown:React:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-26 01:25:03.251  2720  2720 E unknown:React:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-26 01:25:03.251  2720  2720 E unknown:React:     at java.lang.Thread.run(Thread.java:818)
01-26 01:25:03.347  2720  2738 W EGL_emulation: eglSurfaceAttrib not implemented
01-26 01:25:03.347  2720  2738 W OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad760b60, error=EGL_SUCCESS

When I remove this library as a dependency everything works fine.

oney commented 8 years ago

I setup TestGcm project on this branch for React Native 0.18.0. It built and run fine. Please show me android/app/src/main/java/com/yourapp/MainActivity.java of your project.

paulbao commented 8 years ago

I had this issue too. @oney is right, check you MainActivity.java file and you probably had added AsyncStorageModule more than once.

onchainguy-btc commented 8 years ago

OMG I'm sorry @paulbao you are right, that was exactly the issue. Thank you.

Poney1 commented 8 years ago

@oney I had this issue too, but I haven't solve.

Poney1 commented 8 years ago

for React native 0.24

joshuapinter commented 7 years ago

I had the same issue. In later versions of React Native (0.39 in my case) you'll want to look at the getPackages function in MainApplication.java instead of MainActivity.java.

Btw, this happened because react-native link isn't super clever and can sometimes re-add a package that is already included.

AugustoAleGonZhipCode commented 7 years ago

Hello @joshuapinter thanks for your answer. I solved that issue checking what you are saying. I have the same packages 4 times! 😆 As you said it, react-native is not super clever.