androidBuildTypes
androidBuildTypes copied to clipboard
React Native - Companion Repo to android build medium post
Android + React Native + Fastlane: Working with multiple build types
This is the companion repository for my medium post.
Check out the React Native DevOps Guide!!!
The DevOps Guide includes concept discussion and step by step walkthroughs for setting up your own Jenkins agent and running iOS and Android builds, plus a whole lot more.
Running Android Builds, Part 4 - React Native DevOps Guide
Gradle Configurations
Global gradle.properties - defining node executable
# This file lives in ~/.gradle/gradle.properties
MYAPP_RELEASE_STORE_FILE=foo.keystore
MYAPP_RELEASE_KEY_ALIAS=foo-alias
MYAPP_RELEASE_STORE_PASSWORD=foo_store_release
MYAPP_RELEASE_KEY_PASSWORD=foo_key_release
org.gradle.daemon=true
NODE_PATH=[YOUR_HOME_PATH]/.nvm/versions/node/v[YOUR_NODE_VERSION]/bin/node
React ExtraPropertiesExtension
project.ext.react = [
entryFile: "index.js",
nodeExecutableAndArgs: hasProperty('NODE_PATH')?[NODE_PATH]:["node"],
bundleInDebug: false,
bundleInStaging: true,
bundleInRelease: true,
jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
jsBundleDirStaging: "$buildDir/intermediates/assets/staging",
resourcesDirStaging: "$buildDir/intermediates/res/merged/staging",
jsBundleDirRelease: "$buildDir/intermediates/assets/release",
resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
devDisabledInDebug: false,
devDisabledInStaging: true,
devDisabledInRelease: true,
inputExcludes: ["ios/**", "__tests__/**"]
];
new buildType, applicationIdSuffix, signingConfigs
buildTypes {
...
staging {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
applicationIdSuffix ".staging"
}
Fastlane Actions
Yarn install
yarn(
command: "install",
package_path: "./package.json"
)
Android versioning
ANDROID_VERSION_NAME = get_version_name(
gradle_file_path:"android/app/build.gradle",
ext_constant_name:"versionName"
)
ANDROID_VERSION_CODE = get_version_code(
gradle_file_path:"android/app/build.gradle",
ext_constant_name:"versionCode"
)
Adding badges
if options[:badge]
add_badge(
shield: "#{ANDROID_VERSION_NAME}-#{ANDROID_VERSION_CODE}-orange",
glob: "/android/app/src/main/res/mipmap-*/ic_launcher.png",
alpha: true,
shield_scale: "0.75"
)
end
Upload to Crashlytics
if ENV["CRASHLYTICS_API_KEY"] && ENV["CRASHLYTICS_BUILD_SECRET"]
crashlytics(
api_token: ENV["CRASHLYTICS_API_KEY"],
build_secret: ENV["CRASHLYTICS_BUILD_SECRET"],
groups: ["your-test-groups-here"],
notes: "#{ANDROID_VERSION_NAME}-#{ANDROID_VERSION_CODE} beta release - fastlane generated",
notifications: true
)
end
Upload to Play Store
if options[:play_store]
# upload to alpha track on google play developer's console
supply(track: "alpha", apk: "android/app/build/outputs/apk/app-release.apk")
end