Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIVIDE APK SIZE BY 2 IN 2 LINES YOU WON'T BELIEVE THAT ONE TRICK #8331

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ HELP_FUN = \
}
HOST_OS := $(shell uname | tr '[:upper:]' '[:lower:]')

# Defines which variables will be kept for Nix pure shell, use semicolon as divider
export NIX_KEEP ?= BUILD_ENV
export NIX_CONF_DIR = $(PWD)/nix

export REACT_SERVER_PORT ?= 5001 # any value different from default 5000 will work; this has to be specified for both the Node.JS server process and the Qt process
Expand Down Expand Up @@ -101,21 +103,22 @@ prod-build:
lein prod-build

prod-build-android: export TARGET_OS ?= android
prod-build-android: export BUILD_ENV ?= prod
prod-build-android:
BUILD_ENV=prod lein prod-build-android && \
lein prod-build-android && \
node prepare-modules.js

prod-build-ios: export TARGET_OS ?= ios
prod-build-ios: export BUILD_ENV = prod
prod-build-ios: export BUILD_ENV ?= prod
prod-build-ios:
BUILD_ENV=prod lein prod-build-ios && \
lein prod-build-ios && \
node prepare-modules.js

prod-build-desktop: export TARGET_OS ?= $(HOST_OS)
prod-build-desktop: export BUILD_ENV = prod
prod-build-desktop: export BUILD_ENV ?= prod
prod-build-desktop:
git clean -qdxf -f ./index.desktop.js desktop/ && \
BUILD_ENV=prod lein prod-build-desktop && \
lein prod-build-desktop && \
node prepare-modules.js

#--------------
Expand Down
7 changes: 2 additions & 5 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}



defaultConfig {
applicationId "im.status.ethereum"
minSdkVersion 23
Expand All @@ -159,7 +157,7 @@ android {
versionCode getVersionCode()
versionName getVersionName()
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86-64"
abiFilters getEnvOrConfig('NDK_ABI_FILTERS').split(';')
}
}
/**
Expand All @@ -179,7 +177,6 @@ android {
exclude 'META-INF/rxjava.properties'
exclude '/lib/mips64/**'
exclude '/lib/arm64-v8a/**'
exclude '/lib/x86_64/**'
/** Fix for: Execution failed for task ':app:transformNativeLibsWithStripDebugSymbolForDebug'.
* with recent version of ndk (17.0.4754217)
*/
Expand All @@ -204,7 +201,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
include "armeabi-v7a", "arm64-v8a", "x86"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you still include x86 here after all?

Copy link
Member Author

@jakubgs jakubgs Jun 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration section isn't used right now since enableSeparateBuildPerCPUArchitecture is set to false:
https://github.com/status-im/status-react/blob/c2b55233225f6e4d59c9ca5174b5261cc1137fec/android/app/build.gradle#L97
And that means that this section, which normally would have caused Gradle to build a separate APK for each platform, does nothing. I'm just adding arm64-v8a to match what we have set in ndk.abiFilters.

Now, since it seems to be necessary for dev builds, because devs use the emulator, x86 should be included by default, which is the ndk.abiFilters setting, but for pr, release, and nightly builds(except for e2e ones) it will be removed by setting the NDK_ABI_FILTERS env variable in android.gradlke.
See:
https://github.com/status-im/status-react/pull/8331/files#diff-921ddb8a284f72367049b92eff26b9b6R10

}
}
buildTypes {
Expand Down
3 changes: 3 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ STATUS_RELEASE_STORE_PASSWORD=password
STATUS_RELEASE_KEY_ALIAS=status
STATUS_RELEASE_KEY_PASSWORD=password

# platforms for which to build the Android bundle
NDK_ABI_FILTERS=armeabi-v7a;arm64-v8a;x86

org.gradle.jvmargs=-Xmx8704M
18 changes: 12 additions & 6 deletions ci/android.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ def bundle() {
/* Disable Gradle Daemon https://stackoverflow.com/questions/38710327/jenkins-builds-fail-using-the-gradle-daemon */
def gradleOpt = "-PbuildUrl='${currentBuild.absoluteUrl}' -Dorg.gradle.daemon=false "
def target = "release"
/* we don't need x86 for any builds except e2e */
env.NDK_ABI_FILTERS="armeabi-v7a;arm64-v8a"

if (params.BUILD_TYPE == 'pr') {
/* PR builds shouldn't replace normal releases */
target = 'pr'
} else if (btype == 'release') {
gradleOpt += "-PreleaseVersion='${utils.getVersion()}'"
switch (btype) {
case 'pr': /* PR builds shouldn't replace normal releases */
target = 'pr'; break;
case 'e2e':
target = 'pr';
env.NDK_ABI_FILTERS="x86"; break
case 'release':
gradleOpt += "-PreleaseVersion='${utils.getVersion('mobile_files')}'"
}

dir('android') {
withCredentials([
string(
Expand All @@ -28,7 +34,7 @@ def bundle() {
nix.shell(
"./gradlew assemble${target.capitalize()} ${gradleOpt}",
keep: [
'REALM_DISABLE_ANALYTICS',
'REALM_DISABLE_ANALYTICS', 'NDK_ABI_FILTERS',
'STATUS_RELEASE_STORE_FILE', 'STATUS_RELEASE_STORE_PASSWORD',
'STATUS_RELEASE_KEY_ALIAS', 'STATUS_RELEASE_KEY_PASSWORD'
]
Expand Down