<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gradle file &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/tag/gradle-file/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bestdevops.com</link>
	<description>Lets Learn, Do it &#38; Share! Thats a Best DevOps!!!</description>
	<lastBuildDate>Mon, 12 Oct 2026 12:37:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>How to Use Gradle&#8217;s &#8216;provided&#8217; Scope for External JAR Files in NativeScript Android Plugins</title>
		<link>https://www.bestdevops.com/gradle-compiles-provided-jar-files/</link>
					<comments>https://www.bestdevops.com/gradle-compiles-provided-jar-files/#respond</comments>
		
		<dc:creator><![CDATA[anil]]></dc:creator>
		<pubDate>Thu, 13 Jul 2017 07:55:41 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[DevOps Tools]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[BestDevOps]]></category>
		<category><![CDATA[Gradle]]></category>
		<category><![CDATA[gradle file]]></category>
		<category><![CDATA[jar files]]></category>
		<guid isPermaLink="false">http://www.bestdevops.com/?p=2090</guid>

					<description><![CDATA[Learn how to correctly configure Gradle dependencies when adding a 'provided' JAR file—such as the Zebra EMDK—to a NativeScript Android plugin, and understand why classes get skipped during the build metadata step.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"><strong>Source:</strong> <a href="https://discourse.nativescript.org" rel="noopener">discourse.nativescript.org</a></p>



<h2 class="wp-block-heading">Background</h2>



<p class="wp-block-paragraph">The Zebra EMDK (Enterprise Mobility Development Kit) ships its own Android SDK as a JAR rather than being available through Maven Central or the Google Maven repository. When writing a NativeScript Android plugin that wraps EMDK functionality, you must add this external JAR as a compile-time-only (<code>provided</code>) dependency so that the device&#8217;s on-device EMDK library is used at runtime, rather than bundling a duplicate copy into the APK.</p>



<h2 class="wp-block-heading">The Problem: &#8216;provided&#8217; JAR Classes Being Skipped</h2>



<p class="wp-block-paragraph">After placing <code>com.symbol.emdk.jar</code> inside the plugin&#8217;s <code>libs/</code> directory and adding the following configuration to <code>include.gradle</code>:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">dependencies {
  provided files(<span class="hljs-string">'libs/com.symbol.emdk.jar'</span>)
  compile fileTree(exclude: &#91;<span class="hljs-string">'libs/com.symbol.emdk.jar'</span>], <span class="hljs-keyword">include</span>: &#91;<span class="hljs-string">'*.jar'</span>], dir: <span class="hljs-string">'libs'</span>)
}</code></span></pre>


<p class="wp-block-paragraph">Running <code>tns run android</code> triggers the <code>:buildMetadata</code> Gradle task, which processes all JAR files to generate TypeScript metadata for NativeScript. During this step, the EMDK classes are not skipped as expected—instead, they are included in metadata generation and produce a stream of <code>NullPointerException</code> errors:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>:buildMetadata<br>Skip com.symbol.emdk.simulscan.SimulScanConfig<br>Error: java.lang.NullPointerException<br>Skip com.symbol.emdk.simulscan.SimulScanManager<br>Error: java.lang.NullPointerException<br>Skip com.symbol.emdk.simulscan.SimulScanMultiTemplate<br>Error: java.lang.NullPointerException<br>Skip com.symbol.emdk.simulscan.SimulScanReader<br>Error: java.lang.NullPointerException<br>Skip com.symbol.emdk.simulscan.SimulScanReaderInfo<br>Error: java.lang.NullPointerException</p>
</blockquote>



<p class="wp-block-paragraph">Because the metadata for these classes is incomplete or corrupted, the app crashes at runtime whenever any EMDK API is called.</p>



<h2 class="wp-block-heading">Why This Happens</h2>



<p class="wp-block-paragraph">The NativeScript Android runtime uses a custom Gradle task (<code>buildMetadata</code>) to reflect over every JAR on the compile classpath and generate JavaScript-accessible metadata. The <code>provided</code> configuration in Gradle is intended to mark a dependency as available at compile time but absent from the final APK—similar to Maven&#8217;s <code>provided</code> scope or the <code>compileOnly</code> configuration introduced in later Gradle versions.</p>



<p class="wp-block-paragraph">However, the NativeScript build toolchain may still enumerate JARs in the <code>provided</code> configuration when building metadata. If the JAR contains classes that reference other classes not present on the classpath (common with vendor SDKs like EMDK), the reflection step throws <code>NullPointerException</code> errors and silently skips those classes. The result is incomplete metadata and a broken runtime API surface.</p>



<h2 class="wp-block-heading">Key Concepts: &#8216;provided&#8217; vs &#8216;compileOnly&#8217; vs &#8216;compile&#8217;</h2>



<figure class="wp-block-table"><table><thead><tr><th>Configuration</th><th>Available at compile time</th><th>Packaged in APK</th><th>Notes</th></tr></thead><tbody><tr><td><code>compile</code></td><td>Yes</td><td>Yes</td><td>Deprecated in Gradle 3.x+; replaced by <code>implementation</code></td></tr><tr><td><code>provided</code></td><td>Yes</td><td>No</td><td>Legacy; replaced by <code>compileOnly</code> in Gradle 2.12+</td></tr><tr><td><code>compileOnly</code></td><td>Yes</td><td>No</td><td>Preferred modern equivalent of <code>provided</code></td></tr><tr><td><code>implementation</code></td><td>Yes</td><td>Yes</td><td>Preferred modern equivalent of <code>compile</code></td></tr></tbody></table></figure>



<p class="wp-block-paragraph">For Android system-level SDKs like Zebra EMDK—where the real implementation lives on the device and your app should not bundle its own copy—<code>compileOnly</code> (or the legacy <code>provided</code>) is the correct scope.</p>



<h2 class="wp-block-heading">Recommended Approaches</h2>



<h3 class="wp-block-heading">1. Use compileOnly Instead of provided</h3>



<p class="wp-block-paragraph">If your NativeScript and Gradle versions support it, replace <code>provided</code> with <code>compileOnly</code>:</p>


<pre class="wp-block-code"><span><code class="hljs language-php">dependencies {
  compileOnly files(<span class="hljs-string">'libs/com.symbol.emdk.jar'</span>)
  implementation fileTree(exclude: &#91;<span class="hljs-string">'com.symbol.emdk.jar'</span>], <span class="hljs-keyword">include</span>: &#91;<span class="hljs-string">'*.jar'</span>], dir: <span class="hljs-string">'libs'</span>)
}</code></span></pre>


<h3 class="wp-block-heading">2. Exclude the JAR from the buildMetadata Task</h3>



<p class="wp-block-paragraph">If the NativeScript build toolchain still picks up the EMDK JAR during metadata generation and produces errors, you may need to explicitly exclude it from that task. Check the NativeScript plugin documentation or the project&#8217;s Gradle build scripts for a supported exclusion mechanism, such as an <code>exclusions</code> list in <code>include.gradle</code> or a project-level configuration option.</p>



<h3 class="wp-block-heading">3. Verify the JAR&#8217;s Classpath Dependencies</h3>



<p class="wp-block-paragraph">The <code>NullPointerException</code> errors during reflection often indicate that the EMDK JAR references classes from the Android platform SDK or from other Zebra libraries that are not on the metadata-generation classpath. Ensure that the full Android SDK is available during the build, and check whether Zebra provides additional companion JARs that should also be on the <code>compileOnly</code> classpath (without being packaged into the APK).</p>



<h2 class="wp-block-heading">Summary</h2>



<p class="wp-block-paragraph">When integrating a vendor-provided Android SDK JAR—such as the Zebra EMDK—into a NativeScript plugin, use the <code>compileOnly</code> (or legacy <code>provided</code>) Gradle configuration to keep the JAR off the final APK. If the NativeScript <code>:buildMetadata</code> task still processes the JAR and throws <code>NullPointerException</code> errors for EMDK classes, the root cause is typically missing transitive dependencies on the metadata-generation classpath. Resolve this by ensuring all referenced platform and companion classes are available at build time, or by using a supported exclusion mechanism in the NativeScript plugin build configuration.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/gradle-compiles-provided-jar-files/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
