diff --git a/java/dexpreopt.go b/java/dexpreopt.go index de9c5f3eb..1dc3e9fd4 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -28,10 +28,11 @@ import ( type dexpreopter struct { dexpreoptProperties DexpreoptProperties - installPath android.OutputPath - isPrivApp bool - isSDKLibrary bool - isTest bool + installPath android.OutputPath + isPrivApp bool + isSDKLibrary bool + isTest bool + isInstallable bool builtInstalled []string } @@ -74,6 +75,10 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool { return true } + if !d.isInstallable { + return true + } + // TODO: contains no java code return false diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go index e4c80ddec..6838bd2c8 100644 --- a/java/dexpreopt_test.go +++ b/java/dexpreopt_test.go @@ -109,6 +109,16 @@ func TestDexpreoptEnabled(t *testing.T) { }`, enabled: false, }, + { + name: "compile_dex", + bp: ` + java_library { + name: "foo", + srcs: ["a.java"], + compile_dex: true, + }`, + enabled: false, + }, } for _, test := range tests { diff --git a/java/java.go b/java/java.go index 12e724e78..5e67193f0 100644 --- a/java/java.go +++ b/java/java.go @@ -1326,6 +1326,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path j.dexJarFile = dexOutputFile + j.dexpreopter.isInstallable = Bool(j.properties.Installable) dexOutputFile = j.dexpreopt(ctx, dexOutputFile) j.maybeStrippedDexJarFile = dexOutputFile