Don't allow using framework and SDK at the same time.
Using SDK (current, system_current, module_current, or <api_version>)
while at the same time depending on "framework" doesn't make sense
because framework anyway provides all APIs including hidden ones. This
is not only uncessary but also error prone because the availability of a
private method in a class depends on whether the class is part of the
SDK or not.
Add a neverallow rule for prohibiting that. Note that "core_*" SDKs are
allowed because there's no overlap between "framework" and the core-Java
SDKs.
Bug: 227528906
Test: m nothing on git_master
Change-Id: I0605075aef20c75db084beeedcbf49a642573e69
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index 8afe9e0..86f1a37 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -327,6 +327,21 @@
"Only boot images may be imported as a makefile goal.",
},
},
+ // Tests for the rule prohibiting the use of framework
+ {
+ name: "prohibit framework",
+ fs: map[string][]byte{
+ "Android.bp": []byte(`
+ java_library {
+ name: "foo",
+ libs: ["framework"],
+ sdk_version: "current",
+ }`),
+ },
+ expectedErrors: []string{
+ "framework can't be used when building against SDK",
+ },
+ },
}
var prepareForNeverAllowTest = GroupFixturePreparers(