React-native-firebase: Crashes for iOS, doesn't compile on Android

Created on 13 Jul 2017  Â·  15Comments  Â·  Source: invertase/react-native-firebase

Hey!
I could not find similar issue in the issues so I'm posting here.
I'm trying to integrate react-native-firebase to use Analytics in my app. I followed all the steps in the documentation, but without any success. I'm trying to make it working for both platforms- iOS and Android.

TL;DR

App compiles for iOS but crashes just after launch.
The app does not compile for Android and results in the following error:

A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "+"

What happens on iOS?

react-native run-ios command compiles the project successfully, uploads it to the simulator, packager packs the bundle, the app starts but hangs for a bit and crashes/closes. When I try to launch it again the same happens.

Current setup for iOS:

I have GoogleService-Info.plist residing in ios project next to Info.plist file.

AppDelegate.m

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "ReactNativeConfig.h"
#import <BugsnagReactNative/BugsnagReactNative.h>
#import <Firebase.h>

@import GoogleMaps;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSString *GOOGLE_MAPS_API_KEY = [ReactNativeConfig envFor:@"GOOGLE_MAPS_API_KEY"];
  NSURL *jsCodeLocation;
  [GMSServices provideAPIKey:GOOGLE_MAPS_API_KEY];
  [BugsnagReactNative start];
  [FIRApp configure];
  #ifdef DEBUG
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
  #else
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"app"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end

Podfile

# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

target 'app' do
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core'
  ]

  pod 'GoogleMaps'  # <~~ remove this line if you do not want to support GoogleMaps on iOS

  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  pod 'Firebase/Analytics'

end

my custom module imported in another module

import RNFirebase from 'react-native-firebase'

const configurationOptions = {
  debug: __DEV__
}

const firebase = RNFirebase.initializeApp(configurationOptions)

export default firebase

What happens on Android?

cd android && ./gradlew clean && cd .. && react-native run-android running this command results in the error below:

Reading env from: .env

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/lukaleli/app/android/app/build.gradle' line: 184

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "+"

* 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: 7.569 secs

Current setup for Android:

google-services.json residing in android/app directory

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
import groovy.json.JsonSlurper

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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"
        }
    }
}

subprojects {
    ext {
        def npmVersion = getNpmVersionArray()
        versionMajor = npmVersion[0]
        versionMinor = npmVersion[1]
        versionPatch = npmVersion[2]
    }
}

def getNpmVersion() {
    def inputFile = new File("$rootDir/../package.json")
    def packageJson = new JsonSlurper().parseText(inputFile.text)
    return packageJson["version"]
}

def getNpmVersionArray() { // major [0], minor [1], patch [2]
    def (major, minor, patch) = getNpmVersion().tokenize('.')
    return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]
}

android/app/build.gradle (only dependency part)

// ...

dependencies {
    compile project(':react-native-permissions')
    compile project(':react-native-device-info')
    compile project(':react-native-config')
    compile project(':bugsnag-react-native')
    compile project(':lottie-react-native')
    compile project(':react-native-fs')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-camera')
    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'
        }
    compile 'com.google.android.gms:play-services-base:+'
    compile 'com.google.android.gms:play-services-maps:+'
    compile project(':react-native-localization')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.facebook.fresco:animated-gif:0.11.0'
    compile(project(':react-native-firebase')) {
        transitive = false
      }
    compile "com.google.firebase:firebase-core:11.0.0"
    compile "com.google.firebase:firebase-analytics:11.0.0"
}


// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.google.gms.google-services'

Tried solutions

For android I tried to exclude google services dependencies from possibly colliding libraries (react-native-maps and react-native-device-info), but with no success. (idea taken from: https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f )

For iOS I have no clue what to look for as long as I cannot catch the native crashes when running the app in the simulator from the cmd. It just crashes silently.

I'm struggling with this issue the second day already and I'm pulling my hair off... Did anybody encounter something similar?

Thanks in advance!

