【问题标题】:Is it possible to use the new Android app bundle architecture with RN 0.57?是否可以在 RN 0.57 中使用新的 Android 应用程序包架构?
【发布时间】:2023-04-10 18:11:02
【问题描述】:

App 包:https://developer.android.com/guide/app-bundle/ 这允许 Google Play 管理签名、减小应用程序大小并允许按需提取代码,这真是太棒了!

我尝试进行设置,但 Android Studio 一直告诉我需要更新我的 gradle 版本?

这是我的 build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

task wrapper(type: Wrapper) {
    gradleVersion = '4.4' //version required
}

buildscript {
    repositories {
        /**
         * Must stay in this order
         */
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
            }
        }
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "$rootDir/../node_modules/react-native/android" }
        mavenCentral()
    }
}

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

我可以使用 app bundle 吗?还是我必须等到 RN 社区支持才安装?

【问题讨论】:

    标签: android react-native react-native-android android-app-bundle


    【解决方案1】:

    您不一定需要使用 Android Studio 来编译 React Native 项目的发布版本。

    通常你会使用这个命令来编译一个发布版本。

    ./gradlew assembleRelease

    如果您想使用 Android App Bundle,请改用以下内容。

    ./gradlew bundleRelease

    生成的构建将在此文件夹中找到: android/app/build/outputs/bundle/release/app.aab

    本博客详细介绍了这些步骤。

    https://blog.swmansion.com/make-your-react-native-app-3x-smaller-44c993eda2c9

    【讨论】:

    • 我的项目是 React Native 版本 53,当我运行 de command ./gradlew bundleRelease 它运行成功但没有生成任何东西。它只适用于 Reactn Native 59+?
    【解决方案2】:

    已经可以使用 Android App Bundle 发布 React Native 应用程序。自 3.2.0 起,Android Studio 和 Gradle 提供支持。

    【讨论】:

    • 您能详细说明一下吗?它是默认启用的还是我们需要在 gradle 文件上配置一些东西?我们是否应该像在 RN 上使用 proguard 一样谨慎使用它?
    • 您是否已成功设置以获取带有 RN 的 Android App Bundle?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    • 1970-01-01
    • 1970-01-01
    • 2011-09-08
    • 1970-01-01
    相关资源
    最近更新 更多