Created
July 10, 2024 13:49
-
-
Save SambasBoyyyy/ee6e589508d38fe5e770bfbc66d5d84d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
// ... | |
maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal | |
} | |
dependencies { | |
// ... | |
// OneSignal-Gradle-Plugin | |
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]' | |
} | |
} | |
def localProperties = new Properties() | |
def localPropertiesFile = rootProject.file('local.properties') | |
if (localPropertiesFile.exists()) { | |
localPropertiesFile.withReader('UTF-8') { reader -> | |
localProperties.load(reader) | |
} | |
} | |
def flutterRoot = localProperties.getProperty('flutter.sdk') | |
if (flutterRoot == null) { | |
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | |
} | |
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | |
if (flutterVersionCode == null) { | |
flutterVersionCode = '5' | |
} | |
def flutterVersionName = localProperties.getProperty('flutter.versionName') | |
if (flutterVersionName == null) { | |
flutterVersionName = '2.0' | |
} | |
def envProperties = new Properties() | |
def envPropsFile = rootProject.file('../configs/env.props') | |
def envPropertiesFile = rootProject.file('../configs/env.properties') | |
if (envPropertiesFile.exists() && envPropsFile.exists()) { | |
println "=====================================================================" | |
println "⚠️ Warning: env.properties is deprecated, please rename to env.props" | |
println "=====================================================================" | |
} | |
if (envPropertiesFile.exists() && !envPropsFile.exists()) { | |
println "=================================================================" | |
println "⚠️ Warning: env.properties is deprecated and should not be used" | |
println "🪄️ env.properties has been renamed to env.props automatically" | |
println "=================================================================" | |
ant.move file: '../../configs/env.properties', tofile: '../../configs/env.props' | |
} | |
envPropsFile = rootProject.file('../configs/env.props') | |
envPropertiesFile = rootProject.file('../configs/env.properties') | |
if (envPropsFile.exists()) { | |
println "🔧 Loading configs from configs/env.props..." | |
envPropsFile.withReader('UTF-8') { reader -> | |
envProperties.load(reader) | |
} | |
} else { | |
if (envPropertiesFile.exists()) { | |
println "🔧 Loading configs from configs/env.properties..." | |
envPropertiesFile.withReader('UTF-8') { reader -> | |
envProperties.load(reader) | |
} | |
} | |
} | |
apply plugin: 'com.android.application' | |
apply plugin: 'com.google.gms.google-services' | |
apply plugin: 'kotlin-android' | |
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | |
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' | |
android { | |
compileSdkVersion 34 | |
ndkVersion "25.1.8937393" | |
sourceSets { | |
main.java.srcDirs += 'src/main/kotlin' | |
} | |
lintOptions { | |
disable 'InvalidPackage' | |
checkReleaseBuilds false | |
} | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
kotlinOptions { | |
jvmTarget = '1.8' | |
} | |
tasks.withType(JavaCompile) { | |
options.warnings = false | |
} | |
defaultConfig { | |
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | |
applicationId envProperties['androidPackageName'] | |
minSdkVersion 21//flutter.minSdkVersion | |
// targetSdkVersion flutter.targetSdkVersion | |
targetSdkVersion 34 // flutter.targetSdkVersion | |
versionCode flutterVersionCode.toInteger()//4003 | |
versionName '3.2'//flutterVersionName | |
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |
multiDexEnabled true | |
resConfigs "en" | |
manifestPlaceholders += [ | |
envatoPurchaseCode: envProperties['envatoPurchaseCode'], | |
websiteUrl: envProperties['websiteUrl'], | |
websiteDomain: envProperties['websiteDomain'], | |
customScheme: envProperties['customScheme'], | |
googleApiKeyAndroid: envProperties['googleApiKeyAndroid'], | |
adMobAppIdAndroid: envProperties['adMobAppIdAndroid'], | |
facebookClientToken: envProperties['facebookClientToken'], | |
facebookLoginProtocolScheme: envProperties['facebookLoginProtocolScheme'] | |
] | |
resValue 'string', 'facebookAppId', envProperties['facebookAppId'] | |
resValue 'string', 'app_name', envProperties['appName'] | |
} | |
signingConfigs { | |
release { | |
keyAlias envProperties['keyAlias'] | |
keyPassword envProperties['keyPassword'] | |
storeFile rootProject.file('../configs/' + envProperties['storeFile']) | |
storePassword envProperties['storePassword'] | |
} | |
} | |
buildTypes { | |
release { | |
// TODO: Add your own signing config for the release build. | |
// Signing with the debug keys for now, so `flutter run --release` works. | |
signingConfig signingConfigs.release | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
ndk { | |
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' | |
} | |
} | |
debug { | |
signingConfig signingConfigs.release | |
} | |
} | |
} | |
flutter { | |
source '../..' | |
} | |
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" | |
testImplementation 'junit:junit:4.12' | |
androidTestImplementation 'androidx.test:runner:1.1.1' | |
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' | |
implementation 'com.google.android.material:material:1.6.0' | |
implementation 'com.android.support:multidex:1.0.3' | |
implementation 'androidx.browser:browser:1.3.0' | |
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0' | |
implementation 'com.google.android.recaptcha:recaptcha:18.4.0' | |
implementation 'com.google.android.gms:play-services-location:21.2.0' | |
implementation platform('com.google.firebase:firebase-bom:32.8.1') | |
implementation 'com.google.firebase:firebase-analytics' | |
implementation 'com.google.android.play:integrity:1.3.0' | |
} | |
googleServices { disableVersionCheck = true } | |
task copyGoogleServices(type: Copy) { | |
from '../../configs' | |
include 'google-services.json' | |
into '.' | |
} | |
task copyConfigFiles(type: Copy) { | |
from '../../configs/customized/' | |
include '**' | |
into '../../' | |
} | |
println "🔧 Copying configs/google-services.json to android/app/google-services.json" | |
preBuild.dependsOn(copyGoogleServices) | |
println "🔧 Copying configs/customized to project..." | |
println "\n🪄 Building " + envProperties['appName'] + "... 🪄\n" | |
println "\n🔑 Signing with keystore " + envProperties['storeFile'] + "... 🔑\n" | |
preBuild.dependsOn(copyConfigFiles) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment