Bug 19748 - Android build tools should pass the "--max-res-version" option to the aapt command, with the API level that the app is compiled against
Summary: Android build tools should pass the "--max-res-version" option to the aapt co...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.12.4
Hardware: PC Windows
: Normal normal
Target Milestone: 4.14.0
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-05-13 23:33 UTC by projectcuttlefish
Modified: 2014-08-27 13:57 UTC (History)
8 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:
VERIFIED FIXED

Description projectcuttlefish 2014-05-13 23:33:46 UTC
Suppose an Android app is compiled against API level 14. If the Google Play Services component is included, the build will cause aapt to try to compile all of the versions of resources inside of the Android compatibility support package (which is included as a dependency), including resources with an API level greater than 14. Some versions of those resources include attributes that are not defined for API level 14, so the build will fail with errors like:

Error 1 No resource identifier found for attribute 'paddingStart' in package 'android' D:\Cuttlefish\Sandbox\Brian\Test\Components\googleplayservices-16.0\lib\android\19.1.0\content\support\v7\mediarouter\res\layout-v17\mr_media_route_list_item.xml 23 Test

Error 2 No resource identifier found for attribute 'paddingEnd' in package 'android' D:\Cuttlefish\Sandbox\Brian\Test\Components\googleplayservices-16.0\lib\android\19.1.0\content\support\v7\mediarouter\res\layout-v17\mr_media_route_list_item.xml 23 Test

Error 3 No resource found that matches the given name (at 'paddingStart' with value '?android:attr/listPreferredItemPaddingStart'). D:\Cuttlefish\Sandbox\Brian\Test\Components\googleplayservices-16.0\lib\android\19.1.0\content\support\v7\mediarouter\res\layout-v17\mr_media_route_list_item.xml 23 Test

Error 4 No resource found that matches the given name (at 'paddingEnd' with value '?android:attr/listPreferredItemPaddingEnd'). D:\Cuttlefish\Sandbox\Brian\Test\Components\googleplayservices-16.0\lib\android\19.1.0\content\support\v7\mediarouter\res\layout-v17\mr_media_route_list_item.xml 23 Test

Our intention is to easily support slightly older devices, so we set the API level to 14. Setting the API level to 19 would allow the app to build, but would prevent the compiler from finding accidental usages of APIs that are not available on older devices.
Comment 2 Jonathan Pryor 2014-05-14 09:53:39 UTC
Fixed in monodroid/581241ae.
Comment 3 Jonathan Pryor 2014-06-27 17:45:28 UTC
Change to avoid breaking the world (or an untold number of customers): `aapt --max-res-version` will ONLY be used if the $(AaptUseMaxVersion) MSBuild property is True:

  <PropertyGroup>
    <AaptUseMaxVersion>True</AaptUseMaxVersion>
  </PropertyGroup>
Comment 5 Jonathan Pryor 2014-07-01 14:26:46 UTC
Comment #3 is invalid; there will not be a $(AaptUseMaxVersion) MSBuild property, and `aapt --max-res-version` will always be provided (unless $(AndroidUseLatestPlatformSdk) is True).

The `aapt --max-res-version` value used is based on $(TargetFrameworkVersion), but may be overridden within AndroidManifest.xml's //uses-sdk/@android:targetSdkVersion attribute value.
Comment 14 Peter Collins 2014-08-27 13:57:13 UTC
Fix verified using the GooglePlayServices (KitKat) component, v19, however this has already landed in 4.14 and should have been on that milestone for verification.