AAPT2: Process <java-symbols> and private symbol package
Need to introduce the idea of multiple levels of visibility to support <java-symbol>.
Public, Private, Undefined.
Public means it is accessible from outside and requires an ID assigned.
Private means that we explicitly want this to be a symbol (show up in R.java), but not visible
to other packages. No ID required.
Undefined is any normal resource. When --private-symbols is specified in the link phase,
these resources will not show up in R.java.
Change-Id: Icba89221e08e685dee7683786aa7112baf28c856
diff --git a/tools/aapt2/link/ReferenceLinker.cpp b/tools/aapt2/link/ReferenceLinker.cpp
index c0356e5..b4fb996 100644
--- a/tools/aapt2/link/ReferenceLinker.cpp
+++ b/tools/aapt2/link/ReferenceLinker.cpp
@@ -249,10 +249,13 @@
for (auto& package : table->packages) {
for (auto& type : package->types) {
for (auto& entry : type->entries) {
- // A public entry with no values will not be encoded properly.
- if (entry->publicStatus.isPublic && entry->values.empty()) {
- context->getDiagnostics()->error(DiagMessage(entry->publicStatus.source)
- << "No value for public resource");
+ // Symbol state information may be lost if there is no value for the resource.
+ if (entry->symbolStatus.state != SymbolState::kUndefined && entry->values.empty()) {
+ context->getDiagnostics()->error(
+ DiagMessage(entry->symbolStatus.source)
+ << "no definition for declared symbol '"
+ << ResourceNameRef(package->name, type->type, entry->name)
+ << "'");
error = true;
}