Am being forced to upgrade to gradle 8.2 by app owner but the normally working app fails now with the error compileSdkVersion not specified error. I am pretty sure I have defined it in build.gradle but lost what be the cause of it all. Here are my build.gradle files.
the app is built with react version 17.0.2 and react-native version 0.67.4.
project/build.gradle
buildscript {
ext.kotlin_version = '1.6.10'
ext {
minSdkVersion = 22
compileSdkVersion = 31
targetSdkVersion = 31
buildToolsVersion = "29.0.3"
}
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.3')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://repo1.maven.org/maven2' }
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
//maven { url 'https://dl.bintray.com' }
maven { url("$rootDir/../node_modules/detox/Detox-android") }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
google()
mavenCentral()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
app/build.gradle
apply plugin: "com.android.application"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
import com.android.build.OutputFile
project.ext.react = [
enableHermes: false, // clean and rebuild if changing,
hermesFlagsRelease: ["-w", "-O", "-output-source-map"], // add this,
hermesFlagsDebug: ["-w", "-O", "-output-source-map"], // add this,
bundleAssetName: "index.android.bundle",
entryFile: "index.js",
bundleInDebug: false,
bundleInRelease: true,
devDisabledInStaging: true,
root: "../../",
jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
jsBundleDirRelease: "$buildDir/intermediates/assets/release",
resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
devDisabledInRelease : true,
devDisabledInDebug : false,
cliPath : "../../node_modules/react-native/cli.js",
deleteDebugFilesForVariant: {
def variant ->
variant.name.toLowerCase().contains("release") || variant.name.toLowerCase().contains("debug")
},
hermesFlagsForVariant: {
def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('beta') ? ['-w'] : []
}
]
project.ext.sentryCli = [
logLevel: "debug",
sentryProperties: "../sentry.properties"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
def enableSeparateBuildPerCPUArchitecture = true
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = true
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", true);
project.ext.envConfigFiles = [
debug: ".env",
release: "release.env",
// stagingrelease: ".env.staging",
// productionrelease: ".env.production"
]
//to avoid building issues with mahcrest and junit in so emlibraries, likely signaturepad
//https://stackoverflow.com/questions/59085448/duplicate-class-org-hamcrest-basedescription-found-in-modules-jetified-hamcrest
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('org.hamcrest:hamcrest-core:1.1') with module('junit:junit:4.12')
}
}
android {
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
}
compileSdkVersion rootProject.ext.compileSdkVersion
kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8 }
// ndkVersion '21.3.6528147' // The version installed on build machines, see https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "org.oneacrefund.fieldapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 41
versionName "1.8.7"
multiDexEnabled true
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk true // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
}
release {
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
matchingFallbacks = ['release']
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
stagingrelease {
initWith(buildTypes.release)
applicationIdSuffix ".staging"
}
productionrelease {
initWith release
}
}
packagingOptions {
pickFirst '**/*.so'
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
}
// 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:
// https://developer.android.com/studio/build/configure-apk-splits.html
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
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:0.67.3" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'com.couchbase.lite:couchbase-lite-android:3.0.0'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
androidTestImplementation('com.wix:detox:+') { transitive = true }
androidTestImplementation 'junit:junit:4.12'
implementation "androidx.annotation:annotation:1.1.0"
//implementation 'com.google.code.gson:gson:2.8.6'
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation project(':flipper-plugin-rn-performance-android')
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
debugImplementation ("com.facebook.flipper:flipper-leakcanary2-plugin:${FLIPPER_VERSION}"){
exclude group:'com.facebook.fbjni'
}
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
implementation "androidx.core:core-ktx:1.6.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(':reactnativesignaturecapture')
}
// 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'
}
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'MaterialCommunityIcons.ttf' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
repositories {
mavenCentral()
}