Environment

  1. Target Platform: iOS and Android
  2. Development Operating System : macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant):
  4. React Native version: 0.41.2
  5. RNFirebase Version: 2.0.2
General Build Error Bug Android iOS

Most helpful comment

iOS
Yes, unfortunately pasting the file into the directory doesn't automatically add the file to the iOS project. You need to manually add it (which I only know how to do within XCode) by:

  • Right click on your project
  • Click "Add files to 'project name'"
  • Select the .plist file
  • Click ok

Android
Ah, ok, thanks for confirming. Are you able to run with the --stacktrace flag? This will hopefully give some more information...

All 15 comments

@lukaleli thanks for the detailed description of your problems. I'll answer this for iOS and Android in turn

iOS
If the app is crashing, then there will be some logs being generated which will have some more information about what's causing the crash. I tend to run my app from within XCode rather than from the command line which gives visibility of the logs after it has crashed. Perhaps try giving that a go and report back with the error log?

Android
Can you include the snippet of code around line 194 in your /android/app/build.gradle file? From the error, it looks like there might be a syntax issue.

Build file '/Users/lukaleli/app/android/app/build.gradle' line: 194

@chrisbianca , thanks for a quick reply!

iOS
Ok, I was a bit too quick with saying I cannot access logs :) react-native log-ios actually works very well. So here is the log. Now I noticed that it cannot locate GoogleService-Info.plist file... How should I add it to the project properly then? What I did is actually by pasting the file into the directory - it hasn't been imported via XCode. Can you point me to how to do it? (I'm not well versed with XCode and iOS native development)

