I'm getting the following error when trying to build our react-native project for android. Initial issue was that libraries were requiring firebase-iid:17.1.2 instead of firebase-iid:17.1.1. However, when updating this version we get the error below. We have not made any code changes to our code which was previously building fine (2 days ago):
Build error:
> Task :react-native-firebase:compileDebugJavaWithJavac FAILED
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:26: error: incompatible types: RNFirebaseMessagingService cannot be converted to Context
.getInstance(this)
^
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:41: error: incompatible types: RNFirebaseMessagingService cannot be converted to Context
.getInstance(this)
^
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:46: error: cannot find symbol
if (Utils.isAppInForeground(this.getApplicationContext())) {
^
symbol: method getApplicationContext()
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:51: error: incompatible types: RNFirebaseMessagingService cannot be converted to Context
.getInstance(this)
^
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:57: error: cannot find symbol
this.getApplicationContext(),
^
symbol: method getApplicationContext()
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:62: error: cannot find symbol
.getApplicationContext()
^
symbol: method getApplicationContext()
/Volumes/code/work/circularwave/marketplace/app/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:64: error: cannot find symbol
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
^
symbol: method getApplicationContext()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 errors
FAILURE: Build failed with an exception.
android/build.gradle:// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlinVersion = '1.3.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
flatDir {
dirs 'libs'
}
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-basement:16.2.0'
force 'com.google.android.gms:play-services-tasks:16.0.1'
force 'com.google.android.gms:play-services-base:16.1.0'
force 'com.google.android.gms:play-services-iid:16.0.1'
force 'com.google.firebase:firebase-iid:17.1.2'
force 'com.google.firebase:firebase-analytics:16.0.4'
}
}
}
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
}
}
}
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion rootProject.ext.supportLibVersion
}
}
}
}
ext {
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "28.0.3"
supportLibVersion = "26.1.0"
}
android/app/build.gradle: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,
*
* // 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"
// 2nd line, add a new apply:
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.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
aaptOptions {
cruncherEnabled false
}
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.cw.cw"
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 83
versionName "4.8"
multiDexEnabled true
testBuildType System.getProperty('testBuildType', 'debug') //this will later be used to control the test apk build type
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
debug {
debuggable true
buildConfigField 'String', 'INTERCOM_API_ANDROID_KEY', '"android_sdk-97eb0b9401d8d2de5593ae646b5e749355ce06e8"'
buildConfigField 'String', 'INTERCOM_API_ANDROID_ID', '"ik5dhd9y"'
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
buildToolsVersion = rootProject.ext.buildToolsVersion;
// 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 {
implementation project(':react-native-firebase')
implementation project(':react-native-aes-encryption')
implementation project(':react-native-vector-icons')
implementation project(':react-native-photo-view')
implementation project(':react-native-navigation')
implementation project(':react-native-intercom')
implementation project(':react-native-image-resizer')
implementation project(':react-native-fetch-blob')
implementation project(':react-native-config')
implementation (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
implementation 'com.android.support:exifinterface:27.+'
implementation ('com.google.android.gms:play-services-vision:12.0.1') {
force = true
}
}
implementation project(':bugsnag-react-native')
implementation (project(':react-native-device-info')) {
exclude group: 'com.google.android.gms'
}
implementation project(':react-native-config')
implementation (project(':react-native-push-notification')) {
exclude group: 'com.google.android.gms'
}
implementation fileTree(dir: "libs", include: ["*.jar"])
//compile 'com.onfido.api.client:onfido-api-client:+'
implementation 'com.android.support:design:26.0.1'
//compile(name:'onfido-capture-sdk-release-no-launcher-icon', ext:'aar')
//compile 'com.onfido.sdk.capture:onfido-capture-sdk:+'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:0.20.1" // From node_modules
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
//this overrides the sdk play services dependency, without the app crashes, because there can only be one version of google play services
implementation ('com.google.android.gms:play-services-base:16.1.0') {
force = true;
}
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.google.firebase:firebase-firestore:18.2.0'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.google.firebase:firebase-invites:16.0.4'
implementation ('com.google.android.gms:play-services-gcm:16.1.0')
implementation ('com.google.android.gms:play-services-auth:16.0.1')
implementation ('com.google.android.gms:play-services-location:16.0.0')
implementation ('com.google.android.gms:play-services-places:16.0.0')
implementation ('com.google.android.gms:play-services-basement:16.2.0')
implementation ('com.google.android.gms:play-services-tasks:16.0.1')
/*implementation ('com.google.android.gms:play-services-measurement-base:16.0.4') {*/
//force = true;
/*}*/
implementation 'io.intercom.android:intercom-sdk-base:5.+'
androidTestImplementation(project(path: ":detox"))
androidTestImplementation 'junit:junit:4.12'
}
// 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'
}
repositories {
flatDir {
dirs 'libs'
}
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
//// Work around for gradle-plugin compatibility
//com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
android/settings.gradle:rootProject.name = 'marketplace'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':detox'
project(':detox').projectDir = new File(rootProject.projectDir, '../node_modules/detox/android/detox')
include ':react-native-aes-encryption'
project(':react-native-aes-encryption').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-aes-encryption/android')
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-photo-view'
project(':react-native-photo-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-photo-view/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app')
include ':react-native-intercom'
project(':react-native-intercom').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-intercom/android')
include ':react-native-image-resizer'
project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':bugsnag-react-native'
project(':bugsnag-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/bugsnag-react-native/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':app'
MainApplication.java:package com.cw.cw;
import android.app.Application;
import android.util.Log;
import org.reactnative.camera.RNCameraPackage;
import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import fnd.reactaes.reactaes.ReactAESPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnative.photoview.PhotoViewPackage;
import com.bugsnag.BugsnagReactNative;
import io.intercom.android.sdk.Intercom;
import com.robinpowered.react.Intercom.IntercomPackage;
import fr.bamlab.rnimageresizer.ImageResizerPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import io.invertase.firebase.storage.RNFirebaseStoragePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.firestore.RNFirebaseFirestorePackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.links.RNFirebaseLinksPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
import com.reactnativenavigation.NavigationApplication;
public class MainApplication extends NavigationApplication {
//@Override
//protected void attachBaseContext(Context base) {
//super.attachBaseContext(base);
//MultiDex.install(this);
//}
@Override
public boolean isDebug() {
// Make sure you are using BuildConfig from your own application
return BuildConfig.DEBUG;
}
protected List<ReactPackage> getPackages() {
// Add additional packages you require here
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNFirebasePackage(),
new ReactAESPackage(),
new ReactNativePushNotificationPackage(),
new IntercomPackage(),
BugsnagReactNative.getPackage(),
new RNDeviceInfo(),
new RNFirebasePackage(),
new RNFirebaseFirestorePackage(),
new RNFirebaseAuthPackage(),
new RNFirebaseStoragePackage(),
new RNFirebaseDatabasePackage(),
new RNFirebaseLinksPackage(),
new ReactNativeConfigPackage(),
new ImageResizerPackage(),
new RNFetchBlobPackage(),
new PhotoViewPackage(),
new VectorIconsPackage(),
new RNCameraPackage()
);
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
@Override
public void onCreate() {
super.onCreate();
BugsnagReactNative.start(this);
SoLoader.init(this, /* native exopackage */ false);
Intercom.initialize(this, BuildConfig.INTERCOM_API_ANDROID_KEY, BuildConfig.INTERCOM_API_ANDROID_ID);
}
}
AndroidManifest.xml:<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cw.cw"
android:versionCode="60"
android:versionName="4.8"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.cw.cw.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.cw.cw.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-sdk
android:targetSdkVersion="25" />
<application tools:replace="android:allowBackup"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.cw.cw" />
</intent-filter>
</receiver>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.robinpowered.react.Intercom.IntercomIntentService"
android:exported="false">
<intent-filter
android:priority="999">
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
<receiver
android:name="io.intercom.android.sdk.push.IntercomPushBroadcastReceiver"
tools:replace="android:exported"
android:exported="true" />
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="com.cw.cw"
/>
<data android:scheme="http"
android:host="com.cw.cw"
/>
<data android:scheme="com.cw.cw"
android:host="passwordReset"
/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.bugsnag.android.API_KEY" android:value="b104fd79ff6ef7ceb0d6b517ae26fcd3" />
</application>
</manifest>
N/AN/AN/AReact Native version:0.59.4 (issue initially seen on 0.57.x, same issue when upgrading)React Native Firebase library version:5.3.0 (initially seen on 5.5.1, same issue when upgrading)Firebase module(s) you're using that has the issue:TypeScript?ExpoKit?node_modules/react-native-firebase/android/build.gradle
Had the same issue as you and after digging around for a while it appears that the following needs to be up to the latest version:
// Cloud Messaging / FCM
compileOnly "com.google.firebase:firebase-messaging:17.5.0"
should be:
// Cloud Messaging / FCM
compileOnly "com.google.firebase:firebase-messaging:17.6.0"
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.
Most helpful comment
node_modules/react-native-firebase/android/build.gradle
Had the same issue as you and after digging around for a while it appears that the following needs to be up to the latest version:
should be: