Closed xfyre closed 4 years ago
Note: same problem was already reported in #2284, but was closed for not following the issue template.
I can confirm with D8 and even most recent gradle plugin 3.5.0 I get lots of warnings like this
I think the proguard rules might need some investigation
I tagged it with Build error since that's the closes label we have but please note that it is just a warning, and I have had no problems with the app functioning
Hi I got same issue with this D8: Type
and im suspecting this was the reason for me have an error:
Exception in HostObject::get(propName:RNFirebase):
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/firebase/FirebaseApp
I want to be reiterate that I see the warnings but I have no problems with the app functioning. I don't believe the warnings as described in this issue are actually a high priority error at the moment. Two thoughts @en-archx - you may have a multidex issue (you didn't say what API you have a problem with) - https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh#L123 - or you have maybe not included the proguard directives during react-native-firebase install? https://rnfirebase.io/docs/v5.x.x/installation/android#Using-with-Proguard-enabled
If it's not that, then that NoClassDefFoundError is definitely unexpected - I don't reproduce it in my projects or in rnfbdemo
@mikehardy I have done like what you said. But still i'm getting those warnings.
I still get them too. I test app functionality and everything works, so to me it is a problem but not a high priority, PRs welcome
Hi, our firebase not working in the compile version, i think this might be related to this
@robert589 do you mean release version? So you have tested it with minify/proguard enabled and it fails and disabled it works? Then you've done some basic things like enable it again but set wide-ranging 'keep' directives and it works again?
Hi everyone!
I just created a fresh react-native project and configured Auth, Firestore, Messaging and Crashanalytics and it crashes on launch on Android. It works on the first build, but subsequent rebuilds crash.
that sounds like a fully separate issue @lucidvision - can you reproduce this with https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh (a cloneable demo that should "just work" if put the google json / plist in the right spot) ?
I will be able to troubleshoot if you can reproduce it there
Your script is working on Android. I'm not sure what I did wrong in configuration. I'm pretty sure I followed the documentation closely and kept it to the basics on a fresh react-native install.
I got this error when running your script:
Building in iOS causes this error:
Do you mind letting me know how to resolve? Thank you very much for your help! @mikehardy
I made that demo just because it's so fiendish to get correct and I wanted a fully automated reproducible thing I could use myself and show others. Frequently it's a matter order of operations even.
I actually haven't run this since react-native 0.61.x (on 0.61.1 now) came out, so the ios failure must be a difference between those two but I'm not sure what. I can say I have 0.61.1 working in my project at least. If you took the demo and pinned it to 0.60.6 react-native version it should work until I get a chance to diagnose
Hi Mike!
Just wanted to report that updating the pod file to match the pod file for 0.61.1 as shown in rn-diff fixes the issue:
Thanks again for your help and this script you wrote! It's very helpful. @mikehardy
Ah thanks! That makes sense, I really should do the Podfile dynamically as well so that isn't so fragile between upgrades either, the Podfile did change quite a bit between RN60-61
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Maybe the bug is caused by, you forgot to open your android emulator then run
react-native run-android
.open android emulator first.
also try upgrade gradle version in android/gradle/wrapper/gradle-wrapper.properties
https://developer.android.com/studio/releases/gradle-plugin#3-4-0
notice R8 enabled by default
https://developer.android.com/studio/releases/gradle-plugin#3-1-0
notice android.enableIncrementalDesugaring=false
when I enable the proguard it throw these error. an app crash on startup
/Users/x/Desktop/y/node_modules/react-native-firebase/android/build/intermediates/runtime_library_classes/release/classes.jar: D8
: Interface `com.google.firebase.database.Transaction$Handler` not found. It's needed to make sure desugaring of `io.invertase.firebase.databas
e.RNFirebaseDatabase$1$1` is correct. Desugaring will assume that this interface has no default method.
other wise it work correctly I think the problem is with proguard rules
@EhsanSarshar this issue has been closed, and the app does not crash for others. Please create a new issue, ideally with a reproducible example, and the information requested in the template (most importantly gradle items)
@mikehardy I think I should forget about proguard and build my app without it. I don't think enabling proguard is such a big deal.
I have no problem running R8 (note, proguard is actually not used anymore in the Android world) and am not aware of anyone else having problems as well. react-native-firebase works fine with release mode code shrinking.
I requested more data multiple times because that would help isolate the problem. We don't even know if you are on react-native-firebase v5 or v6 at this point.
The results of using a shrinker can be dramatic, and your users would likely appreciate it if your app footprint was smaller, but, your choice.
:fire:
Issue
When compiling Android app, multiple warnings are issued as follows:
Project Files
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`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" } repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.google.gms:google-services:4.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() google() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" import com.android.build.OutputFile /** * 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, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // 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: [] * ] */ project.ext.react = [ nodeExecutableAndArgs: ["node", "--max_old_space_size=4096"] ] apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/react-native-vector-icons/fonts.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 rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.dcnetapp" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion missingDimensionStrategy 'react-native-camera', 'general' versionCode 21 versionName "2.0.0" ndk { abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { release { if (project.hasProperty('DCNETAPP_RELEASE_STORE_FILE')) { storeFile file(DCNETAPP_RELEASE_STORE_FILE) storePassword DCNETAPP_RELEASE_STORE_PASSWORD keyAlias DCNETAPP_RELEASE_KEY_ALIAS keyPassword DCNETAPP_RELEASE_KEY_PASSWORD } } } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } buildTypes { release { minifyEnabled enableProguardInReleaseBuilds signingConfig signingConfigs.release 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, "arm64-v8a": 3, "x86_64": 4] 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 { implementation project(':react-native-firebase') implementation project(':react-native-screens') implementation project(':@react-native-community_async-storage') implementation project(':react-native-square-pos') implementation project(':react-native-camera') implementation project(':react-native-gesture-handler') implementation project(':react-native-vector-icons') implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation 'com.squareup.sdk:point-of-sale-sdk:2.+' implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "com.google.firebase:firebase-core:16.0.9" implementation "com.google.firebase:firebase-messaging:18.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' ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'DcnetApp' include ':react-native-firebase' project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android') include ':react-native-screens' project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android') include ':@react-native-community_async-storage' project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android') include ':react-native-square-pos' project(':react-native-square-pos').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-square-pos/android') include ':react-native-camera' project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android') include ':react-native-gesture-handler' project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':app' ``` #### `MainApplication.java`: ```java package com.dcnetapp; import android.app.Application; import com.facebook.react.ReactApplication; import io.invertase.firebase.RNFirebasePackage; import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage; import com.swmansion.rnscreens.RNScreensPackage; import com.reactnativecommunity.asyncstorage.AsyncStoragePackage; import io.matix.RNSquarePosPackage; import org.reactnative.camera.RNCameraPackage; import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.oblador.vectoricons.VectorIconsPackage; import java.util.Arrays; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseNotificationsPackage(),
new RNScreensPackage(),
new AsyncStoragePackage(),
new RNSquarePosPackage(),
new RNCameraPackage(),
new RNGestureHandlerPackage(),
new VectorIconsPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
```
#### `AndroidManifest.xml`:
```xml
```
Environment
Click To Expand
**`react-native info` output:** ``` info React Native Environment Info: System: OS: macOS 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz Memory: 2.04 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.5.0 - /usr/local/bin/node npm: 6.10.2 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 27, 28 Build Tools: 27.0.3, 28.0.3 System Images: android-22 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom IDEs: Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: ^16.8.3 => 16.8.6 react-native: ^0.59.10 => 0.59.10 npmGlobalPackages: react-native-git-upgrade: 0.2.7 react-native: 0.59.0 ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] 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:** - `5.5.6` - **`Firebase` module(s) you're using that has the issue:** - `Cloud Messaging` - **Are you using `TypeScript`?** - `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]React Native Firebase
andInvertase
on Twitter for updates on the library.