Jul 13 18:10:26 lukaleli assertiond[5484] <Warning>: Submitted job with label: UIKitApplication:<MY.APP.IDENTIFIER>[0xbdc7][5484]
Jul 13 18:10:26 lukaleli SpringBoard[5479] <Warning>: [<MY.APP.IDENTIFIER>] Bootstrap complete with label: UIKitApplication:<MY.APP.IDENTIFIER>[0xbdc7][5484]
Jul 13 18:10:26 lukaleli watchlistd[5632] <Warning>: Now playing app did change to '(null)' (playing: 0) from '(null)'
Jul 13 18:10:26 lukaleli watchlistd[5632] <Warning>: WLKPlaybackSummary - Parameter failed validation bundleID. It is nil
Jul 13 18:10:27 lukaleli goodly[9591] <Error>: objc[9591]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11af8ecc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x11d7046f0). One of the two will be used. Which one is undefined.
Jul 13 18:10:27 lukaleli goodly[9591] <Error>: assertion failed: 16F73 14E8301: libxpc.dylib + 64131 [624BAF4F-2E03-34F8-ACBA-970B04637786]: 0x7d
Jul 13 18:10:27 lukaleli Unknown[9591] <Error>:
Jul 13 18:10:27 lukaleli goodly[9591] <Notice>: Initializing <RCTBatchedBridge: 0x6000001841d0> (parent: <RCTBridge: 0x6080000aa5c0>, executor: RCTJSCExecutor)
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebaseStorage was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebaseRemoteConfig was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebasePerformance was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebaseMessaging was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebaseDatabase was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebaseCrash was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Warning>: Class RNFirebaseAuth was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Jul 13 18:10:27 lukaleli goodly[9591] <Error>: [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
Jul 13 18:10:27 lukaleli goodly[9591] <Error>: [Firebase/Core][I-COR000005] No app has been configured yet.
Jul 13 18:10:27 lukaleli assertiond[5484] <Warning>: client <BSProcessHandle: 0x7faff0c0c3c0; goodly:9591; valid: YES> HWM increased to 1 because of <BKProcessAssertion: 0x7faff0c06250; "FIRClearcutLogger.sendLogs" (finishTask:180s); id:…64EE13EFC0DA>
Jul 13 18:10:28 lukaleli goodly[9591] <Error>: *** Terminating app due to uncaught exception 'com.firebase.core', reason: '`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
    *** First throw call stack:
    (
        0   CoreFoundation                      0x0000000112625b0b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x000000011101f141 objc_exception_throw + 48
        2   CoreFoundation                      0x000000011268e625 +[NSException raise:format:] + 197
        3   goodly                              0x000000010c07c1cf +[FIRApp configure] + 353
        4   goodly                              0x000000010bf062fd -[AppDelegate application:didFinishLaunchingWithOptions:] + 973
        5   UIKit                               0x000000010f20d9b7 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
        6   UIKit                               0x000000010f20f29c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4119
        7   UIKit                               0x000000010f2155e4 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1709
        8   UIKit                               0x000000010f2127f3 -[UIApplication workspaceDidEndTransaction:] + 182
        9   FrontBoardServices                  0x00000001197f35f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
        10  FrontBoardServices                  0x00000001197f346d -[FBSSerialQueue _performNext] + 186
        11  FrontBoardServices                  0x00000001197f37f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
        12  CoreFoundation                      0x00000001125cbc01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        13  CoreFoundation                      0x00000001125b10cf __CFRunLoopDoSources0 + 527
        14  CoreFoundation                      0x00000001125b05ff __CFRunLoopRun + 911
        15  CoreFoundation                      0x00000001125b0016 CFRunLoopRunSpecific + 406
        16  UIKit                               0x000000010f21108f -[UIApplication _run] + 468
        17  UIKit                               0x000000010f217134 UIApplicationMain + 159
        18  goodly                              0x000000010bf0954f main + 111
        19  libdyld.dylib                       0x00000001139d965d start + 1
        20  ???                                 0x0000000000000001 0x0 + 1
    )
Jul 13 18:10:28 lukaleli SpringBoard[5479] <Error>: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
Jul 13 18:10:28 lukaleli com.apple.CoreSimulator.SimDevice.4D4325BE-FD6F-42AE-9A06-B0A891BBD372.launchd_sim[5462] (UIKitApplication:<MY.APP.IDENTIFIER>[0xbdc7][5484][9591]) <Notice>: Service exited due to Abort trap: 6
Jul 13 18:10:28 lukaleli assertiond[5484] <Warning>: Deleted job with label: UIKitApplication:<MY.APP.IDENTIFIER>[0xbdc7][5484]
Jul 13 18:10:28 lukaleli watchlistd[5632] <Warning>: Now playing app did change to '(null)' (playing: 0) from '(null)'
Jul 13 18:10:28 lukaleli watchlistd[5632] <Warning>: WLKPlaybackSummary - Parameter failed validation bundleID. It is nil
Jul 13 18:11:08 lukaleli routined[5468] <Error>: CoreLocation: Error occurred while trying to retrieve motion state update: CMErrorDomain Code:104

Android
Oh, I forgot to mention that. The line the log output refers to is the line where the plugin is applied (the last line in the build.gradle actually):
apply plugin: 'com.google.gms.google-services'

iOS
Yes, unfortunately pasting the file into the directory doesn't automatically add the file to the iOS project. You need to manually add it (which I only know how to do within XCode) by:

  • Right click on your project
  • Click "Add files to 'project name'"
  • Select the .plist file
  • Click ok

Android
Ah, ok, thanks for confirming. Are you able to run with the --stacktrace flag? This will hopefully give some more information...

iOS

Thanks! I made it working on iOS (at least it compiled and run on simulator). But I don't see any events showing up in the dev tools console when I set the debug option to true. Or am I missing something?

Android
Even running just ./gradlew clean command fails. The stacktrace is shown below.

./gradlew clean --stacktrace
Reading env from: .env

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/lukaleli/app/android/app/build.gradle' line: 184

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "+"

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

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:76)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:156)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.google.gms.google-services']
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:160)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)
        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)
        at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
        at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
        at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
        at build_e1xlupo6m8a2sdity9ye2uwrv.run(/Users/lukaleli/Dev/goodly-app/android/app/build.gradle:184)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74)
        ... 38 more
