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

feature: Disable Obfuscation #7

Merged
merged 3 commits into from
Sep 20, 2023

Conversation

wba2hi
Copy link
Contributor

@wba2hi wba2hi commented Sep 18, 2023

Closes: #5

Closes: eclipse-kuksa#5
Signed-Off-By: Andre Weber <andre.weber3@etas.com>
To easily locate shrinking issues (e.g. missing Proguard Consumer rules)
I enabled shrinking for the TestApp when it is build with the optional
parameter "minify".
@wba2hi
Copy link
Contributor Author

wba2hi commented Sep 18, 2023

I checked how other open source libraries are dealing with obfuscation. The majority simply removed the buildTypes.release branch and disabled therefore obfuscation / shrinking by simply using the default values. Some Projects simply set isMinifyEnabled to false.

When checking OkHttp I saw that they still enabled minify for debug builds when they are build with an optional property. I think that this is to find shrinking issues and took this approach over.

Checked Projects:

`LeakCanary
https://github.com/square/leakcanary/blob/main/leakcanary/leakcanary-android/build.gradle
=> no BuildTypes specified => Release uses default settings => minify is disabled per default

OkHttp
https://github.com/square/okhttp/blob/master/okhttp-android/build.gradle.kts
=> no BuildTypes specified => Release uses default settings => minify is disabled per default

EventBus
https://github.com/greenrobot/EventBus/blob/master/eventbus-android/build.gradle
=> no BuildTypes specified => Release uses default settings => minify is disabled per default

=> Introducion of separate parameter "minify" to test obfuscation
https://github.com/square/leakcanary/blob/main/samples/leakcanary-android-sample/build.gradle

Picasso
https://github.com/square/picasso/blob/master/picasso/build.gradle
=> no BuildTypes specified => Release uses default settings => minify is disabled per default

Glide
https://github.com/bumptech/glide/blob/master/library/build.gradle
=> no BuildTypes specified => Release uses default settings => minify is disabled per default

Keyframes:
https://github.com/facebookarchive/Keyframes/blob/master/android/keyframes/build.gradle
=> minify disabled

DBFlow
https://github.com/agrosner/DBFlow/blob/master/lib/build.gradle.kts
=> no BuildTypes specified => Release uses default settings => minify is disabled per default

https://github.com/agrosner/DBFlow/blob/master/coroutines/build.gradle.kts
=> minify disabled`

isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
// for local builds, used to find shrinking issues
val isMinify = project.hasProperty("minify")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this parameter / property to my global gradle.properties to always have shrinking enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allright :)

debug {
// while isDebuggable is set to true no obfuscation takes place,
// the shrinking phase will still remove unused classes
isDebuggable = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically true is the default value here, it was added here basically just to make the comment more clear.

When playing around I was wondering why the classes were not obfuscated when adding this. I tested the behavior by adding an "UnusedClass" to the SDK. Since shrinking is disabled in the SDK it was not removed from the corresponding build aar. However when building the TestApp with the minify parameter it was correctly removed during shrinking when it was unused from inside the TestApp. When the TestApp was using the class, it was correctly left intact

@Chrylo
Copy link
Contributor

Chrylo commented Sep 20, 2023

@SebastianSchildt LGTM, can be merged

@SebastianSchildt SebastianSchildt merged commit 804e8e4 into eclipse-kuksa:main Sep 20, 2023
3 checks passed
@Chrylo Chrylo deleted the feature-5 branch October 11, 2023 13:05
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.

Disable Obfuscation
3 participants