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

Android - Optimization #392

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

Conversation

AndrewEQ
Copy link
Contributor

  • added options for optimization:
"Android": {
"Optimize": {
"MinifyEnabled": true,
"ShrinkResources": true,
"DefaultAndroidProGuard": "proguard-android-optimize.txt",
"PrependRulesFile": "proguard-rules-prepend.pro",
"AppendRulesFile": "proguard-rules-append.pro"
},
...

Default android proguard rules(proguard-android.txt) are applied when not specified

"Android": {
"Optimize": {
"MinifyEnabled": true,
"ShrinkResources": true
},
...

Can add custom proguard rules before or after the main generated class rules:

"Android": {
"Optimize": {
"MinifyEnabled": true,
"ShrinkResources": true,
"PrependRulesFile": "proguard-rules-prepend.pro",
"AppendRulesFile": "proguard-rules-append.pro"
},
...

Create "proguard-rules-prepend.pro" in root of Project folder:

e.g.

MyApp/MainView.ux
MyApp/proguard-rules-prepend.pro

...

proguard-rules-prepend.pro

-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable

- added options for optimization:

```
"Android": {
"Optimize": {
"MinifyEnabled": true,
"ShrinkResources": true,
"DefaultAndroidProGuard": "proguard-android-optimize.txt",
"PrependRulesFile": "proguard-rules-prepend.pro",
"AppendRulesFile": "proguard-rules-append.pro"
},
...
```

Default android proguard rules(proguard-android.txt) are applied when not specified
```
"Android": {
"Optimize": {
"MinifyEnabled": true,
"ShrinkResources": true
},
...
```

Can add custom proguard rules before or after the main generated class rules:
```
"Android": {
"Optimize": {
"MinifyEnabled": true,
"ShrinkResources": true,
"PrependRulesFile": "proguard-rules-prepend.pro",
"AppendRulesFile": "proguard-rules-append.pro"
},
...
```

Create "proguard-rules-prepend.pro" in root of Project folder:

e.g.

MyApp/MainView.ux
MyApp/proguard-rules-prepend.pro

...

proguard-rules-prepend.pro
```
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
```
@AndrewEQ AndrewEQ requested a review from mortend March 26, 2021 11:38
Copy link
Member

@mortend mortend left a comment

Choose a reason for hiding this comment

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

I have added a few comments about naming.

@@ -79,6 +79,9 @@
<Set Outputs.AAR="app/build/outputs/aar/app-@(Build.Configuration:ToLower).aar" />
<Set Outputs.APK="app/build/outputs/apk/@(Build.Configuration:ToLower)/app-@(Build.Configuration:ToLower).apk" />
<Set Outputs.Bundle="app/build/outputs/bundle/@(Build.Configuration:ToLower)/app-@(Build.Configuration:ToLower).aab" />

<Set ProGuard.PrependRulesFile="@(Project.Android.Optimize.PrependRulesFile:ToLower)" />
Copy link
Member

Choose a reason for hiding this comment

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

Naming: I think Proguard should be written with lower-case g (several instances). (In Gradle we write proguardSomething and not proGuardSomething.)

// the Android Gradle plugin. To learn more, go to the section about
// R8 configuration files.
proguardFiles getDefaultProguardFile(
#if @(Project.Android.Optimize.DefaultAndroidProGuard:IsSet)
Copy link
Member

Choose a reason for hiding this comment

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

Naming: I don't think we should repeat Android in this property name. I suggest Project.Android.Optimize.DefaultProguard:IsSet.

@@ -52,9 +52,20 @@ public override void DeleteOutdated(Disk disk, IEnvironment env)
var lines = new List<string> {"## This file was generated by Uno compiler."};
var src = env.GetOutputPath("Java.SourceDirectory");

// Prepend user-defined proguard rules.
var proGuardPrependFile = env.GetString("ProGuard.PrependRulesFile");
Copy link
Member

Choose a reason for hiding this comment

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

Naming: proguardPrependFile, Proguard.PrependRulesFile?

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