Skip to content

Commit 7d28f6e

Browse files
authored
[android] fix release build always crashing because of proguard problems (#28)
1 parent 28e3e11 commit 7d28f6e

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

android/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ dependencies {
8888
natives(variantOf(libs.gdx.freetype.platform) { classifier("natives-x86_64") })
8989
implementation(libs.play.services.games)
9090
implementation(libs.gdx.gamesvcs.android.gpgs)
91+
implementation(libs.androidx.core)
9192
}
9293

9394
tasks.named("preBuild").configure {

android/proguard-rules.pro

+23-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# include property in project.properties.
99
#
1010
# For more details, see
11-
# http://developer.android.com/guide/developing/tools/proguard.html
11+
# https://developer.android.com/guide/developing/tools/proguard.html
1212

1313
# Add any project specific keep options here:
1414

@@ -23,17 +23,11 @@
2323

2424
-dontwarn android.support.**
2525
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
26-
-dontwarn com.badlogic.gdx.utils.GdxBuild
27-
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
28-
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
29-
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
3026

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

33-
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
34-
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
35-
}
36-
30+
# Needed by the Box2D official extension.
3731
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
3832
boolean contactFilter(long, long);
3933
void beginContact(long);
@@ -42,4 +36,23 @@
4236
void postSolve(long, long);
4337
boolean reportFixture(long);
4438
float reportRayFixture(long, float, float, float, float, float);
45-
}
39+
}
40+
41+
# You will need the next three lines if you use scene2d for UI or gameplay.
42+
# If you don't use scene2d at all, you can remove or comment out the next line:
43+
-keep public class com.badlogic.gdx.scenes.scene2d.** { *; }
44+
# You will need the next two lines if you use BitmapFont or any scene2d.ui text:
45+
-keep public class com.badlogic.gdx.graphics.g2d.BitmapFont { *; }
46+
# You will probably need this line in most cases:
47+
-keep public class com.badlogic.gdx.graphics.Color { *; }
48+
49+
# These two lines are used with mapping files; see https://developer.android.com/build/shrink-code#retracing
50+
-keepattributes LineNumberTable,SourceFile
51+
-renamesourcefileattribute SourceFile
52+
53+
# Until https://github.com/kotcrab/vis-ui/issues/395 is resolved
54+
-keep class com.kotcrab.vis.ui.** { *; }
55+
-dontwarn com.apple.eio.FileManager
56+
57+
58+
-keep class com.badlogic.gdx.graphics.g2d.GlyphLayout { *; }

gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ org.gradle.jvmargs=-Xmx1536M
22
android.useAndroidX=true
33
org.gradle.parallel=true
44
org.gradle.caching=true
5+
6+
# TODO: Enable full mode back
7+
android.enableR8.fullMode=false

gradle/libs.versions.toml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ robovm = "2.3.22"
55
gamesvcs = "1.1.0"
66
visui = "1.5.3"
77
playServicesGames = "23.2.0"
8+
androidx = "1.13.1"
89

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

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

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

0 commit comments

Comments
 (0)