th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.09k stars 191 forks source link

Solve build issue with gradle >8.0 #397

Closed mlopezscrm closed 1 year ago

mlopezscrm commented 1 year ago

Hi, if u are having problems with gradle 8.0 just use this patch and problem solved.

diff --git a/android/build.gradle b/android/build.gradle
index 448140f6b54523ebd142bf695f47446fbb11085b..890015d8ee2359b57794a2489871f88600f1e7bd 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -30,6 +30,7 @@ if (isNewArchitectureEnabled()) {
 }

 android {
+    namespace = "com.th3rdwave.safeareacontext"
     compileSdkVersion getExtOrDefault('compileSdkVersion', 30)

   // Used to override the NDK path/version on internal CI or by allowing
janicduplessis commented 1 year ago

Should be fixed in last version

durejagaurav commented 1 year ago

A problem occurred configuring project ':react-native-safe-area-context'.

Failed to notify project evaluation listener. com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.api.GradleException: Adding a Configuration as a dependency is no longer allowed as of Gradle 8.0. KotlinJvmAndroidCompilation with name 'debug' not found.

Please help me solve this.

durejagaurav commented 1 year ago

Patch also not working

mlopezz1 commented 1 year ago

This is not related with the same, can u post ur build gradle? And also app/build.gradle

durejagaurav commented 1 year ago

Build Gradle......

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { ext { buildToolsVersion = "33.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33 kotlinVersion = "1.4.10"

    // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
    ndkVersion = "23.1.7779620"
}
repositories {
    google()
    mavenCentral()
}
dependencies {
    classpath("com.android.tools.build:gradle")
    classpath("com.facebook.react:react-native-gradle-plugin")
}

}

app/build.gradle:

apply plugin: "com.android.application" apply plugin: "com.facebook.react"

/**

/**

/**

android {

ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

namespace "com.xyz"
defaultConfig {
    applicationId "com.xyz"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

}

dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
    implementation("com.facebook.react:hermes-android")
} else {
    implementation jscFlavor
}

}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)