20

I get the build error when I try to build an Android app in my React Native project.

When I run react-native run-android, it says:

> Configure project :react-native-os 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 FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':react-native-os'. > compileSdkVersion is not specified. 

In Android Studio, I can see that it says the same thing: Cause: compileSdkVersion is not specified.

So I edited build.gradle(Module: app) file in Android Studio, but the problem persists and the error message doesn't change.

android { // compileSdkVersion rootProject.ext.compileSdkVersion compileSdkVersion 28 buildToolsVersion "28.0.3" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 

I tried solutions in other threads like this one but nothing worked. Does anyone know what the problem is here?

0

8 Answers 8

7

I also faced the same issue solved by :

1- run npm i @react-native-firebase/app in terminal

2- follow these steps to add firebase to the android platform.

Sign up to request clarification or add additional context in comments.

1 Comment

why do we need firebase library if we are not using firebase?
3

Make sure that you have in android/app/build.gradle:

task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } 

(This error happened to me after I accidentally changed configurations.compile to configurations.implementation)

Comments

1

Easiest and effective solution if this is happening with react native Move to node_module/@react-native-firebase/ for all modules example- app, firestore etc. Go to their android folder and open build.gradle you will see,

project.ext { set('react-native', [ versions: [ android : [ minSdk : 'same your project version root folder/android/app/build.gradle', targetSdk : 'same your project version root folder/android/app/build.gradle', compileSdk: 'same your project version root folder/android/app/build.gradle', buildTools: 'same your project version root folder/android/app/build.gradle' ], firebase: [ bom: firebaseBomVersion, ], ], ]) } 

Hope this made it work. Happy Coding :)

2 Comments

I don't understand, what is the solution you are proposing? move to node_modules and what?
@verunar Change above mentioned versions to same as your app's versions
1

My issue was caused by node command not found by gradle.

# fixed by linking the node path to the /usr/bin/node # node is binary was located in $HOME/.nvm/versions/node/v14.13.0/bin/node sudo ln -s $(which node) /usr/bin/node 

When I run the above command the issue above disappeared.

If you are getting "Operation not permitted" error, please use the following:

# you might need to create the /usr/local/bin directory if it doesn't exist sudo ln -s $(which node) /usr/local/bin/node 

2 Comments

I'm getting "Operation not permitted on this answer" even when I use sudo
@UcheNkadi I have updated the answer to help with this issue.
1

i just solved my issue by install @react-native-firebase/app, i was using firebase messaging but firebase/app was not installed

Comments

1

Go to node_module>@react-native-firebase>messaging>android>build.gradle

Find code which defines min and target sdk and define the sdk and build version same as you have in your main project build.gradle file.

Then run command cd android && ./gradlew clean && cd ..

Also make sure you had defined default firebase config in your app level build.gradle Make sure you have this import on top your build.gradle : apply plugin: "com.google.gms.google-services" and an default config as :

defaultConfig { applicationId "..." minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 00 versionName "... multiDexEnabled true } 

Comments

0

I think you are using Android Supported Library.

If you are 27+ Supported Library you should use compileSdkVersion 27 and targetSdkVersion 27

1 Comment

Hmm...I downgraded and restarted to build again, but it didn't work.
0

Maybe I am too later to answer but the possible reason is if your build.gradle version is above 7 than you also may be getting the error of maven, Plugin with id ‘maven’ not found. If you try to follow the steps and solve that error that sdk compile error vanishes.

https://lifesaver.codes/answer/plugin-with-id-maven-not-found-12774

This worked in my case

2 Comments

I am in a similar situation. Sadly the link you posted does not work.
The link is not working

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.