The minCompileSdk (31) specified in a dependency's AAR metadata is greater than this module's compileSdkVersion (android-30) in React native

Viewed 35

I am currently upgrading my React native Project that was created using React-native cli I upgraded all the dependencies from package.json except react-native and react as: -

 "dependencies": {
"@monterosa/react-native-parallax-scroll": "^1.8.0",
"@notifee/react-native": "^5.7.0",
"@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-community/progress-bar-android": "^1.0.4",
"@react-native-community/progress-view": "^1.3.2",
"@react-native-firebase/app": "^15.4.0",
"@react-native-firebase/messaging": "^15.4.0",
"frisbee": "^3.1.4",
"immutability-helper": "^3.1.1",
"lodash": "^4.17.21",
"native-base": "^3.4.15",
"react": "17.0.1",
"react-icons": "^4.4.0",
"react-native": "0.63.4",
"react-native-a": "^1.0.1",
"react-native-app-intro-slider": "^4.0.4",
"react-native-facebook-login": "^1.6.2",
"react-native-fast-image": "^8.6.1",
"react-native-firebase-push-notifications": "^2.0.2",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.6.0",
"react-native-image-crop-picker": "^0.38.0",
"react-native-in-app-utils": "^6.1.0",
"react-native-loading-spinner-overlay": "^3.0.1",
"react-native-localization": "^2.3.1",
"react-native-material-dialog": "^0.7.7",
"react-native-modal": "^13.0.1",
"react-native-music-control": "^1.4.1",
"react-native-music-player-service": "^0.1.4-beta",
"react-native-popup-menu": "^0.16.1",
"react-native-push-notification": "^8.1.1",
"react-native-restart": "^0.0.24",
"react-native-screens": "^3.17.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-sound": "^0.11.2",
"react-native-splash-screen": "^3.3.0",
"react-native-super-grid": "^4.5.1",
"react-native-swift": "^1.2.3",
"react-native-swiper": "^1.6.0",
"react-native-track-player": "^3.1.0",
"react-native-typing-text": "^0.0.3",
"react-native-vector-icons": "^9.2.0",
"react-native-webview": "^11.23.1",
"react-navigation": "^4.4.4",
"react-redux": "^8.0.2",
"react-timeago": "^7.1.0",
"realm": "^10.21.1",
"redux": "^4.2.0",
"redux-saga": "^1.2.1",
"rn-sliding-up-panel": "^2.4.6",
"toggle-switch-react-native": "^3.3.0"

}, "devDependencies": { "@babel/core": "^7.4.5", "@babel/runtime": "^7.4.5", "babel-jest": "^25.1.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "schedule": "^0.5.0" },

After running the Android develop build command, facing this issue

enter image description here

I tried all things like forcing the gradle to use 31 sdk for minSDK, targetSDK, and compileSDK, and also adding this to build.gradle (project level)

configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}

For your reference, I am adding a build.Gradle here: -

apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
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,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // 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: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,
]

apply from: "../../node_modules/react-native/react.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

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);


android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    ndkVersion "22.0.7026061"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    defaultConfig {
            applicationId "com.loveworld.worship"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            missingDimensionStrategy "RNN.reactNativeVersion", "reactNative56"
            versionCode 31
            versionName "3.9"
            vectorDrawables.useSupportLibrary = true
            multiDexEnabled true
            ndk {
                abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
            }
        }
        signingConfigs {
                debug {
                    storeFile file('debug.keystore')
                    storePassword 'android'
                    keyAlias 'androiddebugkey'
                    keyPassword 'android'
                }
                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 {
            signingConfig signingConfigs.debug
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
        mySpecialRelease {
            matchingFallbacks = ['release', 'debug']
        }
    }
    // 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, "arm64-v8a": 3, "x86_64": 4]
            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
            }
        }
    }

    compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
     }
}

dependencies {
    implementation project(':@react-native-async-storage_async-storage')
    implementation project(':react-native-facebook-login')
    implementation project(':react-native-firebase-push-notifications')
    implementation'com.facebook.soloader:soloader:0.9.0+'
    implementation project(':react-native-screens')
    implementation project(':react-native-restart')
    implementation project(':react-native-track-player')
    implementation project(':realm')
    implementation project(':react-native-fs')
    implementation project(':react-native-music-control')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-localization')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-image-crop-picker')
    implementation project(':react-native-sound')
    implementation project(':react-native-fast-image')
    implementation 'com.android.support:multidex:1.0.1'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    if (enableHermes) {
        // for RN 0.61+
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

// 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'
}

I tried the solutions given in the other question of Stackoverflow, but had no luck still. Can anyone help me with this

Thank you

0 Answers
Related