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 '...
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.12.0
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-02-26 08:17 UTC by Ginie
Modified: 2014-02-26 11:35 UTC (History)
1 user (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 INVALID

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'
  sdkVersion:'19'
  application-label:'Icontest'
  application-icon-160:'res/drawable/icon.png'
  application: label='Icontest' icon='res/drawable/icon.png'
  application-debuggable
  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? 
always
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:

    <activity
            android:icon="@android:drawable/btn_star"
            android:label="Scratch.Bxc18018"
            android:name="scratch.bxc18018.MainActivity">

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

    <activity
            android:label="Scratch.Bxc18018"
            android:icon="@*android:drawable/btn_star"
            android:name="scratch.bxc18018.MainActivity">

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":

http://stackoverflow.com/questions/15650376/what-is-the-meaning-of-the-asterisk-when-referring-to-android-xml-resources

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):

http://developer.android.com/reference/android/R.drawable.html#btn_star

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.