Add release stuff

This commit is contained in:
izzy2lost
2025-08-13 22:01:12 -04:00
parent 82b2951ae3
commit 0cead2ccb0
5 changed files with 347 additions and 24 deletions
+68 -4
View File
@@ -7,11 +7,30 @@ else {
apply plugin: 'com.android.library'
}
// Load keystore properties
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace("com.starship.android")
buildFeatures {
buildConfig true
}
// Signing configuration
signingConfigs {
release {
if (keystorePropertiesFile.exists()) {
storeFile file(keystoreProperties['STARSHIP_STORE_FILE'])
storePassword keystoreProperties['STARSHIP_STORE_PASSWORD']
keyAlias keystoreProperties['STARSHIP_KEY_ALIAS']
keyPassword keystoreProperties['STARSHIP_KEY_PASSWORD']
}
}
}
ndkVersion "26.0.10792818"
compileSdkVersion 33
defaultConfig {
@@ -20,14 +39,19 @@ android {
}
minSdkVersion 24
targetSdkVersion 33
versionCode 5
versionName "1.0.0"
versionCode 6
versionName "1.0.1"
externalNativeBuild {
cmake {
arguments "-DSDL_SHARED=ON", "-DANDROID_STL=c++_static", "-DHAVE_LD_VERSION_SCRIPT=OFF",'-DUSE_OPENGLES=ON'
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
}
// Optimize APK size
vectorDrawables {
useSupportLibrary true
}
}
// ✅ Universal APK: disables split APKs per ABI
@@ -38,9 +62,31 @@ android {
}
buildTypes {
release {
debug {
debuggable true
jniDebuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources false
}
release {
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// Enable R8 full mode for better optimization
android.enableR8.fullMode = true
// Optimize native libraries
ndk {
debugSymbolLevel 'NONE'
}
// Sign the release build
if (keystorePropertiesFile.exists()) {
signingConfig signingConfigs.release
}
}
}
applicationVariants.all { variant ->
@@ -60,8 +106,26 @@ android {
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
// Additional optimizations
packagingOptions {
// Exclude unnecessary files to reduce APK size
excludes += [
'META-INF/DEPENDENCIES',
'META-INF/LICENSE',
'META-INF/LICENSE.txt',
'META-INF/NOTICE',
'META-INF/NOTICE.txt',
'META-INF/*.kotlin_module'
]
// Pick first occurrence of duplicate files
pickFirsts += ['**/libc++_shared.so', '**/libjsc.so']
}
if (buildAsLibrary) {
libraryVariants.all { variant ->
variant.outputs.each { output ->
+49 -15
View File
@@ -1,17 +1,51 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in [sdk]/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Starship Android ProGuard Rules
# Add any project specific keep options here:
# Keep SDL classes
-keep class org.libsdl.app.** { *; }
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Keep native methods
-keepclasseswithmembernames class * {
native <methods>;
}
# Keep MainActivity and its native methods
-keep class com.starship.android.MainActivity {
public static java.lang.String getSaveDir();
public static void waitForSetupFromNative();
public native void attachController();
public native void detachController();
public native void setButton(int, boolean);
public native void setCameraState(int, float);
public native void setAxis(int, short);
}
# Keep DialogActivity
-keep class com.starship.android.DialogActivity { *; }
# Keep ControllerButtons constants
-keep class com.starship.android.ControllerButtons { *; }
# Keep DocumentFile for SAF
-keep class androidx.documentfile.provider.DocumentFile { *; }
# Optimization settings
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
# Remove logging in release builds
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
# Keep line numbers for crash reports
-keepattributes SourceFile,LineNumberTable
# Rename source file attribute to something shorter
-renamesourcefileattribute SourceFile