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/r8 optimization #4743

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

irodotos7
Copy link
Contributor

No description provided.

Copy link
Contributor

autofix-ci bot commented Mar 17, 2025

Hi! I'm autofix logoautofix.ci, a bot that automatically fixes trivial issues such as code formatting in pull requests.

I would like to apply some automated changes to this pull request, but it looks like I don't have the necessary permissions to do so. To get this pull request into a mergeable state, please do one of the following two things:

  1. Allow edits by maintainers for your pull request, and then re-trigger CI (for example by pushing a new commit).
  2. Manually fix the issues identified for your pull request (see the GitHub Actions output for details on what I would like to change).

@vaslabs
Copy link
Contributor

vaslabs commented Mar 17, 2025

This is WIP

* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a proguardTest-rules.pro to be used to build instrumented tests

these are the typical contents when creating a project in android studio

# Proguard rules that are applied to your test apk/code.
-ignorewarnings
-dontoptimize

-keepattributes *Annotation*

-keep class androidx.test.espresso.**
# keep the class and specified members from being removed or renamed
-keep class androidx.test.espresso.IdlingRegistry { *; }
-keep class androidx.test.espresso.IdlingResource { *; }

-dontnote junit.framework.**
-dontnote junit.runner.**

-dontwarn androidx.test.**
-dontwarn org.junit.**
-dontwarn org.hamcrest.**
-dontwarn com.squareup.javawriter.JavaWriter

but get the same ones as in your reference project you created


import scala.xml.XML

trait AndroidModule extends JavaModule {

this
Copy link
Contributor

Choose a reason for hiding this comment

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

this might be here by accident

appLinkArgsBuilder += "--proguard-minimal-keep-rules"
}
appLinkArgsBuilder += "--proguard-minimal-keep-" +
"rules"
if (androidIsDebug()) {
appLinkArgsBuilder += "--debug-mode"
Copy link
Contributor

Choose a reason for hiding this comment

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

imo, we should separate these with androidDebugInstall (androidDebugDex, etc) and androidReleaseInstall and have the common arguments in a shared method, so we can eliminate these if statements

@@ -706,4 +708,248 @@ trait AndroidModule extends JavaModule {
PathRef(signedApk)
}

/** Whether we are building an application (APK) or a library (AAR) */
def isApplication: T[Boolean] = Task {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this? we have AndroidModule and AndroidAppModule which should separate the two

)
}

/** Toggle desugaring in R8 (usually true for full R8 mode when minSdk < 24) */
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a link to documentation you can put here as a reference?

None
}

def mainDexListOutput: T[Option[PathRef]] = T {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is probably not needed, try to refactor with a case class in runR8 task

val multiDexArgs =
mainDexRules().toSeq.flatMap(r => Seq("--main-dex-rules", r.path.toString)) ++
mainDexList().toSeq.flatMap(l => Seq("--main-dex-list", l.path.toString)) ++
mainDexListOutput().toSeq.flatMap(l => Seq("--main-dex-list-output", l.path.toString))
Copy link
Contributor

Choose a reason for hiding this comment

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

from the https://github.com/com-lihaoyi/mill/pull/4743/files#r2007060988 , you can decide the name of the output here and return it as part of a R8Output case class (needs a better name)

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