Caused by: java.lang.NumberFormatException: For input string: "+"
        at java_lang_Integer$valueOf$0.call(Unknown Source)
        at com.google.gms.googleservices.GoogleServicesPlugin.checkMinimumVersion(GoogleServicesPlugin.groovy:88)
        at com.google.gms.googleservices.GoogleServicesPlugin.addDependency(GoogleServicesPlugin.groovy:101)
        at com.google.gms.googleservices.GoogleServicesPlugin.apply(GoogleServicesPlugin.groovy:47)
        at com.google.gms.googleservices.GoogleServicesPlugin.apply(GoogleServicesPlugin.groovy)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        ... 49 more


BUILD FAILED

Total time: 4.844 secs

I'll just paste whole android/app/build.gradle here:

apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

// def secretPropsFile = rootProject.file("secret.properties")

// Initialize a new Properties() object called keystoreProperties.
// def secretProps = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
// secretProps.load(new FileInputStream(secretPropsFile))

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"]
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "<MY.APP.IDENTIFIER>"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
          keyAlias project.env.get('KEY_ALIAS')
          keyPassword project.env.get('KEY_PASSWORD')
          storeFile file(project.env.get('STORE_FILE'))
          storePassword project.env.get('STORE_PASSWORD')
        }
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-permissions')
    compile project(':react-native-device-info')
    compile project(':react-native-config')
    compile project(':bugsnag-react-native')
    compile project(':lottie-react-native')
    compile project(':react-native-fs')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-camera')
    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'
        }
    compile 'com.google.android.gms:play-services-base:+'
    compile 'com.google.android.gms:play-services-maps:+'
    compile project(':react-native-localization')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.facebook.fresco:animated-gif:0.11.0'
    compile(project(':react-native-firebase')) {
        transitive = false
      }
    compile "com.google.firebase:firebase-core:11.0.0"
    compile "com.google.firebase:firebase-analytics:11.0.0"
}


// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.google.gms.google-services'

iOS
You'll only start seeing logs on the dev tools console when you start using Firebase services in the JS. You should be able to see some native logs though regardless?

Android
My only guess is that the google services plugin doesn't like what you're doing with your versionCode statement? I don't think it's anything RNFirebase specific that's causing the problem.

iOS
I already use it via JS, but there's no logs in the console.

import RNFirebase from 'react-native-firebase'

const configurationOptions = {
  debug: __DEV__,
  errorOnMissingPlayServices: false,
  persistence: true
}

const firebase = RNFirebase.initializeApp(configurationOptions)

const logEvent = (event, params) => {
  firebase.analytics().logEvent(event, params)
}

export default {
  logEvent
}

And usage in other module

Analytics.logEvent('test', { id: 1234 })

Nothing shows up in the console... Is there any other way to check if firebase works?

Android
That's not the case. It's a completely valid groovy code. I just changed versionCode to integer to be 100% sure and the error is still the same.

Nothing shows up in the console... Is there any other way to check if firebase works?

This usually takes a good few hours to happen, it's not real time unfortunalty.

iOS
Ok, I can confirm that it works for iOS. I started to see events showing up in the dashboard. I don't understand why debug mode is not working, though.

Android
Still in the void...

For Android, try changing your play-services-base to a specific version, e.g. compile "com.google.android.gms:play-services-base:11.0.1.

There's a few issues people are having using + from Googling.

Ok, I tried to update the dependencies in a following way:


// ...
compile 'com.google.android.gms:play-services-base:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
// ...

and it results in a following error:

