Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change 'app' to ${project.archivesBaseName} #73919

Open
droplet-js opened this issue Jan 14, 2021 · 7 comments
Open

change 'app' to ${project.archivesBaseName} #73919

droplet-js opened this issue Jan 14, 2021 · 7 comments
Labels
c: proposal A detailed proposal for a change to Flutter P3 Issues that are less important to the Flutter project platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team

Comments

@droplet-js
Copy link

/// `$buildDir/app/outputs/flutter-apk/app-<abi>-<flavor-flag>-<build-mode-flag>.apk`

android-gradle-build-renaming-the-apk

@pedromassangocode
Copy link

Hi @v7lin
Can you please elaborate the motivation of this proposal?
Why this is important?
Thank you

@pedromassangocode pedromassangocode added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Jan 14, 2021
@droplet-js
Copy link
Author

Hi @v7lin
Can you please elaborate the motivation of this proposal?
Why this is important?
Thank you

it is not important. but it is useful.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 14, 2021
@pedromassangocode
Copy link

pedromassangocode commented Jan 14, 2021

It is important to know why a change should be made.
Ca you elaborate why this is useful?

@pedromassangocode pedromassangocode added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 14, 2021
@droplet-js
Copy link
Author

droplet-js commented Jan 15, 2021

It is important to know why a change should be made.
Ca you elaborate why this is useful?

the ${project.archivesBaseName} default value is 'app', it will not cause break change.
i will use it rename apk

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 15, 2021
@pedromassangocode pedromassangocode added passed first triage platform-android Android applications specifically c: proposal A detailed proposal for a change to Flutter tool Affects the "flutter" command-line tool. See also t: labels. and removed in triage Presently being triaged by the triage team labels Jan 15, 2021
@jmagman jmagman added the t: gradle "flutter build" and "flutter run" on Android label Jan 20, 2021
@jmagman
Copy link
Member

jmagman commented Jan 20, 2021

I think this is a request to build the APK to known location based on app name instead of hardcoding "app-" prefix? The referenced referenced is in dart, project.archivesBaseName is a Gradle property.

See also #54328

@PerLycke
Copy link

@jmagman I think he wants to be able to rename the apk / bundle without getting errors.

For example if you perform

flutter build appbundle

with the following defaultConfig:

defaultConfig {
    applicationId "some.app"
    minSdkVersion 24
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    **archivesBaseName = "app-${builtType}-${versionName}-${versionCode}.apk"**
}

It will eventually throw the following error stating an unsupported Android Plugin:

[ 4 ms] Unsupported Android Plugin version: 7.0.0.
[ 1 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 getGradleVersionFor (package:flutter_tools/src/android/gradle_utils.dart:181:3)
#2 getGradleVersionForAndroidPlugin (package:flutter_tools/src/android/gradle_utils.dart:124:10)
#3 _exitWithExpectedFileNotFound (package:flutter_tools/src/android/gradle.dart:1031:3)
#4 findBundleFile (package:flutter_tools/src/android/gradle.dart:1011:3)
#5 AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:516:31)

@GaryQian GaryQian added the P3 Issues that are less important to the Flutter project label Jul 26, 2022
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-android Owned by Android platform team triaged-android Triaged by Android platform team labels Jul 8, 2023
@droplet-js
Copy link
Author

droplet-js commented Jan 12, 2024

@jmagman we can use the following code to get app bundle file / apk file

// https://github.com/android/gradle-recipes/blob/agp-8.1/getSingleArtifact/build-logic/plugins/src/main/kotlin/CustomPlugin.kt
// https://gist.github.com/ychescale9/fffef60e49de36375698997b277fab9d
// https://github.com/Triple-T/gradle-play-publisher/blob/master/play/plugin/src/main/kotlin/com/github/triplet/gradle/play/PlayPublisherPlugin.kt#L216C23-L216C63
def builtArtifacts = variant.artifacts.getBuiltArtifactsLoader().load(variant.artifacts.get(SingleArtifact.APK).get()) ?: throw RuntimeException("Cannot load APKs")
def apkFile = File(builtArtifacts.elements.single().outputFile) // apk
// https://github.com/android/gradle-recipes/blob/agp-8.1/getSingleArtifact/build-logic/plugins/src/main/kotlin/CustomPlugin.kt#L47
def bundleFile = variant.artifacts.get(SingleArtifact.BUNDLE).get().asFile // aab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: proposal A detailed proposal for a change to Flutter P3 Issues that are less important to the Flutter project platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels. triaged-android Triaged by Android platform team
Projects
None yet
Development

No branches or pull requests

6 participants