Bug 42091 - Latest update breaks InputJar bindings
Summary: Latest update breaks InputJar bindings
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 6.1.0 (C7)
Hardware: Macintosh Mac OS
: High normal
Target Milestone: 7.1 (C9)
Assignee: Atsushi Eno
: 42492 ()
Depends on:
Reported: 2016-06-22 19:13 UTC by Randy
Modified: 2017-02-24 15:17 UTC (History)
9 users (show)

Tags: BZSRC7 XATriaged
Is this bug a regression?: ---
Last known good build:

My EMDK binding project (101.88 KB, application/zip)
2016-06-22 19:20 UTC, Randy
Better version of the emdk project (99.48 KB, application/zip)
2016-06-22 19:43 UTC, Randy
Build log (76.52 KB, application/zip)
2016-06-23 18:53 UTC, Randy

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Randy 2016-06-22 19:13:09 UTC
I have a solution that contains a binding project for the EMDK library. The provided JAR file contains the definitions with just stubs for the functions. I had been using this for some time with a binding project where the JAR file was defined as an InputJar. It would build the calls but not include the JAR file. When run on a device, it would look in the system for the JAR and would fail to create the object if the JAR wasn't there. This allowed me to support EMDK when it existed on the device but not fail on devices that didn't have it.

With the latest update this has broken. The EMDK project compiles fine but when the main project that references it compiles, I get about 50 errors like this:

/Users/Randy/Documents/Rome/Client/Android/obj/Debug/android/src/md5343c63482c6369fcde56beb4a92c2200/MrtApplication_EMDKController.java(30,30): Error:  error: package com.symbol.emdk.EMDKManager does not exist
 (Splitware) javac

My main project code looks like:
	public class MrtApplication : Application, SocketMobileHelper.ScanApiHelper.ScanApiHelperNotification
		class EMDKController : Java.Lang.Object,

The compiler is creating java stubs like this: (I included the stub functions it generates for the EMDKListener interface)
package md5343c63482c6369fcde56beb4a92c2200;

public class MrtApplication_EMDKController
	extends java.lang.Object
public void onClosed ()
		n_onClosed ();

	private native void n_onClosed ();

	public void onOpened (com.symbol.emdk.EMDKManager p0)
		n_onOpened (p0);

	private native void n_onOpened (com.symbol.emdk.EMDKManager p0);


The errors are for the three 'com.symbol.emdk' classes that the class implements. If I use EmbeddedJar, it compiles fine but won't run since it is trying to execute the stub functions. When using InputJar, it acts like the generated stub is looking for the specified interface classes and not finding them since InputJar doesn't include the jar file in the final output.
Comment 1 Randy 2016-06-22 19:20:38 UTC
Created attachment 16445 [details]
My EMDK binding project

You should be able to create a trivial project, include this project and define a class like this to recreate the error. You'll have to add the appropriate stub functions to satisfy the interface definitions.

		class EMDKController : Java.Lang.Object,
Comment 2 Randy 2016-06-22 19:43:01 UTC
Created attachment 16446 [details]
Better version of the emdk project

The previous version had a new version of the jar that was causing extra warnings. This is the one that used to work properly before the latest tamarin.android update.
Comment 3 Randy 2016-06-22 20:08:50 UTC
One extra issue is that trying to open the 'Options' dialog for the EMDK project will crash xamarin studio
Comment 4 Randy 2016-06-23 18:53:12 UTC
Created attachment 16465 [details]
Build log

I've added the diagnostic build log for my project because I think it shows the problem. Search for "emdk.jar" and go to the 5th instance. This is the javac command for the main project that is including the emdk project. It has an entry like:

    <AndroidExternalJavaLibrary Include="..\EMDK\Jars\com.symbol.emdk.jar">

This references the jar to resolve the interface classes in the main project. I can see it listed in the attached log but the actual javac command doesn't include that jar file and that is why it starts getting compile error.

Changing it to AndroidJavaLibrary will fix the compile problems but won't run since it will also include the jar in the final apk. However this jar is just stub functions and shouldn't be in the apk. The real jar is already installed on the device and the app should runtime link to that one.

It looks like there was a change in the build scripts that is causing it to drop the external library.
Comment 5 Jonathan Pryor 2016-07-12 14:08:52 UTC
*** Bug 42492 has been marked as a duplicate of this bug. ***
Comment 6 steve goodman 2016-07-12 19:34:48 UTC
I've managed to reproduce this bug in Visual Studio with Xamarin Android

Is there any kind of work around for this?
Comment 7 Jonathan Pryor 2016-07-28 20:11:40 UTC
@Eno: Do you know why the <DetermineJavaLibrariesToCompile/> task *ignores* the `ExternalJavaLibraries` property (from `@(AndroidExternalJavaLibrary)`)?


At a quick glance, it appears to be due to monodroid/30c22c7f, which fixes Bug #27553.
Comment 8 Atsushi Eno 2016-08-16 09:01:44 UTC
Correct, that was accidentally removed. Fixes:

I believe DoNotPackageAttribute could be used as a workaround.
Comment 9 narayanp 2016-09-16 19:51:29 UTC
I have tried to verify this issue with latest master Xamarin.Android 7.0.99-77 builds and getting the same behavior, below are the I follow:

