Attribute product="phone" and "tablet"

1,933 views
Skip to first unread message

Yuku Sugianto

unread,
Aug 26, 2012, 12:57:40 AM8/26/12
to adt-dev

I found several string resources from Android SDK that have the attribute "product".

For example in frameworks/base/core/res/res/values/strings.xml :


    <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. -->

    <string name="low_memory" product="tablet">Tablet storage is full. Delete some files to free space.</string>

    <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. -->

    <string name="low_memory" product="default">Phone storage is full. Delete some files to free space.</string>


This seems extremely useful for our apps as well, so we can mention "phone" or "tablet" instead of generic "device". 

Is this officially supported? Or is there any way to enable this?


Xavier Ducrohet

unread,
Aug 29, 2012, 1:49:25 AM8/29/12
to adt...@googlegroups.com
I think this is only used when building apps that are bundled with the platform. The correct string gets hardcoded in the apk depending on the device target. It's not like it's chosen at runtime AFAIK.

I'll have to check.
 
--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Yuku Sugianto

unread,
Aug 29, 2012, 2:18:34 AM8/29/12
to adt...@googlegroups.com
I see. Thanks. Hopefully this can be integrated into app developer's build system as well?

It seems that the framework and internal Android apps (Mms, Settings, Calculator, etc) are not built using Eclipse nor ant. Why shouldn't we use their build system (or otherwise they use our build system) so that the whole build system can be more extensively tested? 

Xavier Ducrohet

unread,
Aug 29, 2012, 2:27:58 AM8/29/12
to adt...@googlegroups.com
The build system of the bundled app has vastly different requirement that mostly resolve around building for different devices and using private APIs (which is more true for settings than it is for calculator of course). Those apps are also generally simpler and don't have a lot (if any) external dependencies (for instance no need to use the support library as they are running on a very specific device only).

On the other hand, you really don't want to use Makefile to build Android applications. Let's leave it at that.

As for the product attribute support, as I said it wouldn't work for apps that aren't bundled with a device. The new build system we are working on will help though in case where you do provide different apk for different targets.

Eason Lee

unread,
Aug 22, 2013, 12:50:24 AM8/22/13
to adt...@googlegroups.com
Hi Xavier,

Is it any update for this problem? Thanks a lot.

在 2012年8月29日星期三UTC+8下午2时28分00秒,Xavier Ducrohet写道:

Xavier Ducrohet

unread,
Aug 30, 2013, 3:57:08 PM8/30/13
to adt...@googlegroups.com
I just answered this in another thread already, so here it is again:

The aapt product mechanism was developed for the platform when you have a string that should say "tablet" vs "phone". It's meant to be a build-time flag only, ie the resulting application does not contain both strings and it's not resolved at runtime. Instead it generates two (or more) different apks.

While this is useful, this is also very limited. The new variant mechanism introduced by the Gradle-based build system overrides of all this.

If you are truly trying to generate two different APKs with different strings, then use flavors, and have each flavor contain its own version of the string. This will also let you configure per-flavor images, layouts, or any other type of resources, which the aapt product option cannot do.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages