Bug 31763 - Adding an Android Library Project to an Android Binding project causes referencing app project's build to fail.
Summary: Adding an Android Library Project to an Android Binding project causes refere...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 5.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-07-08 16:22 UTC by Jon Goldberger [MSFT]
Modified: 2016-03-15 19:03 UTC (History)
2 users (show)

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

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:
Status:
RESOLVED FIXED

Description Jon Goldberger [MSFT] 2015-07-08 16:22:07 UTC
## Description

Following the instructions here, 

>http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Android_Library_Projects

 to add an Android Library Project to an Android Binding project causes the referencing Android app project's build to fail if the "bin" and "res" folders from the Android Library Project are zipped using Finder on the Mac to zip the folders. The error message in the build output is: 


>/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Tool exited with code: 1. Output: >/Users/apple/Downloads/DonkyUILibrary.JavaBinding/TestAndroidLibraryProjectInBinding/obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/res/drawable-mdpi/dk_ic_chat_message_status_failed.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
>/Users/apple/Downloads/DonkyUILibrary.JavaBinding/TestAndroidLibraryProjectInBinding/obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/res/drawable-hdpi/dk_ic_chat_message_status_failed.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
>/Users/apple/Downloads/DonkyUILibrary.JavaBinding/TestAndroidLibraryProjectInBinding/obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/res/drawable-xhdpi/dk_ic_chat_message_status_failed.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
>/Users/apple/Downloads/DonkyUILibrary.JavaBinding/TestAndroidLibraryProjectInBinding/obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/res/drawable-xxhdpi/dk_ic_chat_message_status_failed.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
>/Users/apple/Downloads/DonkyUILibrary.JavaBinding/TestAndroidLibraryProjectInBinding/obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/res/drawable-xxxhdpi/dk_ic_chat_message_status_failed.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
>ERROR: unable to open 'obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/__MACOSX/bin/._donkyui.jar' as a zip file: -78
>ERROR: unable to process jar files while packaging '/var/folders/14/lysfsx_x4y912h9z1qmf58qr0000gn/T/idurrsv0.612/resources.apk.bk'
>ERROR: packaging of '/var/folders/14/lysfsx_x4y912h9z1qmf58qr0000gn/T/idurrsv0.612/resources.apk.bk' failed (TestAndroidLibraryProjectInBinding)

What I noted was odd is that the search is looking in the __MACOSX folder, which is a folder which shows up in Windows when you unzip a zip file that was created on the Mac. To resolve this build failure, I just unzipped the Android Library Project (DonkyUI.zip) in Windows, deleted the __MACOSX folder, and re-zipped using Windows zip. Using this Windows zip file to replace the original DonkyUI.zip file resolved the issue. 


## Steps to reproduce

1. Download the test project from Dropbox (link in private comment below, please keep internal)

2. Open in Xamarin Studio on Mac and restore packages.

3. Build the solution.

Expected result: Projects will build without error.

Actual result: App project build fails with above error.


## Note

As mentioned above this seems to be an issue with the format of the Zip file. In the Solution directory in Finder, you will see DonkyUI-Windows.zip. This is DonkyUI.zip re-zipped using Windows. To test the workaround. rename DonkyUI.zip to something else and then rename DonkyUI-Windws.zip to DonkyUI.zip. After doing this rebuild the solution and the App project will build without error. 


## My environment

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

=== Xamarin.Android ===

Version: 5.1.4.16 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: 8.10.3.2 (Business Edition)
Hash: 8b265d6
Branch: master
Build date: 2015-06-30 15:19:13-0400

=== Xamarin.Mac ===

Version: 2.0.2.35 (Business Edition)

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.10.4
Darwin Jons-iMac.local 14.4.0 Darwin Kernel Version 14.4.0
    Thu May 28 11:35:04 PDT 2015
    root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
Comment 2 Abhishek 2015-07-09 05:44:53 UTC
I have tried this issue and able to reproduce the reported behavior at my end.

Steps To Reproduce:
1.  Download the given project from comment 1.
2.  Open the project on Xamarin Studio.
3.  Build the application.
4. It will give the build error.

Screencast: http://www.screencast.com/t/lV6rWbtonP
Build Output: https://gist.github.com/Abhishekk360/b70581c8e2795aac30d1
IDE log: https://gist.github.com/Abhishekk360/69f33538000b398ad042

Environment Info:

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

=== Xamarin.Android ===

Version: 5.1.4.16 (Business Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.10.2.43 (Business Edition)
Hash: 428e4d4
Branch: master
Build date: 2015-07-03 10:41:01-0400

=== Xamarin.Mac ===

Version: 2.0.2.40 (Business Edition)

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 Jonathan Pryor 2015-07-09 12:19:28 UTC
The problem is that we're too "liberal" when looking for .jar files -- we grab all .jar files extracted from the .zip file, which includes e.g. obj/Debug/__library_projects__/DonkyUILibrary.JavaBinding/library_project_imports/__MACOSX/bin/._donkyui.jar, which is NOT a .jar file.

@Dean: The simplest fix is probably to update mandroid's extract-resources command to *exclude* files with __MACOSX in the path name.
Comment 4 dean.ellis 2015-07-09 12:33:49 UTC
We currently just blindly extract the entire contents of the zip. I think we need to NOT include hidden files in the zip in the first place. I assume the __MACOSX  or the ._donkyui.jar is flagged as hidden. 

But we also need to guard against this as well and not extract the __MACOSX
Comment 5 dean.ellis 2016-03-15 19:03:14 UTC
Fixed in monodroid/master/7406df57