1. Create an android project.
2. Add the attached emdk binding project to the android project.
3. Add reference of emdk binding library to the android project.
4. Build the solution.

And Observing that I am getting approx 37 errors in the error pad and here is the build output for the same.

Build Output: https://gist.github.com/lal360/facfab375631f69685803ccad67406d3

Is I am doing the right steps to verify this issue?

Here is the screencast for the same : 

Screencast: http://www.screencast.com/t/6diR26hopsj0

Environment Info: 
gist: https://gist.github.com/lal360/facfab375631f69685803ccad67406d3
Comment 10 Randy 2016-09-19 15:16:13 UTC
The 'Build output' and 'environment info' links above both show the environment info so I can't check if you are getting the proper errors. The errors to look for are in the original report above. They should be missing emdk packages and classes since in the final java build the emdk.jar reference is missing.
Comment 11 narayanp 2016-09-22 12:02:51 UTC
Here is an update to the Comment 9, I am attaching the gist of the Build Output.

Build Output: https://gist.github.com/lal360/32f813240f52651c6618240214a592c4
Comment 12 James Athey 2016-09-28 16:11:42 UTC
This bug just bit me - I'm trying to wrap the Recon SDK http://www.reconinstruments.com/developers/develop/, which provides only stubs in its platform JAR. Are there any workarounds, other than downgrading to Xamarin.Android 6.0?
Comment 13 Randy 2016-10-03 17:47:27 UTC
Yes, the errors you are getting in the "Target _CompileJava:" section are the problem. If you look at the arguments in the 'javac' command in that step, it is not referencing the emdk.jar file as an external jar.
Comment 14 Atsushi Eno 2016-11-04 08:38:47 UTC

> 1. Create an android project.
> 2. Add the attached emdk binding project to the android project.
> 3. Add reference of emdk binding library to the android project.
> 4. Build the solution.

I figured out why you are seeing the build errors; you have to add com.symbol.emdk.jar as AndroidExternalJavaLibrary to the application project too.

Note that the binding project uses InputJar which does not embed the jar to the binding DLL and hence does not automatically extract and reference it.
Comment 15 Randy 2016-11-04 17:30:37 UTC
Step #3 in my process is adding the jar as an AndroidExternalJavaLibrary in the main project. This had been working for a year or more. The xamarin update that caused the problem would show the list of libraries in the log but the actual javac command in the log doesn't include that library.

In the comments above, you will see my comment from 2016-06-23 where that is exactly what I am doing.

As noted in my 10-03 comment, search the build log for "Target _CompileJava:", check the list of libraries and compare it to the libraries in the javac command. The build process is ignoring any AndroidExternalJavaLibrary entries.
Comment 16 Atsushi Eno 2016-11-08 07:02:40 UTC
Because those fixes on comment #8 are not in the public release yet.
Comment 17 Atsushi Eno 2016-11-08 07:05:54 UTC
It should be marked as "fixed", to trigger QA verification (again).
Comment 18 Randy 2016-11-08 13:22:27 UTC
What release has the fix? It doesn't seem to be in the current stable release, is it in the current beta?
Comment 19 Brendan Zagaeski (Xamarin Team, assistant) 2016-11-08 18:27:28 UTC
The "Resolved Fixed" state means "A resolution has been performed, and it is awaiting verification by QA" [1].  It does not indicate the release status.  The primary indication for the release status in Xamarin's Bugzilla is the "Target Milestone" field.  That field is currently set to "7.1 (C9)" (that is Xamarin.Android 7.1, Cycle 9) for this bug.  That means that the bug is planned to be verified by QA against builds from the Cycle 9 "branch" those versions are published to the Stable channel (and often before they are published to the Beta channel).

[1] https://bugzilla.xamarin.com/page.cgi?id=fields.html#bug_status

Work is in progress right now to get builds of Cycle 9 prepared for the Alpha updater channel [2] (hopefully within the next few business days).  Those initial versions of Cycle 9 might or might not include the patch for this particular bug depending on when the patch was committed to the Cycle 9 branch.

[2] https://developer.xamarin.com/recipes/cross-platform/ide/change_updates_channel/

If you wished, you could also experiment with the continuous open source builds of Xamarin.Android from the "master" branch [3] or the Cycle 9 branch [4] but please be aware these are strictly _untested development builds_.

[3] https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-master/
[4] https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-builds-cycle9/

Xamarin Support Team
Comment 20 narayanp 2016-11-21 13:58:56 UTC
I have checked this issue with latest Cycle 9 XA and follow these steps mentioned in Comment 14:

> 1. Create an android project.
> 2. Add the attached emdk binding project to the android project.
> 3. Add reference of emdk binding library to the android project.
> 4. Build the solution.
> 5. Add com.symbol.emdk.jar as AndroidExternalJavaLibrary to the application project

And after that I am successfully able to build the project.

Screencast: http://www.screencast.com/t/AHxtPS4U

Environment Info:
gist: https://gist.github.com/lal360/d41911acbe86f4646c7e99b9e3988229

Hence, I am closing the issue.

Thanks !
Comment 21 Randy 2017-02-24 15:17:41 UTC
Confirmed that the just released xamarin.android V7.1.0.41 fixes this problem.