Skip to content

Commit

Permalink
[android] fix release build always crashing because of proguard probl…
Browse files Browse the repository at this point in the history
…ems (#28)
  • Loading branch information
bartekpacia authored Jan 4, 2025
1 parent 28e3e11 commit 7d28f6e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dependencies {
natives(variantOf(libs.gdx.freetype.platform) { classifier("natives-x86_64") })
implementation(libs.play.services.games)
implementation(libs.gdx.gamesvcs.android.gpgs)
implementation(libs.androidx.core)
}

tasks.named("preBuild").configure {
Expand Down
33 changes: 23 additions & 10 deletions android/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# https://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

Expand All @@ -23,17 +23,11 @@

-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild

# Needed by the gdx-controllers official extension.
-keep class com.badlogic.gdx.controllers.android.AndroidControllers

-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}

# Needed by the Box2D official extension.
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
boolean contactFilter(long, long);
void beginContact(long);
Expand All @@ -42,4 +36,23 @@
void postSolve(long, long);
boolean reportFixture(long);
float reportRayFixture(long, float, float, float, float, float);
}
}

# You will need the next three lines if you use scene2d for UI or gameplay.
# If you don't use scene2d at all, you can remove or comment out the next line:
-keep public class com.badlogic.gdx.scenes.scene2d.** { *; }
# You will need the next two lines if you use BitmapFont or any scene2d.ui text:
-keep public class com.badlogic.gdx.graphics.g2d.BitmapFont { *; }
# You will probably need this line in most cases:
-keep public class com.badlogic.gdx.graphics.Color { *; }

# These two lines are used with mapping files; see https://developer.android.com/build/shrink-code#retracing
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFile

# Until https://github.com/kotcrab/vis-ui/issues/395 is resolved
-keep class com.kotcrab.vis.ui.** { *; }
-dontwarn com.apple.eio.FileManager


-keep class com.badlogic.gdx.graphics.g2d.GlyphLayout { *; }
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
org.gradle.parallel=true
org.gradle.caching=true

# TODO: Enable full mode back
android.enableR8.fullMode=false
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ robovm = "2.3.22"
gamesvcs = "1.1.0"
visui = "1.5.3"
playServicesGames = "23.2.0"
androidx = "1.13.1"

[libraries]
gdx = { module = "com.badlogicgames.gdx:gdx", version.ref = "gdx" }
Expand All @@ -18,6 +19,7 @@ gdx-freetype-platform = { module = "com.badlogicgames.gdx:gdx-freetype-platform"
robovm-rt = { module = "com.mobidevelop.robovm:robovm-rt", version.ref = "robovm" }
robovm-cocoatouch = { module = "com.mobidevelop.robovm:robovm-cocoatouch", version.ref = "robovm" }

androidx-core = { module = "androidx.core:core", version.ref = "androidx" }
play-services-games = { module = "com.google.android.gms:play-services-games", version.ref = "playServicesGames" }

gdx-gamesvcs-core = { module = "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core", version.ref = "gamesvcs" }
Expand Down

0 comments on commit 7d28f6e

Please sign in to comment.