8

The Android (Open Source Project) native launcher source code seems to be missing the following required XML layout parameters in some of its published resource files: layout_height and layout_width

Missing attributes

Compile-time exceptions

This breaks launcher compilation, at least independent compilation, throwing errors such as:

  • 'layout-width' attribute should be defined
  • 'layout-height' attribute should be defined

Note: there are many other issues that need to be resolved in order compile Android launcher2, this question is about these specific missing attributes and how come they are missing?

How does Google compile its launcher and what are the LayoutParams values?

So how is Google able to compile the code when these required attributes are missing?

Furthermore, what are the values that should be used, should they be:

android:layout_width="fill_parent"
android:layout_height="fill_parent"

or wrap_content, or specific pixel values - in other words, where can I get this kind of information / what is the secret build process?

Community
  • 1
  • 1
Cel
  • 6,467
  • 8
  • 75
  • 110
  • 3
    Dunno how Google does it exactly, but it's built along with the Android core, so maybe they disable these warnings. I've open sourced my efforts at compiling the launcher [here](https://github.com/RaghavSood/CompilingLauncher2), and I got most of it to work. It compiles and runs, but isn't bug free. – Raghav Sood Jan 02 '13 at 13:48
  • @RaghavSood thanks for sharing your work! i see you have used match_parent in your [AppsCustomizeTabHost](https://github.com/RaghavSood/CompilingLauncher2/blob/master/res/layout/apps_customize_pane.xml) but I believe doing that causes some layout distortions (and [such "fixes" may be related to the zoom anomalies, too](https://github.com/RaghavSood/CompilingLauncher2)) - do you know how to ignore the warnings you mention above? (i checked out the make files and python scripts under Launcher2 and at least these do not seem to add any LayoutParams) – Cel Jan 02 '13 at 13:59
  • I ended changing a lot of things to get it to compile. I also had the app list looking fine, but then I changed something and can't remember what. All this was done months ago in June 2012. And I don't know how to ignore these warnings, sorry. – Raghav Sood Jan 02 '13 at 14:06
  • @RaghavSood thanks anyway! ignoring these warnings seems to be a fruitful avenue, so if anyone could confirm that or knows how to do it, that would probably work as an answer.. – Cel Jan 02 '13 at 14:11
  • 2
    Ignoring these warnings might not help, as on some versions of Android (ICS and above I think), the lack of those two parameters results in a runtime exception. – Raghav Sood Jan 02 '13 at 14:12
  • @RaghavSood ic :( well, the answer must lie elsewhere then.. – Cel Jan 02 '13 at 14:17
  • 1
    You mat want to take a look at [this](https://groups.google.com/d/topic/android-building/DqYdq7KGUhw/discussion) as well. They managed to build the launcher without changes, but couldn't get it to install. it may install on a Nexus Device though. – Raghav Sood Jan 04 '13 at 14:37
  • AOSP projects are not SDK projects and cannot be built as such. – CommonsWare Jan 10 '13 at 20:04

1 Answers1

5

We do not compile Android with Eclipse+ADT but with make. The compilers do not check for layout_width and layout_height at build time. When these attributes are missing a runtime error is generated. But Launcher2 is built so that these attributes are not needed (using code to generate layout params for instance.) There is nothing secret about it :)

Romain Guy
  • 97,993
  • 18
  • 219
  • 200
  • Thanks! I was able to disable some Lint checks for IDE-based compilation as well and successfully built the ported launcher without these 13 XML attribute pairs, and i have not encountered any runtime exceptions with these (custom) layouts thus far! (configured IntelliJ IDEA project properties, not 100% sure about how to do it in Eclipse) – Cel Jan 10 '13 at 21:48