Bug 6186 - Android library project binding needs to generate Resource.designer.cs and avoid conflicts
Summary: Android library project binding needs to generate Resource.designer.cs and av...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
Depends on:
Reported: 2012-07-19 04:11 UTC by Atsushi Eno
Modified: 2012-07-19 12:14 UTC (History)
1 user (show)

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

repro project (1.73 MB, application/zip)
2012-07-19 07:49 UTC, Atsushi Eno

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 Atsushi Eno 2012-07-19 04:11:58 UTC
Even with the latest fixes in Android library binding, there are still some issues that needs fixes, e.g. to get ActionBarSherlock *samples* working (the binding itself should already build).

- Resource names in the android library project and the managed application project often conflicts, while they should be actually different (by package name). Currently we *overwrite* the resources when the containing files names overlap. I think this was what what Android SDK used to do, now it became better at their side and we should follow.

- Android library resources could be referenced by the application project code, as a member of R.* class where the R class is *from the library project* (not the R class from the app project). Here is an example:


I already have a fix for the first issue. The second needs some work.
Comment 2 Atsushi Eno 2012-07-19 06:47:18 UTC
The former issue is now fixed.

For the latter issue, I noticed that we should *not* be generating Resource class within the library project binding dll, because 1) the resource IDs will be changed later for exactly the same reason as IDs in the Android library project R.java cannot be constant, and 2) it will later conflict with the resource in the application project.

Instead of generating IDs in the library project, it should rather be generated in the application project's Resource.designer.cs. In the previous resource designer bugfix, I explicitly made changes to C# resource designer generator to *skip* non-app resources (as it prevented generating sane code somehow), but now it is likely time to make it working and activate again.
Comment 3 Atsushi Eno 2012-07-19 07:18:45 UTC
Actually the latter issue should *not* matter; the Resource.designer.cs within the app *.csproj should describe *everything* that will be ultimately packaged in the arsc/apk and the corresponding field for the ID should also be there.

What I was missing was that the Resource.designer.cs in my test .csproj had *different* default namespace than the namespace I used in the test activity and thus resulted in ordinal type resolution failure.
Comment 4 Atsushi Eno 2012-07-19 07:49:20 UTC
Created attachment 2228 [details]
repro project
Comment 5 Atsushi Eno 2012-07-19 07:51:01 UTC
Actually there still seems some resource resolution issue regarding aapt:

		Tool /home/atsushi/android-sdk-linux/platform-tools/aapt execution started with arguments: package -f -m -M obj/Debug/android/AndroidManifest.xml -J /tmp/3f4o3s9u.3iy --custom-package actionbarsherlocktest.actionbarsherlocktest -F obj/Debug/android/bin/packaged_resources.bk -S obj/Debug/res/ -I /home/atsushi/android-sdk-linux/platforms/android-15/android.jar -A /svn/monodroid-samples/ActionBarSherlock/ActionBarSherlockTest/obj/Debug/assets/ --extra-packages com.actionbarsherlock --auto-add-overlay 
		Resources/values/themes.xml(5): error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light.DarkActionBar'.
		Resources/values/themes.xml(6): error: No resource found that matches the given name: attr 'actionBarStyle'.
		Resources/values/themes.xml(9): error: Error retrieving parent for item: No resource found that matches the given name 'Widget.Sherlock.Light.ActionBar.Solid.Inverse'.
		Resources/values/themes.xml(10): error: No resource found that matches the given name: attr 'background'.
		Resources/values/themes.xml(13): error: No resource found that matches the given name: attr 'backgroundSplit'.
		Tool /home/atsushi/android-sdk-linux/platform-tools/aapt execution finished.
Comment 6 Atsushi Eno 2012-07-19 12:14:40 UTC