1

Okey, i am on day 3 for this issue. I think i have tried nearly everything.

The package which i can't remove: react-native-firebase

I tried: Completely removing all references with firebase in the code, which include build.gradle files, package.json, etc. Checking out to older commits and making a build( The firebase is still there!!! ). Tried cleaning the project with ./gradlew clean. I have removed node_modules and reinstalled multiple times. Cleaned watchdog caches.

Previously i was able to build the apk(but it would crash instantly when opened on android). Right now, i can't even make a apk.. I get error:

/android/app/src/main/AndroidManifest.xml:9:5-81 Warning:
        Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:9:5-81 duplicated with element declared at AndroidManifest.xml:5:5-81
:app:processReleaseResources
:app:generateReleaseSources
:app:incrementalReleaseJavaCompilationSafeguard
:app:compileReleaseJavaWithJavac
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:transformClassesWithJarMergingForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbyb.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 56.222 secs

Any help or advice would be really helpful.

Thanks!

EDIT: After removing duplicate permissions and running ./gradlew clean, rebuilding and reassembling. Same error:

:app:incrementalReleaseJavaCompilationSafeguard
:app:compileReleaseJavaWithJavac
:app:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:transformClassesWithJarMergingForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbyb.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 11.648 secs

EDIT:

dependencies {
    compile project(':react-native-flurry-analytics')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-permissions')
    compile project(':react-native-animation')
    compile project(':react-native-mail')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.facebook.react:react-native:+'
    compile 'com.google.android.gms:play-services:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
    compile project(':react-native-share')
    compile project(':react-native-maps')
    compile project(':react-native-onesignal')
}

EDIT:

08-30 15:30:08.871 1090-1153/com.adpages.android E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                   java.lang.RuntimeException: An error occured while executing doInBackground()
                                                                       at android.os.AsyncTask$3.done(AsyncTask.java:299)
                                                                       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
                                                                       at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:239)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
                                                                       at java.lang.Thread.run(Thread.java:856)
                                                                    Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.maps.GoogleMapOptions
                                                                       at com.airbnb.android.react.maps.AirMapManager.<init>(AirMapManager.java:52)
                                                                       at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.createAllViewManagers(XReactInstanceManagerImpl.java:699)
                                                                       at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:204)
                                                                       at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:69)
                                                                       at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:143)
                                                                       at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:140)
                                                                       at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:76)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.processPackage(XReactInstanceManagerImpl.java:954)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.createReactContext(XReactInstanceManagerImpl.java:862)
                                                                       at com.facebook.react.XReactInstanceManagerImpl.access$600(XReactInstanceManagerImpl.java:110)
                                                                       at com.facebook.react.XReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(XReactInstanceManagerImpl.java:214)
                                                                       at com.facebook.react.XReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(XReactInstanceManagerImpl.java:193)
                                                                       at android.os.AsyncTask$2.call(AsyncTask.java:287)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:234)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                                                                       at java.lang.Thread.run(Thread.java:856) 
08-30 15:30:08.891 1090-1090/com.adpages.android D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so

EDIT:

dependencies {
    compile project(':react-native-flurry-analytics')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-permissions')
    compile project(':react-native-animation')
    compile project(':react-native-mail')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.facebook.react:react-native:+'
    compile project(':react-native-share')
    compile project(':react-native-onesignal')

    compile(project(':react-native-maps')) {
      exclude group: 'com.google.android.gms', module: 'play-services'
      exclude group: 'com.google.android.gms', module: 'play-services-maps'
      exclude group: 'com.google.android.gms', module: 'play-services-location'
      exclude group: 'com.google.android.gms', module: 'play-services-gcm'
    }
    compile 'com.google.android.gms:play-services:10.2.1'
    compile 'com.google.android.gms:play-services-location:10.2.1'
    // Required for OneSignal, even if you have added FCM.
    compile 'com.google.android.gms:play-services-gcm:10.2.1'
}
IvRRimUm
  • 1,724
  • 3
  • 21
  • 40

2 Answers2

1

These situations have always been a pain point in Android.
Since you're using a different version of play-services than what comes with react-native-maps, you need to exclude the packages from react-native-maps and add them manually like this.

compile(project(':react-native-maps')) { 
    exclude group: 'com.google.android.gms', module: 'play-services-base' 
    exclude group: 'com.google.android.gms', module: 'play-services-maps' 
    exclude group: 'com.google.android.gms', module: 'play-services-location' 
exclude group: 'com.google.android.gms', module: 'play-services-gcm' 
} 
compile "com.google.android.gms:play-services-base:10.2.1" 
compile "com.google.android.gms:play-services-maps:10.2.1" 
compile 'com.google.android.gms:play-services-location:10.2.1' 
// Required for OneSignal, even if you have added FCM. 
compile 'com.google.android.gms:play-services-gcm:10.2.1'
basudz
  • 997
  • 1
  • 6
  • 14
  • No duplicates any of the files you mentioned :// – IvRRimUm Aug 30 '17 at 14:37
  • @IvRRimUm can you post the dependencies section in your build.gradle file? There's a duplicate somewhere, but it doesn't necessarily have to be Firebase. – basudz Aug 30 '17 at 15:00
  • @IvRRimUm it's the gms deps. remove compile 'com.google.android.gms:play-services-location:10.2.1' compile 'com.google.android.gms:play-services-gcm:10.2.1' and go from there. – basudz Aug 30 '17 at 15:12
  • Removed both of them, still getting: `* What went wrong: Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbyb.class` – IvRRimUm Aug 30 '17 at 15:15
  • @IvRRimUm did you run ./gradlew clean first before building? – basudz Aug 30 '17 at 15:17
  • @IvRRimUm Just saw that react-native-maps includes its own version of playservices so you probably need to remove com.google.android.gms:play-services:10.2.1 as well. https://github.com/airbnb/react-native-maps/blob/master/docs/installation.md#android – basudz Aug 30 '17 at 15:23
  • I can generate apk now!!! But it still insta crashes. I added the error in the question. – IvRRimUm Aug 30 '17 at 15:30
  • @IvRRimUm Ok, so the link I posted to installing react-native-maps tells you how to set it up if you need to use different versions of playservices. Go through that to add back in the playservices lines that you removed. It seems your initial build problem was the playservices library inside react-native-maps was conflicting with the playservices deps that you manually added. – basudz Aug 30 '17 at 15:34
  • Just updated my question my deps. I still get the error :// – IvRRimUm Aug 30 '17 at 16:07
  • @IvRRimUm so basically you need to find the right combination of your playservices that work with react-native-maps. Since you are adding in the direct packages of gcm, location, and maps from playservices, you can probably remove the 'com.google.android.gms:play-services:10.2.1' dependency. You're on the right track to fixing everything though and your Firebase is completely removed so I think you could close this issue. – basudz Aug 30 '17 at 16:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/153281/discussion-between-ivrrimum-and-basudz). – IvRRimUm Aug 30 '17 at 17:20
0

Seems like you have a doubled permission request on AndroidManifest.xml

Did you check it?

Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:9:5-81 duplicated with element declared at AndroidManifest.xml:5:5-81

bennygenel
  • 23,896
  • 6
  • 65
  • 78
  • Have you tried to do a gradle clean after you deleted the duplicate record? Can you try it again and post the error again please? – bennygenel Aug 29 '17 at 16:32
  • Its not the same error. `com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbyb.class` [Here](https://stackoverflow.com/a/42610163/2315280) an answer for your second error. – bennygenel Aug 29 '17 at 17:42
  • First try to unlink the library by using command react-native unlink library name then remove using npm uninstall library name – Paras Watts Aug 30 '17 at 18:04