Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compileSdkVersion is not specified error in React Native Android

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?

like image 503
sflow Avatar asked Aug 07 '19 07:08

sflow


2 Answers

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.

like image 51
Amr Abdalrahman Avatar answered Oct 15 '22 10:10

Amr Abdalrahman


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 :)

like image 39
Arush pande Avatar answered Oct 15 '22 11:10

Arush pande