1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] In Mobile Development, How to Validate If com.android.tools.build:gradle and...

Discussão em 'Mobile' iniciado por Stack, Novembro 7, 2024 às 23:32.

  1. Stack

    Stack Membro Participativo

    If Android Studio automatically inform the developer if there are deprecated code or deprecated declared configurations at any part of the mobile app project. How about if I developing a mobile app project aside from Android Studio (i.e., I am using Visual Studio Code to develop mobile app), and if Android Studio suggests a version changes if there's one such as under the dependencies (i.e., com.android.tools.build:gradle:version_value).

    Then, what are the articles should I read in order to undertand the proper configuration of build.gradle.

    What I want to understand is if I build an apk or an appbundle, I can say that my build is in the right state (e.g., The build.gradle is properly utilizing the SDK, sourceCompatibility, targetCompatibility, etc.).

    Is there someone can validate my mobile project infrastructure?

    These are my flutter doctor -v results:

    [√] Flutter (Channel stable, 3.24.1, on Microsoft Windows [Version 10.0.26100.2161], locale en-US)
    • Flutter version 3.24.1 on channel stable at C:\Users\alagu\FlutterSDK\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (3 months ago), 2024-08-20 16:46:00 -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

    [√] Windows Version (Installed version of Windows is version 10 or higher)

    [√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\alagu\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_SDK_ROOT = C:\Users\alagu\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)
    • All Android licenses accepted.

    [√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

    [√] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.10.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Enterprise
    • Visual Studio Enterprise 2022 version 17.10.35004.147
    • Windows 10 SDK version 10.0.22621.0

    [√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
    https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
    https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)

    [√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin can be installed from:
    https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
    https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)

    [√] VS Code (version 1.95.1)
    • VS Code at C:\Users\alagu\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.100.0

    [√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26100.2161]
    • Chrome (web) • chrome • web-javascript • Google Chrome 130.0.6723.93
    • Edge (web) • edge • web-javascript • Microsoft Edge 130.0.2849.68
    ! Device IP_ADDRESS:pORT(IT IS JUST AN ILLUSTRATION) is not authorized.
    You might need to check your device for an authorization dialog.

    [√] Network resources
    • All expected network resources are available.

    • No issues found!


    And this is my android/build.gradle configurations:

    buildscript {
    ext.kotlin_version = '1.9.23'//'1.6.21'
    repositories {
    google()
    mavenCentral()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:8.5.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
    }

    allprojects {
    repositories {
    google()
    mavenCentral()
    }
    }

    rootProject.buildDir = "../build"
    subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
    project.evaluationDependsOn(":app")
    }

    tasks.register("clean", Delete) {
    delete rootProject.buildDir
    }


    And this is android/app/build.gradle configurations:

    plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    // END: FlutterFire Configuration
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
    }

    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.rpi.raquelshowroom"
    compileSdk = flutter.compileSdkVersion //localProperties.getProperty("flutter.compileSdkVersion").toInteger() //flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion //localProperties.getProperty("flutter.ndkVersion").toInteger() //flutter.ndkVersion

    applicationVariants.all { variant ->
    variant.outputs.all {
    outputFileName = "RaquelShowroom-${variant.name}-${variant.versionName}.apk"
    }
    }

    compileOptions {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
    jvmTarget = JavaVersion.VERSION_17
    }

    defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId = "com.rpi.raquelshowroom"
    // 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.
    minSdk = localProperties.getProperty("flutter.minSdkVersion").toInteger() //flutter.minSdkVersion
    targetSdk = flutter.targetSdkVersion //localProperties.getProperty("flutter.targetSdkVersion").toInteger() //flutter.targetSdkVersion
    versionCode = flutterVersionCode.toInteger()
    versionName = flutterVersionName
    multiDexEnabled true
    }

    signingConfigs {
    release {
    keyAlias = keystoreProperties['keyAlias']
    keyPassword = keystoreProperties['keyPassword']
    storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
    storePassword = keystoreProperties['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.debug
    signingConfig = signingConfigs.release
    }
    }
    }

    flutter {
    source = "../.."
    }


    I know that I have nothing to be more worried about because my mobile app project was running properly in debug mode with a minimal effort of testing, but I realized that if my mobile app is deployed to production, then I need to be sure that it could not introduce build issues to different devices.

    Any insights from you guys? and I would really appreciate it.

    Continue reading...

Compartilhe esta Página