#!/bin/bash

set -e

export BUILD_TIME=$(date +%s000)

ROOT_WD=$PWD

# related to https://github.com/facebook/react-native/issues/25290#issuecomment-507629926
cd android/app/src/main/res/
# Remove all previously generated drawable resources to avoid conflicts
rm -rf drawable-*/src_assets_img_*.png drawable-*/node_modules_*.png
cd $ROOT_WD
rm -rf android/app/build/generated/*

cd android
./gradlew bundleRelease

echo "find your bundle here: file://./android/app/build/outputs/bundle/release/app-release.aab"