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

Changes to make minifyEnabled work... #1063

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Changes to make minifyEnabled work... #1063

wants to merge 1 commit into from

Conversation

bitmold
Copy link
Collaborator

@bitmold bitmold commented Jan 25, 2024

Was testing this and it seems to work, shaves off some megabytes.

It ought to be tested more thoroughly, but I'm confident with what I've seen so far. Open to feedback, of coruse.

You either need to make release builds, or do what I was doing and just change the release part of buildTypes in each module's build.gradle to debug...

Again, would kindly appreciate your thoroughness here @syphyr

@bitmold bitmold requested a review from n8fr8 January 25, 2024 05:04
@syphyr
Copy link
Contributor

syphyr commented Jan 25, 2024

Is it necessary to add the org.slf4j:slf4j-simple:1.6.1 implementation and additional proguard rules in order to minify the build?

@syphyr
Copy link
Contributor

syphyr commented Jan 25, 2024

Everything seems fine after applying this commit. I also tried removing the proguard and slf4j changes since they did not seem to be necessary.

@syphyr
Copy link
Contributor

syphyr commented Jan 25, 2024

Oh, I see now that slf4j and additional proguard rules are required for minify. Sorry about that..
WARNING:R8: Missing class org.slf4j.impl.StaticLoggerBinder
Now i see why you added them ;-)

@syphyr
Copy link
Contributor

syphyr commented Jan 25, 2024

is crunchPngs true also something we want?

@syphyr
Copy link
Contributor

syphyr commented Jan 25, 2024

Also, since the resources become obfuscated by R8, maybe jniDebuggable false is also appropriate for this.

@syphyr
Copy link
Contributor

syphyr commented Jan 26, 2024

@bitmold When I started testing this on the master branch, I ran into an error because of AGP 8. This is what I did to solve the issue: syphyr@7ec449f

@syphyr
Copy link
Contributor

syphyr commented Jan 28, 2024

Minify is causing a bug with retrofit2 by renaming the classes. This causes a fatal exception when selecting the "Ask Tor" feature. I have tried to fix this issue by using the examples here, but so far I have been unsuccessful:
https://stackoverflow.com/questions/35506111/retrofit-2-not-sending-data-when-proguard-is-enabled

@bitmold if you have any further suggestions on this issue, please let me know.

@syphyr
Copy link
Contributor

syphyr commented Jan 28, 2024

One suggestion on fixing the retrofit2 issue was to add Keep annotations, but that seems to also not be working.

--- a/app/src/main/java/org/torproject/android/circumvention/CircumventionApi.kt
+++ b/app/src/main/java/org/torproject/android/circumvention/CircumventionApi.kt
@@ -12,10 +12,11 @@ import retrofit2.converter.gson.GsonConverterFactory
 import retrofit2.http.Body
 import retrofit2.http.GET
 import retrofit2.http.POST
+import androidx.annotation.Keep
 import java.net.InetSocketAddress
 import java.net.Proxy
 
-
+@Keep
 interface CircumventionEndpoints {
 
     @GET("countries")

@bitmold
Copy link
Collaborator Author

bitmold commented Jan 28, 2024 via email

@syphyr
Copy link
Contributor

syphyr commented Jan 28, 2024

Using the @keep annotations seems like the easiest approach. Here is some further info that seems useful:
https://stackoverflow.com/questions/6548213/how-to-keep-classes-containing-specific-members

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants