Skip to content

Instantly share code, notes, and snippets.

@Software78
Last active May 10, 2025 23:47
Show Gist options
  • Select an option

  • Save Software78/97b4ce4dd783f22f60aab261c1034b1c to your computer and use it in GitHub Desktop.

Select an option

Save Software78/97b4ce4dd783f22f60aab261c1034b1c to your computer and use it in GitHub Desktop.
LadyBug fix
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null || namespace.isEmpty()) {
def defaultNamespace = project.group.toString().replace('.', '_')
namespace = defaultNamespace
}
buildFeatures {
buildConfig = true
}
}
// Task to ensure namespace and remove package attribute
project.tasks.register("fixManifestsAndNamespace") {
doLast {
// Ensure namespace in build.gradle
def buildGradleFile = file("${project.projectDir}/build.gradle")
if (buildGradleFile.exists()) {
def buildGradleContent = buildGradleFile.getText('UTF-8')
def manifestFile = file("${project.projectDir}/src/main/AndroidManifest.xml")
if (manifestFile.exists()) {
def manifestContent = manifestFile.getText('UTF-8')
def packageName = manifestContent.find(/package="([^"]+)"/) { match, p -> p }
if (packageName && !buildGradleContent.contains("namespace")) {
println "Setting namespace in ${buildGradleFile}"
buildGradleContent = buildGradleContent.replaceFirst(
/android\s*\{/, "android {\n namespace '${packageName}'"
)
buildGradleFile.write(buildGradleContent, 'UTF-8')
}
}
}
// Remove package attribute from AndroidManifest.xml
def manifests = fileTree(dir: project.projectDir, includes: ['**/AndroidManifest.xml'])
manifests.each { File manifestFile ->
def manifestContent = manifestFile.getText('UTF-8')
if (manifestContent.contains('package=')) {
println "Removing package attribute from ${manifestFile}"
manifestContent = manifestContent.replaceAll(/package="[^"]*"/, '')
manifestFile.write(manifestContent, 'UTF-8')
}
}
}
}
// Ensure the task runs before the build process
project.tasks.matching { it.name.startsWith("preBuild") }.all {
dependsOn project.tasks.named("fixManifestsAndNamespace")
}
}
}
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace "com.sendmonee.app"
compileSdkVersion flutter.compileSdkVersion
ndkVersion "27.0.12077973"
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.sendmonee.app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 24
targetSdkVersion 35
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
if (System.getenv("ANDROID_KEYSTORE_PATH")) {
release {
storeFile file(System.getenv("ANDROID_KEYSTORE_PATH"))
keyAlias System.getenv("ANDROID_KEYSTORE_ALIAS")
keyPassword System.getenv("ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD")
storePassword System.getenv("ANDROID_KEYSTORE_PASSWORD")
}
} else {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
}
flavorDimensions "default"
productFlavors {
production {
dimension "default"
applicationIdSuffix ""
manifestPlaceholders = [appName: "App Name"]
}
staging {
dimension "default"
applicationIdSuffix ".dev"
manifestPlaceholders = [appName: "App Name Beta"]
}
development {
dimension "default"
applicationIdSuffix ".dev"
manifestPlaceholders = [appName: "[DEV] App Name"]
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
debug {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:33.7.0')
implementation("com.google.firebase:firebase-analytics")
implementation ('com.google.firebase:firebase-messaging')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
}
#Mon Dec 16 09:32:29 WAT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.2" apply false
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
id "com.google.gms.google-services" version '4.4.2' apply false
}
include ":app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment