Only add jacocoagent if the package contains some java code.

Bug: 27877982
Change-Id: I8bf05d67a823402e7e488990753cc9005ec5e90b
diff --git a/core/package_internal.mk b/core/package_internal.mk
index fb21c2b..f200d12 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -231,7 +231,10 @@
 ifeq (true,$(EMMA_INSTRUMENT_STATIC))
 ifdef LOCAL_JACK_ENABLED
 # Jack supports coverage with Jacoco
+ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
+# Only add jacocoagent if the package contains some java code
 LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+endif # Contains java code
 else
 LOCAL_STATIC_JAVA_LIBRARIES += emma
 endif # LOCAL_JACK_ENABLED
@@ -241,7 +244,10 @@
 # In unbundled build merge the emma library into the apk.
 ifdef LOCAL_JACK_ENABLED
 # Jack supports coverage with Jacoco
+ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
+# Only add jacocoagent if the package contains some java code
 LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+endif # Contains java code
 else
 LOCAL_STATIC_JAVA_LIBRARIES += emma
 endif # LOCAL_JACK_ENABLED