Bug 18018 - Using drawable or color from android package as Activity Icon does not pass 'aapt dump badging' tool
Summary: Using drawable or color from android package as Activity Icon does not pass '...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.12.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-02-26 08:17 UTC by Ginie
Modified: 2014-02-26 11:35 UTC (History)
1 user (show)

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:

Description Ginie 2014-02-26 08:17:40 UTC
Description of Problem:

When using anything from the android package as the Activity icon, the application can be run in debug or production mode, but can not be published to PlayStore due to failing the 'aapt' tool

Steps to reproduce the problem:
1. Create a new Adnroid Application project
2. In MainActivity choose anything from the android package as the the Activity Icon. Here are two examples
  a: [Activity(Label = "Test", MainLauncher = true, Icon = "@android:drawable/btn_star")]
  b: [Activity(Label = "Test", MainLauncher = true, Icon = "@android:color/transparent")]
3. Run the application (with any example)
4. run 'aapt dump badging' on the produced apk

Actual Results:
aapt spits out the following on both examples. The last two lines show two errors

  package: name='Icontest.Icontest' versionCode='1' versionName='1.0'
  application: label='Icontest' icon='res/drawable/icon.png'
  W/ResourceType(14419): No known package when getting value for resource number 0x0108000a
  ERROR getting 'android:icon' attribute: attribute is not a string value

How often does this happen? 
Comment 1 Jonathan Pryor 2014-02-26 11:05:07 UTC
I'm not sure what the cause is, or what the fix is, but I think i see the problem.

Grab apktool: https://code.google.com/p/android-apktool/

When I create a .apk as per steps 1-4, the generated obj/Debug/android/AndroidManifest.xml contains:


When I run apktool on the generated .apk, I see something different:


Note that the //activity/@android:icon values differ: the "source" file to the build -- what Xamarin.Android generates -- is @android:drawable/btn_star. The _actual_ value -- as produced by aapt itself! -- is @*android:drawable/btn_star. Notice the added '*'.

`aapt` doesn't produce any warnings about the source @android:drawable/btn_star value, so I currently have no idea why `aapt` is generating an "invalid" resource reference.
Comment 2 Jonathan Pryor 2014-02-26 11:35:50 UTC
The answer is an unsatisfactory "Don't Do That™". In particular, if a '*' is in the resource name, it means that the resource is "private":


That isn't satisfactory because I can't find any useful reference on what resources are "public" vs. "private". For example, R.drawable.btn_star is documented, which you'd _think_ would mean it's public, yet apparently it is NOT (hence the warnings):


This is additionally irritating because `aapt` doesn't even issue a warning that it's changing the non-private reference @android:drawable/btn_star into a private reference @*android:drawable/btn_star, so the only way to know this is happening is to use `aapt dump badging` or apktool.