./gradlew clean
Reading env from: .env

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-firebase'.
   > Could not resolve all dependencies for configuration ':react-native-firebase:_debugCompile'.
      > Could not find com.google.android.gms:play-services-base:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.jar
            https://jcenter.bintray.com/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.pom
            https://jcenter.bintray.com/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-base/11.0.0/play-services-base-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-core:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.0.0/firebase-core-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-config:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-config/11.0.0/firebase-config-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-auth:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/11.0.0/firebase-auth-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-analytics:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-analytics/11.0.0/firebase-analytics-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-database:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-database/11.0.0/firebase-database-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-storage:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-storage/11.0.0/firebase-storage-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-messaging:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/11.0.0/firebase-messaging-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-crash:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-crash/11.0.0/firebase-crash-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-perf:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-perf/11.0.0/firebase-perf-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified
      > Could not find com.google.firebase:firebase-ads:11.0.0.
        Searched in the following locations:
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.pom
            file:/Users/lukaleli/.m2/repository/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.jar
            https://jcenter.bintray.com/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.pom
            https://jcenter.bintray.com/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.jar
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.pom
            file:/Users/lukaleli/Dev/goodly-app/node_modules/react-native/android/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/android/m2repository/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.jar
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.pom
            file:/Users/lukaleli/Library/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-ads/11.0.0/firebase-ads-11.0.0.jar
        Required by:
            goodly:react-native-firebase:unspecified

* 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: 22.551 secs

Perhaps that shed a light a bit?

Ok, I updated the Google Repository to the latest version from Android SDK manager. Now it compiles, but when app starts I get:

art  I  Late-enabling -Xcheck:jni
         AndroidRuntime  D  Shutting down VM
                         E  FATAL EXCEPTION: main
                         E  Process: app.identifier.com, PID: 26304
                         E  java.lang.NoSuchMethodError: No static method zza(Landroid/app/Application;)V in class Lcom/google/
                            android/gms/internal/zzbav; or its super classes (declaration of 'com.google.android.gms.internal.z
                            zbav' appears in /data/app/app.identifier.com-1/base.apk)
                         E      at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                         E      at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                         E      at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                         E      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
                         E      at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
                         E      at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
                         E      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                         E      at android.app.ActivityThread.installProvider(ActivityThread.java:5855)
                         E      at android.app.ActivityThread.installContentProviders(ActivityThread.java:5447)
                         E      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5386)
                         E      at android.app.ActivityThread.-wrap2(ActivityThread.java)
                         E      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
                         E      at android.os.Handler.dispatchMessage(Handler.java:102)
                         E      at android.os.Looper.loop(Looper.java:154)
                         E      at android.app.ActivityThread.main(ActivityThread.java:6121)
                         E      at java.lang.reflect.Method.invoke(Native Method)
                         E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

Ok, I will post how I made it working for android as well here. The problem is with colliding play services modules. I basically excluded them from the libraries that use them (in my case: react-native-device-info and react-native-maps) and added them as a separate dependencies in my build.gradle file with fixed version.

dependencies {
    compile project(':react-native-permissions')
    compile (project(':react-native-device-info')){
        exclude group: 'com.google.android.gms'
    }
    compile project(':react-native-config')
    compile project(':bugsnag-react-native')
    compile project(':lottie-react-native')
    compile project(':react-native-fs')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-camera')
    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms'
    }
    compile ('com.google.android.gms:play-services-base:11.0.0') {
        force = true
    }
    compile ('com.google.android.gms:play-services-maps:11.0.0') {
        force = true
    }
    compile ('com.google.android.gms:play-services-gcm:11.0.0') { 
        force = true 
    }
    compile project(':react-native-localization')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.facebook.fresco:animated-gif:0.11.0'
    compile(project(':react-native-firebase')) {
        transitive = false
      }
    compile "com.google.firebase:firebase-core:11.0.0"
    compile "com.google.firebase:firebase-analytics:11.0.0"
}

Hope that it'll help someone.
Issue can be closed now. Thanks for your help!

Maybe this should be added to the FAQ along with the duplicate dex files issue as theyre both the same issue essentially
https://github.com/invertase/react-native-firebase/blob/master/docs/faqs.md

@lukaleli which version did you use? How did you add it in build.gradle? can you provide sample code?

Was this page helpful?
0 / 5 - 0 ratings