private static void addService(XmlDocument document, XmlElement application ) { // <service // android:name="com.android.tools.fd.runtime.InstantRunService" // android:exported="true"/> Element service = document.getXml().createElement(SdkConstants.TAG_SERVICE); setAndroidAttribute(service, SdkConstants.ATTR_NAME, BOOTSTRAP_INSTANT_RUN_SERVICE); // Export it so we can start it with a shell command from adb. setAndroidAttribute(service, SdkConstants.ATTR_EXPORTED, SdkConstants.VALUE_TRUE); application.getXml().appendChild(service); }
/** * Set android:testOnly="true" to ensure APK will be rejected by the Play store. */ @NonNull private static XmlDocument addTestOnlyAttribute(XmlDocument document) { Optional<XmlElement> applicationOptional = document .getByTypeAndKey(ManifestModel.NodeTypes.APPLICATION, null /* keyValue */); if (applicationOptional.isPresent()) { XmlElement application = applicationOptional.get(); setAndroidAttribute(application.getXml(), SdkConstants.ATTR_TEST_ONLY, SdkConstants.VALUE_TRUE); } return document.reparse(); }