compileSdkVersion is not specified error in React Native Android

22,791

Solution 1

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.

Solution 2

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

Share:
22,791
sflow
Author by

sflow

Updated on February 14, 2022

Comments

  • sflow
    sflow about 2 years

    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?

  • sflow
    sflow almost 5 years
    Hmm...I downgraded and restarted to build again, but it didn't work.
  • Esmail Jamshidiasl
    Esmail Jamshidiasl about 4 years
    actually this is the answer. when you type mistakes then gradle crash at that word and fails to read all build.gradle file and cannot see min sdk or other settings
  • verunar
    verunar over 2 years
    I don't understand, what is the solution you are proposing? move to node_modules and what?
  • Admin
    Admin over 2 years
    @verunar Change above mentioned versions to same as your app's versions