Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use the new Android app bundle architecture with RN 0.57?

Tags:

App bundles: https://developer.android.com/guide/app-bundle/ This allows Google Play to manage signing, decrease the app size, and allows for pulling code on demand which is really awesome!

I tried setting this up but Android studio kept telling me I need to update my gradle version?

Here is my 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"
}

Is it possible for me to be able to use the app bundles? Or will I have to install wait until the RN community supports it?

like image 236
James111 Avatar asked Nov 23 '18 00:11

James111


1 Answers

You don’t necessarily need to use Android Studio to compile a release build of a React Native project.

Normally you would use this command to compile a release build.

./gradlew assembleRelease

If you want to use Android App Bundle, you use the following instead.

./gradlew bundleRelease

The resulting build will be found in this folder: android/app/build/outputs/bundle/release/app.aab

This blog elaborates more on the steps.

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

like image 197
L.U. Avatar answered Sep 19 '22 17:09

L.U.