Skip to content

Update engine artifacts for Android #33059

Closed

Description

@blasten

These are the current Engine artifacts for Android:

├── android-arm
│   └── flutter.jar
├── android-arm-profile
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── flutter.jar
├── android-arm-release
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── flutter.jar
├── android-arm64
│   └── flutter.jar
├── android-arm64-profile
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── flutter.jar
├── android-arm64-release
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── flutter.jar
├── android-x64
│   ├── flutter.jar
│   └── libflutter.so
├── android-x86
│   ├── flutter.jar
│   └── libflutter.so

Once Flutter starts generating 32 and 64 bits in app bundles, these artifacts are better structured this way:

├── android
│   └── flutter.jar    // <-- io.flutter .class
├── android-arm-release
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── libflutter.so
├── android-arm64
│   └── libflutter.so
├── android-arm64-profile
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── libflutter.so
├── android-arm64-release
│   ├── darwin-x64
│   │   └── gen_snapshot
│   └── libflutter.so
├── android-x64
│   └── libflutter.so
├── android-x86
│   └── libflutter.so

Note that libflutter.so is already outside flutter.jar in x64 and x86.

This change will:

  • Reduce the size of the artifacts downloaded from Google CDN.
  • Simplify the Gradle build script and potentially make the build faster.

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    t: gradle"flutter build" and "flutter run" on Android
    platform-androidAndroid applications specifically
    on May 20, 2019
  2. blasten commented on May 20, 2019

    @blasten
    Author

    Actually, this new structure may increase the size of the artifacts by 28M. (663M -> 691M)

  3. jason-simmons commented on May 20, 2019

    @jason-simmons
    Member

    The engine Java build scripts generate a BuildConfig.java file containing flags indicating whether this is a debug, profile, or release build. Some embedder Java code is conditional on these flags.

    So we would need to ship different flutter.jar binaries for debug, profile, and release.

    Some options:

    • Use the current format where each target platform has its own flutter.jar which includes libflutter.so. If the APK needs to support multiple ABIs, then extract the libflutter.so binaries for the other ABIs from those platforms' flutter.jar files.
    • Ship separate versions of flutter.jar containing only Java code for debug, profile, and release. Alongside each flutter.jar, provide libflutter.so binaries for each supported target platform. The libflutter.so files could be packaged inside JARs that place them within that platform's lib/$ABI path.
  4. blasten commented on May 21, 2019

    @blasten
    Author

    Thanks for the background @jason-simmons. This is helpful!

    Use the current format where each target platform has its own flutter.jar which includes libflutter.so. If the APK needs to support multiple ABIs, then extract the libflutter.so binaries for the other ABIs from those platforms' flutter.jar files.

    This is the implementation after my changes.

    On a side note, do you know why libflutter.so is duplicated in x64 & x86 (it's in flutter.jar and also outside)?

    File flutterX86Jar = project.file("${project.buildDir}/${AndroidProject.FD_INTERMEDIATES}/flutter/flutter-x86.jar")
    Task debugX86JarTask = project.tasks.create("${flutterBuildPrefix}X86Jar", Jar) {
    destinationDir flutterX86Jar.parentFile
    archiveName flutterX86Jar.name
    from("${flutterRoot}/bin/cache/artifacts/engine/android-x86/libflutter.so") {
    into 'lib/x86'
    }
    from("${flutterRoot}/bin/cache/artifacts/engine/android-x64/libflutter.so") {
    into 'lib/x86_64'
    }
    }

    Also, it doesn't seem like like android-x64/flutter.jar or android-x86/flutter.jar is ever used.

  5. jason-simmons commented on May 21, 2019

    @jason-simmons
    Member

    I think we were distributing libflutter.so artifacts for all platforms in the early days of Flutter before flutter.jar existed.

    The libflutter.so artifacts were removed after the migration to flutter.jar on most platforms. But they had to be kept around for x86/x64 because the Gradle script was using them to create ARM/x86/x64 APKs in debug mode.

  6. hnvn commented on May 21, 2019

    @hnvn

    This update would resolve this issue, doesn't it? Currently, I cannot run my (released) Flutter app in x86 devices. This issue is known and still stays there for a long time.

  7. blasten commented on Jun 15, 2019

    @blasten
    Author
  8. blasten commented on Oct 10, 2019

    @blasten
    Author

    Gradle now consumes Flutter Maven artifacts, so this issue isn't relevant at this point.

  9. github-actions commented on Aug 27, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    engineflutter/engine related. See also e: labels.platform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions