-
-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,15 @@ android { | |
targetSdkVersion @(SDK.TargetVersion) | ||
versionCode = @(Project.Android.VersionCode) | ||
versionName = '@(Project.Android.VersionName)' | ||
multiDexEnabled @(Project.Android.MultiDexEnabled:IsSet:Test(@(Project.Android.MultiDexEnabled:Bool),true)) | ||
|
||
#if @(Project.Android.Optimize.MinifyEnabled:Test(1, 0)) | ||
//minifier handles multi-dexing for release | ||
#if @(DEBUG:Defined) | ||
multiDexEnabled @(Project.Android.MultiDexEnabled:IsSet:Test(@(Project.Android.MultiDexEnabled:Bool),true)) | ||
#endif | ||
#else | ||
multiDexEnabled @(Project.Android.MultiDexEnabled:IsSet:Test(@(Project.Android.MultiDexEnabled:Bool),true)) | ||
#endif | ||
|
||
ndk { | ||
#if @(DEBUG:Defined) | ||
|
@@ -83,6 +91,12 @@ android { | |
|
||
} | ||
|
||
//prevent gradle build crash - https://stackoverflow.com/a/47689687/2139770 | ||
dexOptions { | ||
javaMaxHeapSize "4g" | ||
} | ||
|
||
|
||
#if @(Project.Android.Bundle.Language.EnableSplit:IsSet) || @(Project.Android.Bundle.Density.EnableSplit:IsSet) || @(Project.Android.Bundle.ABI.EnableSplit:IsSet) | ||
bundle { | ||
#if @(Project.Android.Bundle.Language.EnableSplit:IsSet) | ||
|
@@ -133,8 +147,32 @@ android { | |
#elif @(Project.Android.Key.Store:IsSet) | ||
signingConfig = signingConfigs.release | ||
#endif | ||
minifyEnabled = false | ||
proguardFiles 'proguard-rules.pro' | ||
|
||
#if @(Project.Android.Optimize.MinifyEnabled:IsSet) | ||
// Enables code shrinking, obfuscation, and optimization for only | ||
// your project's release build type. | ||
minifyEnabled @(Project.Android.Optimize.MinifyEnabled:ToLower) | ||
#else | ||
minifyEnabled true | ||
#endif | ||
|
||
#if @(Project.Android.Optimize.ShrinkResources:IsSet) | ||
// Enables resource shrinking, which is performed by the | ||
// Android Gradle plugin. | ||
shrinkResources @(Project.Android.Optimize.ShrinkResources:ToLower) | ||
#else | ||
shrinkResources true | ||
#endif | ||
// Includes the default ProGuard rules files that are packaged with | ||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. Naming: I don't think we should repeat |
||
'@(Project.Android.Optimize.DefaultAndroidProGuard:ToLower)' | ||
#else | ||
'proguard-android.txt' | ||
#endif | ||
), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Naming: |
||
if (proGuardPrependFile.IsValidPath()) | ||
lines.AddRange(File.ReadAllLines(proGuardPrependFile)); | ||
|
||
// Add existing Java classes. | ||
if (Directory.Exists(src)) | ||
VisitSourceDirectoryRecursive(src, src, lines); | ||
|
||
// Append user-defined proguard rules. | ||
var proGuardAppendFile = env.GetString("ProGuard.AppendRulesFile"); | ||
if (proGuardAppendFile.IsValidPath()) | ||
lines.AddRange(File.ReadAllLines(proGuardAppendFile)); | ||
|
||
// End with newline. | ||
lines.Add(""); | ||
|
||
|
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-caseg
(several instances). (In Gradle we writeproguardSomething
and notproGuardSomething
.)