Gradle compiles provided jar files


#1

Hi all,

I’m trying to write a plugin for the Zebra EMDK (https://www.zebra.com/us/en/support-downloads/software/developer-tools/emdk-for-android.html). The Zebra EMDK provides it’s own Android SDK, therefore I have to add an external lib to my plugin.

I put the necessary jar file into the libs folder of my plugin (/libs/com.symbol.emdk.jar) and added the dependencies to my include.gradle file (according to this example: http://techdocs.zebra.com/emdk-for-android/4-0/tutorial/tutCreateProjectAndroidStudio/):

dependencies {
  provided files('libs/com.symbol.emdk.jar')
  compile fileTree(exclude: ['libs/com.symbol.emdk.jar'],include: ['*.jar'], dir: 'libs')
}

On tns run android it seems that the jar file gets compiled. I see the following errors in the log file:

:buildMetadata
Skip com.symbol.emdk.simulscan.SimulScanConfig
Error: java.lang.NullPointerException
Skip com.symbol.emdk.simulscan.SimulScanManager
Error: java.lang.NullPointerException
Skip com.symbol.emdk.simulscan.SimulScanMultiTemplate
Error: java.lang.NullPointerException
Skip com.symbol.emdk.simulscan.SimulScanReader
Error: java.lang.NullPointerException
Skip com.symbol.emdk.simulscan.SimulScanReaderInfo
Error: java.lang.NullPointerException

Due to the missing/skipped classes the app crashes if I want to use the external lib.

Can you tell me how do I add the external lib correctly?

Thank you!
Best regards,
Julian


#2

If the buildMetadata task fails similarly, then it can’t resolve or find a class or classes that are referenced in the library. I would load the jar in a java decompiler and see what it depends on.


#3

Thanks for your answer. I don’t know what you mean with “if the buildMetadata task fails similarly”. The task didn’t fail, it produces the NullPointerException in the log file. As ZEBRA provides his own version of Android (which is actually installed on the device) I think that I don’t need to add more jars.


#4

Apologies for the poor wording. Read as “should buildMetadata output those logs, or similar…”. The result of the messages being that you won’t be able to access the classes in your JavaScript code, reflection would still work however, so that’s a possible workaround you could consider, if the problem is a blocker.