Commit 36ac8d24 authored by DatHV's avatar DatHV
Browse files

cập nhật build os

parent 873fba2d
import java.util.Properties
import java.io.FileInputStream
import groovy.json.JsonSlurper
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("org.jetbrains.kotlin.android")
id("com.google.gms.google-services")
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "com.icom.mypoint"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
flutter {
// path tới thư mục gốc Flutter project
source = "../.."
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
// --- Signing (optional) ---
val keystoreProps = Properties().apply {
val f = rootProject.file("key.properties")
if (f.exists()) load(FileInputStream(f))
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
// --- Helper đọc env.json theo flavor ---
fun readEnvJson(flavor: String): Map<String, Any> {
val envFile = file("src/$flavor/assets/config/env.json")
return if (envFile.exists()) {
val json = JsonSlurper().parseText(envFile.readText()) as Map<String, Any>
json
} else {
mapOf(
"baseUrl" to "https://api.sandbox.mypoint.com.vn/8854/gup2start/rest",
"t3Token" to "default_token",
"enableLogging" to true
)
}
}
android {
namespace = "com.icom.mypoint"
compileSdk = 36
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.icom.mypoint"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
signingConfigs {
create("release") {
if (keystoreProps.getProperty("storeFile") != null) {
storeFile = file(keystoreProps.getProperty("storeFile"))
storePassword = keystoreProps.getProperty("storePassword")
keyAlias = keystoreProps.getProperty("keyAlias")
keyPassword = keystoreProps.getProperty("keyPassword")
}
}
}
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.getByName("debug")
getByName("debug") {
isMinifyEnabled = false
}
getByName("release") {
signingConfig = signingConfigs.findByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
isCoreLibraryDesugaringEnabled = true
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
buildConfig = true
}
// --- Flavors giữ nguyên ENV của bạn ---
flavorDimensions += "environment"
productFlavors {
create("dev") {
dimension = "environment"
val env = readEnvJson("dev")
buildConfigField("String", "BASE_URL", "\"${env["baseUrl"]}\"")
buildConfigField("String", "LIB_TOKEN", "\"${env["t3Token"]}\"")
buildConfigField("boolean", "ENABLE_LOGGING", "${env["enableLogging"]}")
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
}
create("stg") {
dimension = "environment"
val env = readEnvJson("stg")
buildConfigField("String", "BASE_URL", "\"${env["baseUrl"]}\"")
buildConfigField("String", "LIB_TOKEN", "\"${env["t3Token"]}\"")
buildConfigField("boolean", "ENABLE_LOGGING", "${env["enableLogging"]}")
applicationIdSuffix = ".stg"
versionNameSuffix = "-stg"
}
create("pro") {
dimension = "environment"
val env = readEnvJson("pro")
buildConfigField("String", "BASE_URL", "\"${env["baseUrl"]}\"")
buildConfigField("String", "LIB_TOKEN", "\"${env["t3Token"]}\"")
buildConfigField("boolean", "ENABLE_LOGGING", "${env["enableLogging"]}")
}
}
}
flutter {
source = "../.."
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
implementation(platform("com.google.firebase:firebase-bom:33.3.0"))
implementation("com.google.firebase:firebase-messaging")
}
{
"project_info": {
"project_number": "1010760838494",
"firebase_url": "https://mypoint-ef484.firebaseio.com",
"project_id": "mypoint-ef484",
"storage_bucket": "mypoint-ef484.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1010760838494:android:fcc285d7290a38eddd33cf",
"android_client_info": {
"package_name": "com.icom.mypoint"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDChaLnKgTMa9EbRuugJ0niYxrcEO4y0vU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:1010760838494:android:924647a469832666dd33cf",
"android_client_info": {
"package_name": "com.icom.mypoint.dev"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDChaLnKgTMa9EbRuugJ0niYxrcEO4y0vU"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
{
"name":"dev",
"baseUrl":"https://api.sandbox.mypoint.com.vn/8854/gup2start/rest",
"t3Token":"dev-xxx",
"enableLogging":true
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FEE440</color>
</resources>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="mypoint_flutter_app"
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
......@@ -27,12 +29,20 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
android:value="2"/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="default_channel"
/>
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
......
package com.icom.mypoint
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
class MainActivity : FlutterActivity()
class MainActivity : FlutterActivity() {
private val channelName = "com.icom.mypoint/config"
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channelName).setMethodCallHandler { call, result ->
when (call.method) {
"getConfig" -> {
val flavor = BuildConfig.FLAVOR
val baseUrl = BuildConfig.BASE_URL
val libToken = BuildConfig.LIB_TOKEN
val enableLogging = BuildConfig.ENABLE_LOGGING
result.success(mapOf(
"flavor" to flavor,
"baseUrl" to baseUrl,
"libToken" to libToken,
"enableLogging" to enableLogging
))
}
else -> result.notImplemented()
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment