Not able to build for android

react-native run-android-android
info Starting JS server…
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)…
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Configure project :react-native-device-info
WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-fabric
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: 
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from /home/devendradora/projects/android/DiscourseMobile/node_modules/react-native/android

> Configure project :react-native-key-pair
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: 
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-orientation
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-vector-icons
WARNING: The specified Android SDK Build Tools version (26.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /home/devendradora/projects/android/DiscourseMobile/node_modules/react-native/android

> Task :app:processDebugGoogleServices
Parsing json file: /home/devendradora/projects/android/DiscourseMobile/android/app/google-services.json

> Task :react-native-firebase:compileDebugJavaWithJavac
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:8: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:5: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:11: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:21: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:36: error: cannot find symbol
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
    ^
  symbol:   class LocalBroadcastManager
  location: class RNFirebaseMessaging
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java:36: error: cannot find symbol
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
                                                  ^
  symbol:   variable LocalBroadcastManager
  location: class RNFirebaseMessaging
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:26: error: cannot find symbol
    LocalBroadcastManager
    ^
  symbol:   variable LocalBroadcastManager
  location: class RNFirebaseMessagingService
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:41: error: cannot find symbol
      LocalBroadcastManager
      ^
  symbol:   variable LocalBroadcastManager
  location: class RNFirebaseMessagingService
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java:51: error: cannot find symbol
        LocalBroadcastManager
        ^
  symbol:   variable LocalBroadcastManager
  location: class RNFirebaseMessagingService
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:54: error: cannot find symbol
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
    ^
  symbol:   class LocalBroadcastManager
  location: class RNFirebaseNotifications
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotifications.java:54: error: cannot find symbol
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
                                                  ^
  symbol:   variable LocalBroadcastManager
  location: class RNFirebaseNotifications
/home/devendradora/projects/android/DiscourseMobile/node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseNotificationManager.java:204: error: cannot find symbol
      LocalBroadcastManager
      ^
  symbol:   variable LocalBroadcastManager
  location: class RNFirebaseNotificationManager
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.
12 errors

> Task :react-native-firebase:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

@devendradora can you try adding a gradle.properties file in /android with the following contents:

android.useDeprecatedNdk=true
android.useAndroidX=true
android.enableJetifier=true

and then running the run-android command again? Let me know if that doesn’t work.

3 Likes

Thank you Dear @pmusaraj

I have updated gradle.properties but still getting error.

  • I have updated below in a branch checkout from master after cloning to temporarily fix various errors .
  1. In android/app/build.gradle
  • commented versionName MYAPP_VERSION

  • commented signingConfigs

  1. updated android/gradle.properties

android.useDeprecatedNdk=true
android.useAndroidX=true
android.enableJetifier=true

It would be really helpful, if package.json and build.gradle is updated so that there is no build failure

Please find logs. pasted in pastebin
https://pastebin.com/md6dHHd1

Thank you for all your help.

Make sure you’ve pulled the repository and cleaned your build (either in Android Studio or via Gradle). This sounds like an issue with caches, once they’re cleared, the build should run.

1 Like

Thank you dear @pmusaraj
I once again tried a fresh git clone and build project in windows , linux and mac os , but same error.

Is it possible for you to kindly share the latest package.json and build.gradle

thank you.

What is your version of gradle and java?

1 Like

I tried all the steps specified , but still it fails throwing following error

**Execution failed for task ':react-native-firebase:compileDebugJavaWithJavac'.**
**> Compilation failed; see the compiler error output for details.**

**java -version**
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-2-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)


**Gradle version**
Tried gradle-4.10.2 , gradle-5.1.1
1 Like

You can try upgrading your openjdk to version to 12 or look into the compiler logs for more details on that specific errors.

3 Likes

Hey,
So I was also getting similar kind of errors and found out that some of the libraries require Java8 support…so as we have to manually install these versions in android studio version 3 and later…so do you also followed the same path coz I want to be sure before making a change to the build tools?

1 Like