From 60999344a21b6d4f07f43bb675c364aef148a73c Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 16 Nov 2021 04:15:33 +0000 Subject: [PATCH] Update platform_apis error message The updated error message is more descriptive about the incompatibility between platform_apis and sdk_version. Implemented as per the discussion in b/204447559#17 Test: In build/soong, run go test ./java Bug: 204447559 Change-Id: I826f0ce47313b337f1754a1b6bc11ce65c837a41 --- java/app_test.go | 4 ++-- java/base.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/app_test.go b/java/app_test.go index 07439fcd0..0aae9280d 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -144,14 +144,14 @@ func TestPlatformAPIs(t *testing.T) { } `) - testJavaError(t, "platform_apis must be true when sdk_version is empty.", ` + testJavaError(t, "This module has conflicting settings. sdk_version is empty, which means that this module is build against platform APIs. However platform_apis is not set to true", ` android_app { name: "bar", srcs: ["b.java"], } `) - testJavaError(t, "platform_apis must be false when sdk_version is not empty.", ` + testJavaError(t, "This module has conflicting settings. sdk_version is not empty, which means this module cannot use platform APIs. However platform_apis is set to true.", ` android_app { name: "bar", srcs: ["b.java"], diff --git a/java/base.go b/java/base.go index ca34f2eef..2ef065036 100644 --- a/java/base.go +++ b/java/base.go @@ -502,9 +502,9 @@ func (j *Module) checkPlatformAPI(ctx android.ModuleContext) { usePlatformAPI := proptools.Bool(j.deviceProperties.Platform_apis) sdkVersionSpecified := sc.SdkVersion(ctx).Specified() if usePlatformAPI && sdkVersionSpecified { - ctx.PropertyErrorf("platform_apis", "platform_apis must be false when sdk_version is not empty.") + ctx.PropertyErrorf("platform_apis", "This module has conflicting settings. sdk_version is not empty, which means this module cannot use platform APIs. However platform_apis is set to true.") } else if !usePlatformAPI && !sdkVersionSpecified { - ctx.PropertyErrorf("platform_apis", "platform_apis must be true when sdk_version is empty.") + ctx.PropertyErrorf("platform_apis", "This module has conflicting settings. sdk_version is empty, which means that this module is build against platform APIs. However platform_apis is not set to true") } }