mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-11-23 12:57:58 +00:00
Play Console flagged the bundle: DEX optimisation low, obfuscation 1%, no deobfuscation file, no native debug symbols. Release builds now run R8 with resource shrinking and put the native symbol table in the bundle; play-upload.mjs --mapping uploads mapping.txt. Release APK 6.45 MB -> 3.35 MB. Capacitor's consumer rules keep every plugin class: the seven plugins, MainActivity and AlwaysVisibleWebView keep their names in mapping.txt.
94 lines
4.1 KiB
Groovy
94 lines
4.1 KiB
Groovy
apply plugin: 'com.android.application'
|
|
|
|
import groovy.json.JsonSlurper
|
|
|
|
// Version from package.json, so the APK and the web app share one number.
|
|
// versionCode = major*10000 + minor*100 + patch (1.24.0 -> 12400).
|
|
def pkgVersion = new JsonSlurper().parse(file('../../package.json')).version
|
|
def (vMajor, vMinor, vPatch) = pkgVersion.tokenize('.').collect { it.replaceAll(/[^0-9].*$/, '').toInteger() }
|
|
|
|
// Release signing reads android/keystore.properties (gitignored; it names the keystore
|
|
// and its passwords). Without that file a release build is left unsigned.
|
|
def keystoreProps = new Properties()
|
|
def keystorePropsFile = rootProject.file('keystore.properties')
|
|
if (keystorePropsFile.exists()) keystorePropsFile.withInputStream { keystoreProps.load(it) }
|
|
|
|
android {
|
|
namespace = "eu.on8ar.coredriverx"
|
|
compileSdk = rootProject.ext.compileSdkVersion
|
|
defaultConfig {
|
|
applicationId "eu.on8ar.coredriverx"
|
|
minSdkVersion rootProject.ext.minSdkVersion
|
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
versionCode vMajor * 10000 + vMinor * 100 + vPatch
|
|
versionName pkgVersion
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
aaptOptions {
|
|
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
|
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
|
|
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
|
|
}
|
|
}
|
|
signingConfigs {
|
|
release {
|
|
if (keystorePropsFile.exists()) {
|
|
storeFile file(keystoreProps['storeFile'])
|
|
storePassword keystoreProps['storePassword']
|
|
keyAlias keystoreProps['keyAlias']
|
|
keyPassword keystoreProps['keyPassword']
|
|
}
|
|
}
|
|
}
|
|
buildTypes {
|
|
release {
|
|
if (keystorePropsFile.exists()) signingConfig signingConfigs.release
|
|
// R8: shrinks and optimises the code (Play flagged "DEX optimisation: low").
|
|
// Plugins survive through Capacitor's own consumer rules, which keep every
|
|
// @CapacitorPlugin class and @PluginMethod. mapping.txt goes to Play with the
|
|
// bundle (scripts/play-upload.mjs) so crash reports stay readable.
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
// Symbols of the bundled native libraries go into the bundle for Play's crash reports.
|
|
ndk { debugSymbolLevel 'SYMBOL_TABLE' }
|
|
}
|
|
}
|
|
// The app only calls BarcodeScanner.scan(), which runs the Google code scanner in
|
|
// Play services. The bundled ML Kit detector (startScan, readBarcodesFromImage) is
|
|
// never used; its native library is about 20 MB over all ABIs.
|
|
packaging {
|
|
jniLibs {
|
|
excludes += ['lib/*/libbarhopper_v3.so']
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
flatDir{
|
|
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
|
|
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
|
|
implementation project(':capacitor-android')
|
|
testImplementation "junit:junit:$junitVersion"
|
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
implementation project(':capacitor-cordova-android-plugins')
|
|
}
|
|
|
|
apply from: 'capacitor.build.gradle'
|
|
|
|
try {
|
|
def servicesJSON = file('google-services.json')
|
|
if (servicesJSON.text) {
|
|
apply plugin: 'com.google.gms.google-services'
|
|
}
|
|
} catch(Exception e) {
|
|
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
|
}
|