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

Cannot set up firebase on android react native 0.60.3

Open suupham2506 opened this issue 7 years ago • 6 comments

Issue

I tried to set up firebase for my React native app version 0.60.0 but I ran into bugs on android. Anyone made it work, please help me out.


Project Files

iOS

Click To Expand

ios/Podfile:

  • [ ] I'm not using Pods
  • [x] I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • [ ] my application is an AndroidX application?
  • [ ] I am using android/gradle.settings jetifier=true for Android compatibility?
  • [ ] I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

    classpath 'com.google.gms:google-services:4.2.0'

android/app/build.gradle:

implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
apply plugin: 'com.google.gms.google-services'

android/settings.gradle:

// N/A

MainApplication.java:

protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); packages.add(new RNFirebaseMessagingPackage()); packages.add(new RNFirebaseNotificationsPackage()); return packages; }

AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />

<application
  android:name=".MainApplication"
  android:label="@string/APP_NAME"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/APP_NAME"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:launchMode="singleTop">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

  <receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/>
  <receiver android:enabled="true" android:exported="true"  android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
    <intent-filter>
      <action android:name="android.intent.action.BOOT_COMPLETED"/>
      <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
      <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
      <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
  </receiver>

  <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
    <intent-filter>
      <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
  </service>

  <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />

</application>


Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • [ ] iOS
    • [ ] Android
    • [ ] iOS but have not tested behavior on Android
    • [ ] Android but have not tested behavior on iOS
    • [ ] Both
  • react-native-firebase version you're using that has this issue:
    • e.g. 5.4.3
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N


Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Screen Shot 2019-07-24 at 4 26 36 PM

suupham2506 avatar Jul 24 '19 09:07 suupham2506

Sure, just clone this repo https://github.com/mikehardy/rnfbdemo and run RNVERSION=60 ./make-demo.sh - works

The problem you are having is you didn't use compatible versions https://rnfirebase.io/docs/v5.x.x/getting-started#Supported-versions---React-Native-/-Firebase

v5.4 + AndroidX -> no go (well maybe no go) v5.4 + new firebase SDK libraries -> definitely no go

mikehardy avatar Jul 24 '19 13:07 mikehardy

Sure, just clone this repo https://github.com/mikehardy/rnfbdemo and run RNVERSION=60 ./make-demo.sh - works

The problem you are having is you didn't use compatible versions https://rnfirebase.io/docs/v5.x.x/getting-started#Supported-versions---React-Native-/-Firebase

v5.4 + AndroidX -> no go (well maybe no go) v5.4 + new firebase SDK libraries -> definitely no go

this repo is not working for rn 0.60.4 . the build fails

creative-git avatar Jul 27 '19 17:07 creative-git

Which build @creative-git ? I just updated it recently and it was working for me. Maybe open an issue + PR on that repo

mikehardy avatar Jul 28 '19 13:07 mikehardy

@creative-git - maybe it was an iOS build you had issues with, I had finished updating rnfbdemo for RN60+Android but wasn't quite done with iOS. It's fully updated / and appears to work for me now? https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

mikehardy avatar Jul 28 '19 16:07 mikehardy

@mikehardy , i tested it on ios. didn't try it on android after that. with RNFB v6 still in alpha, and RN 0.60 autolinking , lot of developers facing issues integrating RNFB with RN. It will be great if the documentation of either v5 or v6 has some clear installation steps on RN 0.60

creative-git avatar Jul 29 '19 06:07 creative-git

I agree - PRs are welcome, there's an edit button on every documentation page

mikehardy avatar Jul 29 '19 13:07 mikehardy