-
-
Notifications
You must be signed in to change notification settings - Fork 23
Android - Optimization #392
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
- 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 ```
There was a problem hiding this 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)" /> |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming: proguardPrependFile
, Proguard.PrependRulesFile
?
Default android proguard rules(proguard-android.txt) are applied when not specified
Can add custom proguard rules before or after the main generated class rules:
Create "proguard-rules-prepend.pro" in root of Project folder:
e.g.
MyApp/MainView.ux
MyApp/proguard-rules-prepend.pro
...
proguard-rules-prepend.pro