Google I/O 2011: Android Development Tools


>>Tor Norbye: I think we’re live.
>>Xavier Ducrohet: Hello, welcome to our session on Android development tools. I am Xavier
Ducrohet. I am the tech lead for the Android development tools at Google.
>>Tor Norbye: And I am Tor Norbye. I work on the Android development tools and I work
for Xavier.>>Xavier Ducrohet: Before we start, I want
to mention this is live streamed, and so we will take some questions from Google moderator
at the end of this session, and also some live questions. So you have the link here
to go onto moderator and post some interesting questions and vote down the bad ones, please.
So today we are going to give you some demonstration of some of the latest feature that we have
worked on for the last three to six months. Unfortunately, we can’t really show you everything
because there’s just too much. We’ll show you how those feature can appear
with best practices when doing Android development. And we will also show you some other feature
that we notice some developers don’t really know about but are very useful. And we will
also show you some upcoming new features. So let’s get started. So that’s the agenda.
So the first thing I want to mention, I know as a quick introduction to the tools, first
thing, they are completely developed in the open. We work directly in the repository and
we accept contribution if they are good. So if you are interested, feel free to talk to
us. When we work on the development tools, we
are pretty agnostic in terms of environment. We want to make sure you guys can work whether
you use Linux, Mac or Windows. And in terms of IDE, also we are very flexible. So there
is support for general Android support for Eclipse, NetBeans and for IntelliJ. And of
course there is support for command line tool. We have an end-based built system where you
can just build your application from the command line, and it’s very useful if you want to
do automatic build. And there’s even support for instrumentation so you can do automated
testing from the command line, or of course through a server.
I mentioned all those IDEs. And we started with Eclipse, really, because we can’t really
focus on all of them. But we are very happy that other people are actually dock support
for other IDEs, like IntelliJ has native support for Android. And when we work on the tools,
we try to make sure that we don’t just code directly for Eclipse and just embed everything
there and it’s one big application. We actually do a lot of small libraries that are reusable
so third-party tool vendor can actually do that and reuse them and reuse our code, and
it’s under Apache so it’s very easy to reuse. And of course some of those libraries are
reused also in the stand-alone application so if someone compiles with the end tool and
they don’t want to use IDE, they can use some standard application to do debugging, profiling
and those kind of things. So on the Eclipse integration part, we are
trying to be as integrated as possible to be a good citizen to the Eclipse ecosystem.
So mostly, if you know how to use Eclipse, you should know how to use the tools for Eclipse.
We have basic project support, build, launch, debugging, all of that is directly integrated.
We don’t have to care about all the plumbing that goes inside for you.
And we also have support for editors. As you may know, Android does a lot of different
XML files and we do provide some support for that, and we will talk about that a little
bit later. Some of the standard tools I talked about,
we tried to merge them into Eclipse so make sure they are integrated directly. And some
of them, like the Draw 9 Patch, is actually not there yet. We are working on it. At some
point. I mentioned editors. It is something where
we have gotten a lot of feedback that there are a lot of XML files and they are complicated
to know. There are a lot of attributes, a lot of specific values that need to go into
the attributes. And so in the past few months, really, we have really focused on improving
those editors. There are several different types. Some of
them, like the Android manifest, will show up like a form-based editor where you have
mostly some forms to just fill some values, text fields and things like that, but we also
try to make sure that there’s always an XML version for that. And the original version
of the XML was just the basic Eclipse XML editor which is good but not really advanced.
And so we have done a lot of progress recently on that regarding content assist, quick fix,
quick assist, and all those features that you expect when you are an Eclipse user.
The other part — The other type of editor really is WYSIWYG editor, and it’s mostly
the layout editor. And I know a lot of you want to have a full,
high quality UI builder, so let’s talk about that a little bit.
When you think about WYSIWYG editor, there’s two different things. There’s the interactivity
part, which we didn’t really have until like six months ago, so we have been focusing a
lot on that and Tor will show you some things. The other part is the rendering. So we see
a lot of people who receive a new version of ADT, ADT 9, AD T10 and they say the rendering
is still broken, and that is completely normal because the rendering code is not in ADT at
all. So what we have is, each SDK component, for
example, the 1.5 SDK component, the 2.1 SDK component, the 3.0 SDK component, all those
come with their own rendering engine, and we do that for two reason. The first is there
is a lot of resource in Android. When you want to draw a button in Eclipse, you want
it to be drawn the same way as it’s drawn in the device in terms of using the 9 Patch
that actually match that device. In fact, in Gingerbread we changed the look
of the buttons, and they changed again in the holographic theme in Honeycomb. So you
want to make sure whether you are rendering with 1.5 or 2.0 or 3.0, you get the right
button. So all the framework resources is packaged with each SDK component. So that’s
the resource part. And the code part, where we actually — So
we actually run part of the Android View framework inside Eclipse, or the view class, the widget
class, the pane canvas, all of that, we run that inside of Eclipse.
But below that, in Android on the device, there’s actually a lot of native code that
we didn’t want to bring into Eclipse, so we replaced that.
And so it’s been a very long process. Before 3.0, we had some version of replacing those
code and there’s some issue when you have a class like paint or Canvas, it is half native
and half Java so replacing it completely was kind of difficult. So we have done a lot of
improvement in 3.0 to really try to be much better in terms of supporting a lot of different
type of rendering, a lot of classes, like the path class was not supported at all in
previous version. It refused it inside your custom view or inside some widget that uses
it by default. It would just crash inside Eclipse.
We have done a lot of progress inside 3.0, and even more progress in 3.1 that released
yesterday. We are planning to keep improving that and then to go back and rerelease new
versions — new revisions, actually, of earlier SDK to port back those improvements so the
rendering in Eclipse will look good in Eclipse no matter what version of the rendering library
you select. And with that, we are going to give you a
demo.>>Tor Norbye: All right. Can we switch to
the Mac? Okay. So this is our new layout WYSIWYG editor.
The way you operate with this editor is drag and drop. So you can go to the palette, you
can drag something. And as you can see, as I am dragging over the canvas, I am getting
some feedback. You can see over on the right there’s an outline telling me what the drop
target is. Once I drop it, I can also obviously drag
around to reconfigure this view, and I can even drag over to the outline if I’m trying
to target a specific position or a small drop target or something. And obviously we have
unlimited undo, so let me clean that up again. On the left here you see a palette, and this
is giving you a preview of what these widgets look like for the current theme. So if I switch
to some other layouts here that have different theme, you can see the palette now looks — you
can see sort of a holo theme. Here is another customized version of the theme.
So the palette updates to show you what you will get. And I can click on a category, so
the time and date here, you can see the widgets in that category or text fields and so forth.
One category I want to point out in particular is the text fields category. If you went to
the ProTips session yesterday, you learned it is very important to set the input type
for your text fields. So what we have done here is we have packaged a text field with
a lot of different configurations for different input types.
So if you are going to put — if you are going to ask the user for a phone number, for example,
don’t just drop a plain text field there. Drop the phone number text field much that’s
going to set the input type so that when the user gets an on-screen keyboard, it’s not
going to have characters. It’s going to have numbers, for example.
The last category I want to point out is this one on the bottom. This is a special category,
custom and library views. When you open that, we scan your project in all of your libraries
and we find out if you have any custom view implementations. As you can see, I have a
few here. So just like the built-in widgets, I can drag
these and we get a live preview in the tool. So here is a tip. If you control click on
this you can jump to the code. So I am opening this custom view class and
I am going to edit the custom view a little bit. So I am going to copy this color definition
and drop it down here and let’s change the color to something recognizable. And I am
saving and I am going to go back to the layout. Notice how instantly the layout preview —
[ Applause ]>>Tor Norbye: So the preview updated.
So if you think about it, that’s means we’re actually running your custom views inside
the IDE. And of course we have do that. How else could we preview it? And as Xavier said,
we do the same thing with the built-in views. That’s how we can ensure that if you have
a relative layout in the tool, it is going to behave exactly the way it does at runtime.
So if you have custom views, you might be a bit concerned at this point. What if your
custom view is creating 50 threads or maybe connecting to a database or something? That’s
going to crash and burn; right? Yes, it probably would.
Android has already provided special API support for this.
So in your custom view, you can call this method “is in edit mode.” Your custom view
obviously extends view, and view has this method called “is in edit mode.” When you
run on the phone or tablet or an emulator, this method is going to return false. But
in a tool, this is going to return true. So what we want to do here is in the tool,
maybe you want to do some sample data that you are showing in the tool, and then if it’s
false, you might do the real read from database or something like that.
So here, we’ll just put some dummy data in the tools so it looks better. I am going to
call the add block method. We will put some time blocks in this time strip for a couple
of different times. Let me copy and paste this line a few times.
And so now when I save this and go back, you can see that in the tool, we’re getting sort
of a little preview. And this is now part of the class. I didn’t actually add any time
blocks in my layout here. So if I were to drag in another one of these, you can see
we actually get this design time behavior in the tool.
All right. So that’s custom views. [ Applause ]
>>Tor Norbye: Thank you. The next thing I want to explain is our new
layout actions bar. So I am going to drag in a couple of controls here, or widgets.
And if you see this area above the Canvas, there is a toolbar there. This area contains
a number of actions that depend on what you have selected and what the parent layout is.
So right now, I am in a linear layout. So I can, for example, toggle the orientation
of this linear layout, or I can change between match parent and wrap content for the width
or height. Or I can play with the gravity of this button. So, for example, I can right
justify it. Or I can modify the weights. So I can make the middle button stretch and take
all the available room or I can distribute the weights evenly. So if I delete this widget,
you can see the other widgets will take up the available extra room.
And again, the layout actions bar depends on what you have selected. So if I open another
layout, this is a widget within a table layout. You can see in the outline, it says table
layout. So now we have other actions here. There is an action, for example, to add a
table row or delete it or to delete the selection of rows.
Above the layout actions bar is our configuration chooser. So let me open a — This is a layout
that just has a bunch of different controls. And Xavier told you how we have one — we
actually do the rendering per SDK. So we have a render target toggle in the configuration
chooser, and here I can say I actually want to see this layout rendered with 1.6. And
you can see when I chose it, you can now see the old classic check-box look for example.
However, when you are using this tool, strongly recommend that even if you are targeting an
older version of Android, you want to use the latest version of rendering target, because
as you can see in this example, showing the system bar is only supported in the latest
version. And a number of the features I am going to show you doesn’t properly work with
the old versions of layout library until Xavier finishes back porting it.
>>Xavier Ducrohet: So one of the things that we added starting with 3.0 is the previous
version of the rendering library was just really run to a library, which is why we call
it run to a library. It wrote on the bitmap and some bonding box for all the objections
there. Starting with 3.0, we wanted to add a lot
more interactivity, and so we had to really extend the API between Eclipse and that rendering
library so a lot of the things you are going to see really requires that.
So that’s what why we’re going to go back and port that back to 2.1 and up, probably,
at least to start with. And so suddenly, when you get that new version of the rendering
library for 2.1, let’s say, then some of those feature will suddenly become available when
you use 2.1.>>Tor Norbye: All right. Next to the rendering
target, we have a locale chooser. So here is the layout where I have a bunch
of different translations, so I can switch to another language. And this is project wide,
so once you have chosen the project you want to work with I can go to other layouts and
it’s going to show me that new language. And below the language chooser, we have a
line with a number of different configurations that are per layout. So the first thing we
can do is we can change the theme. So the theme chooser shows me all the themes that
are referenced from the manifest, all the themes available in this version of the SDK,
and any themes that are in this project. So you can see that I can, for example, switch
to the welcome theme for this layout. Or if I switch to a default theme, you can recognize
the progress bar in the center; right? So that’s the theme chooser.
And over on the left we have a screen size selector. So obviously this is a ten inch
tablet size. That’s why you see the Honeycomb buttons on the bottom here.
If I switch to a phone layout, you can see this is a 3.2 inch size screen.
Now, I can choose that I want to actually render this as a tablet size instead, and
it automatically scales — or it zooms out so I can see the whole layout but if you look
at the zooms control here I can to 100 percent so it is rendering my layout the way it would
look on a tablet. And next to the screen size, we have the orientation
toggle. So I can, for example, test my layout in both orientations, back and forth here.
So let’s say that I want to make the landscape version of my layout different. The way you
do that is through the configuration chooser. There’s a button up on the top right here,
create. So when I click that, I get this dialogue which asks me what qualifiers I want to create
a special configuration for. So I am going to choose landscape and add
it to the list on the right. And you can see it tells me here that it’s going to create
a new file in the landscape folder. So when I press okay, it duplicates the default
layout and we are now in the landscape orientation. So if I open the package explorer, you can
see it created a new file here. So we now have a landscape layout we can edit
that’s not going to affect, for example, the portrait mode.
So let me go ahead and drop in an image here and when I drop that I get this resource chooser.
We use this resource chooser in a number of places in the tool when you need to input
some resource. So here is a quick tip for you. This one accepts wild cards. So I am
looking for a logo. I can’t remember what it’s called, but I can put a star and then
logo, and this is going to find all the matching resources for me.
So that’s my logo. Let’s use the layout actions bar to center it, and let’s also add some
padding, some margins. And here’s another tip. You can drag to move things around, but
if you hold the modifier key, you can actually duplicate. So if you want to, for example,
quickly put out a lot of buttons you can quickly do it with the modifier key. So I am going
drag this over on the left here so we get a symmetric look.
So now we have the landscape orientation layout, and if I switch back to portrait you can see
indeed we have different layouts now for the two orientations.
So that’s all well and good. But if you look at the header in this layout, and it contains
a bunch of stuff, a bunch of buttons and everything, and this has now been duplicated between the
two layouts, and that’s probably not fun for maintenance; right? If you were asked to change
the header, you have to go into each one of your layouts. You don’t want to did that.
And if you look in my outline, you can see there actually is a color strip above it,
and that’s just an include. So Android has a mechanism to avoid this kind of duplication,
and that’s the include mechanism. And we’re already using it for this color
strip. You can see it’s a separate layout that’s just included everywhere.
So what I want to do is do the same thing to the header. I want to have a separate header
layout that we include everywhere. And we have a new feature to help you with this if
you have already gone ahead and done this duplication. And that is this visual refactorring
called extract include. So I select the portion of the layout that
I want to refactor out into its own layout, and in the context, there’s this extract include
menu item. So when I choose that, it brings up this refactorring
wizard dialogue. It’s asking me for the name of the new layout but notice it also has a
check box which asks me whether I not only want to extract the fragments from this layout
but also look in all the other layouts and find duplication elsewhere as well.
So I am going to press preview and we get this dialogue here and can you can see it
is ripping out a bunch of XML from the layout and it’s createing a new file here that’s
the same XML plus some name space stuff. But look at this. It’s also found the same
header in a bunch of other files. And it’s cleaning all that up for me and replacing
it with an include. So when I press OK, it shows me my new header
layout. You can see it’s just the header, and I can go ahead and edit this if I want.
So when I press okay, it shows me my new header layout. You can see it’s just a header and
I can go ahead and edit this if I want. And if I go back to the layout we were editing,
and I select this header, you can see it’s now just an include.
Using this — [ Applause ]
>>Tor Norbyte: Thank you. And using this layout is also very easy. I’m
just going to open our form layout again. I go to the layout category. I can drag in
an include tag, and I’m going to drop it right here. Here’s the resource chooser again. We’re
going to point it to our header. You can see there’s our included layout.
We have one more feature to help with this. So if I go back to my layout here, if I need
to edit this header, I can obviously open the header file — header file, this is not
a C header file — but I can open this header layout, and I can obviously edit it. But what
if I want to see it as I’m editing it in context? I can head back to this and DoubleClick on
this include and look carefully at the layout as I’m doing that. Do you see what happened?
It grayed out everything. I can no longer select anything except the header. And if
you look carefully, I’m actually not editing the outer layout anymore. It opened the inner
included layout as you can see in the outline. But it’s rendering it to me the way it looks
within another layout. And so if I, for example, go to another layout
that was also cleaned up, this one, and I DoubleClick here, you can see it’s now letting
me edit this header in line the way it’s viewed from this other layout. And, in fact, I can
right-click on this layout. There’s this “show included in” menu. And we know all the places
this layout is included in the project. You can switch and view it the way it’s appearing
in any of these. That’s a feature I hope will really help you
work with includes. [ Applause ]
>>Tor Norbyte: Thank you. So that’s a feature to help you avoid layout
duplication. There’s another kind of duplication that’s really bad as well. And that is in-lining
styles. So I’m going to DoubleClick on this button. What that does in our tool is jump
to the corresponding view in the XML. And I’m going to show you that for this button,
we’ve in-lined a bunch of styles, some text size, font style. This is not good. And, in
fact, we’ve done it on all the buttons. What we want to do is use a similar feature
to create a logical style for this and put that in a separate file so there’s one place
to update. So I’m going to switch back to the graphical
view, and I want to select all the buttons. And quick tip, we have a special select menu
that lets me select all the widgets of the same type. That’s quicker, since this is not
a contiguous selection. Here’s all my buttons. And I can now invoke this other visual refactoring
extract style. So now I get another wizard dialogue. If you
look in the center of this, what the tool has done is look at all the attributes defined
by all the selected elements, count and sort them based on what their values are. So it’s
telling me, for example, that five out of the six elements set the foreground color
— the text color to foreground one and one of them set it to foreground two. In fact,
that wasn’t even intentional. That’s one of the things you want to use style so that you
don’t end up with things that aren’t fully up to date.
So I am going to name a new style here, home button style. I can also choose to unify the
styles with this check box. It’s going to rip out any values that are different. Let’s
press preview. And you can see it now creates a new style in my styles file. And in the
layout, it’s going to strip out, you know, all the inline styles and replace them with
style definitions. When I do that, we’re back to our layout. And if I DoubleClick again,
you can see we now have a much simpler definition. And we can go to one place to update the styles.
[ Applause ]>>Tor Norbyte: All right. Another thing that
we’ve improved a lot is support for list views. So list views have been very tricky for us
in the tool. We used to render this. Basically, nothing. And the reason for that is that list
views, they’re contents and even the ListView item layout is all configured from Java code,
and not a custom view, from your activities and adapters. And we do run your custom views,
but we do not run your activities. So that was tricky. But we have a solution now that
works pretty well. And what we’re doing is we’re picking a default layout to show you.
You can then go in and say I actually want you to show me the list using one of these
builtin layouts. Or more likely, you have a custom layout for your ListView items that
you want to see. And so you can invoke this choose layout here, which gives you the resource
chooser again. And in this project, have a particular list item session layout that was
intended for this ListView. When you choose this, we preview your list using exactly your
layout. So we’re planning to support something similar
to what I showed you with includes. We would love to let you inline edit these ListView
item layouts. We don’t do that yet, but I think that’s next on our plate.
>>Xavier Ducrohet: And also, that feature did not make it — it’s inside the next version
of ADT, but it’s not in the 3.1 rendering library. So we’re going to finish that, and
then we’ll release an update version of the 3.1 SDK component that will have a new version
of the library that will do that.>>Tor Norbyte: Let me show you a couple more
visual refactorings. First of all, we can let you change widget
type. So, for example, I can take this text field, it’s showing me some other likely candidates,
or I can pick any view type that I want really. But we’re going to convert it to a spinner.
And the reason you want to do that is, if you were to just delete the old text flow
and insert a new spinner, then your layout attachments would disappear, your ID attachments
and so forth. This let you preserve things in place. Let’s say I want to drag in a progress
indicator next to this spinner here. If I put in the table view, it creates a new column
which I do not want. What I really want is for this cell to be able to have siblings.
To do that, I can use the wrap in parent visual refactoring. This is going to insert a new
parent in the middle of the hierarchy. So I’m going to choose a horizontal linear layout
here. I’ll call it parent. And I now have, if you look in the outline, you can see we
have a new linear layout inserted in the middle. And I can now proceed to go and drag, for
example, this progress indicator and then I don’t get a new cell.
And we also have a change layout refactoring which attempts to make some conversions from
one layout to another. And we’re still trying to improve this. But we have the basics in
place. And that brings me to relative layout. So
show of hands, who here has worked with relative layout?
A lot of you. So then you know that relative layout is a
very powerful layout. But it could be a bit tricky to work with. I hope that you will
like this next part of the demo. Unlike everything else I’ve shown you, this
is not in the version 11 of the Eclipse plug-in that we’re going to release very soon. Our
tools, basically all of the source code is available. You can build it from scratch today
what you’ve seen. We’re still doing a bit of QA on the release. This is the follow-up,
so this is a preview to give you a sense of what we’re doing. Here’s the relative layout,
and I’m going to drag in a text field over this. As I’m dragging, you can see it’s trying
to attach this to sort of the nearest edge or maybe do some centering.
So I’m going to drop it around here. And then I’m going to drag another widget in, a button.
And as I’m dragging, you can see that it’s doing a bunch of matching. It’s trying to
pick a nice edge match for this. So I’m going to drop the button there. Let’s
do another text field under it. It’s attaching it right there.
And let’s put in a label and show you baseline alignment. So it’s doing a baseline alignment
of this label. And let’s put a spinner below it. So in addition to giving your geometric
matches as you’re dropping, I can also reattach any edge. So I can go and, you know, reattach
the right edge over here. I can do the left edge to here. Or maybe to here. Or to the
bottom. Or I can release an edge like this so that it goes where it wants to go based
on the intrinsic height. And, obviously, I can just reconfigure things. And it makes
sure that there are no cycles or any problems like that.
Notice also that as I’m selecting things in this layout, it’s showing me what the attachments
are and it’s also highlighting dependent nodes a bit.
And I can even turn on visualization of all the attachments in this relative layout. So
let’s go back to, for example, this activation screen. You can see here that, for example,
the bottom buttons are bound to the bottom right, whereas the content pane is attached
to the center, and so forth. So that’s what we’re working off relative layout.
And once we’re done with it, I hope you’ll find it very useful.
[ Cheers and applause ]>>Tor Norbyte: So the last visual thing I
want to show you is our support for animations. So in Honeycomb, there’s a new animator API.
So you have this new animator resource folder. And if you have animation resources in there,
you can open any layout, and you can select the widget. And when you right click on it,
there’s this play animation menu. In here, we show you all the builtin animation as well
as the animator resources you’ve added to your project. So if I select this, this custom
one animation, you can see that we previewed animation right in the tool. So you can make
some tweaks. So if I open this animation file — by the way, we have — we now have code
completion on this and documentation, so you can explore the API a bit.
[ Cheers and applause ]>>Tor Norbyte: So I’m going to insert an interpolator.
I’m going to change it to an overshoot interpolator and jump back here.
And now if I rerun the animation, you can sort of see the overshoot animation. This
gives you a good way to play animation and preview them before actually having to run
your application. Notice this animation is independent of the widget I chose. I can go
to this layout and run animation on the entire layout. It’s basically just an animation resource
you can apply to any object you want. The last thing I want to show you is —
>>Xavier Ducrohet: So I just want to mention something. Because if you start using that,
you’re probably going to have a problem. In the resource folder of your application,
there’s an anim folder. That’s where the animation are supposed to go. At the framework level,
they wanted to make a difference between the old animation framework and the new animation
framework. So starting with 3.0, you can actually put them in res/animation. So it’s not really
required, you can put them in either animation folder.
But the convention is that you put the old one in anim and the new one in animation.
And that’s the only place where edit is going to go and look for those. So the right-click
menu that Tor showed you where we list all the animation that you have in your project,
we’re only going to go and look in the new animation folder. So you should really put
them there. If you don’t find it, it’s just that you put it in the older folder. So that
will help you if you have an issue and don’t find your animations.
>>Tor Norbyte: Okay. The last thing I want to show you is our somewhat improved support
for pure XML editing. If you don’t want to use a UI builder, at least you should check
this part out. So if you switch to XML, obviously, we have
code completion for the layout types. So I can insert edit text. And give myself some
space. I can complete on, for example, the text property here. We get documentation.
We help you complete framework resources. We also give you help if you’re doing — if
you type strings by hand. So I’m going to type hello world. Notice that if I invoke
the Eclipse quick fix command, which is command one on Mac and control one on other platforms,
we had a quick fix to extract this string. By the way, all the visual refactorings I
showed you before, also available on XML. Quick fix on the element and you can do your
wrap in and so forth right there. So on a string like this, I can do extract
Android string. This is going to give me a wizard where I can quickly choose the key
I want to use. This will basically pull the string into a resource file.
I can also do some completion on the margin. Notice how you don’t have to type the name
space prefix. You also don’t have to type the layout underscore prefix. We match them
both, give you completion on units with documentation. Or if you create a nonexistent resource, like
this, you get an error, but there also is a quick fix to correct this error. So here
we have a missing dimension. So if I invoke this quick fix, it goes to the dimensions
file and adds an entry for me to customize. And we also help you with flags. So, for example,
for the text field, there’s a bunch of flags you may want to set. And we help you with,
basically, picking all the various attributes you may want to add to this flag.
Now, we also have support for go to declaration pervasively within the tool. So, obviously,
I can hold the control key and hover over here and I can jump to the string that we
just extracted. And if you have many definitions of a resource, for example, notice how if
I hover over this okay, it instantly shows me all the locations where this string is
defined, all of the message catalogues so I can quickly, for example, go to the German
definition of okay, which is same as English, I guess.
[ Laughter ]>>Tor Norbyte: And this works not just from
layout XML files. It works everywhere. So if I open the manifest file, for example,
I can jump to the drawable resource that’s going to open it. That’s the app icon. I can
jump to a permission that opens the documentation for that permission. I can jump, obviously,
to string resources, which I’ve already shown you. And I can jump to, for example, the activity
or services registered here. So this is going to jump into the Java code.
And within the Java code as well, if I, for example, hover over this layout, you can see
that it’s telling me that this resource is defined in these multiple layouts here. And
even for IDs defined in any inline in any XML file, it will locate it and go to it for
you. So that’s basically — I’m going to turn it back over to Xavier.
[ Cheers and applause ]>>Tor Norbyte: We have the slides.
>>Xavier Ducrohet: All right. That looks great. There we go.
So that’s what we’ve been working on on the layout editor. Obviously, it’s something that
we are going to keep working on. So we’ll get even more improvements.
So I wanted to do a quick talk about another tool that we have that’s not technically packaged
with the SDK. It’s created by Roman Nurik, who’s a different product advocate at Android.
And it’s a Web application. It’s Android Assets Studio. And it’s a Web app that will allow
you to create assets. Now, creating a layout is one thing. But actually,
you know, putting logos in that layout is another thing. And maybe some of you are working
alone and don’t have a graphic artist to work with you. So that tool allows you to create
icons for your launcher icons, but also the — you know, the big 512 by 512 icon that
you need to put on Market. And then, like, notification icons, menu icons, and tab icons.
And it’s even going to create different style based on which version of Android, since we
changed, like, for the notification icon. And then you get a big zip file that contains
all the icons in every density and so on. It’s very easy to use. You know, if you’re
looking to get some quick assets, that’s a great way to create some assets and make sure
that your application has some nice-looking icons.
So now I’m going to give you a quick demonstration on some features that we have in the tools
that you should be aware of, but maybe are not aware of.
So I’m sure a lot of you have been doing Android for quite a while now. But I still want to
mention that in DDMS, you have that log cat view. Use it. If your application is crashing
and you get a false close dialogue and you’re wondering what’s going on. The whole exception
has been dumped into logcat. Just go look at it. If something is going wrong, first
reflex should be go to logcat. And then if it’s not there, they try to connect to the
debugger and see what’s up. I should have — there I go. So I have a small
application here that’s — okay — that’s an application that should be showing around
here. So the thing that I want to show you is, you
probably know Traceview. Traceview is a profiling tool that we have. We’ve had it for a long
time. It’s — want to improve it, but it’s there, and you should use it. It’s a stand-alone
tool, but thanks to actually an excellent contribution, we have it integrated in Eclipse
right now. So that’s much better. And it’s very easy to use. So what I’m going to do
here is, I’m going to click on that button, which is going to start profiling my application.
Then I’m going to do something with my application which takes a while. That’s fractiles. And
I’m just going to click back here. It’s telling the VM to stop profiling, send me back the
trace file so I can look at it. And then you get Traceview directly inside
Eclipse. So if you don’t know about Traceview, you can easily, like, zoom in, see here, and
you see here the thread that’s red that is apparently taking a lot of time, you can look
at the blue, zoom in even more to see what’s going on here with all of those methods here.
So you have a lot of things that happens here. And because it’s integrated into Eclipse,
you can easily click command and click here and go — hmm. You should be able to. Hold
on. Is it….
Maybe not.>>Tor Norbyte: Maybe not.
>>Xavier Ducrohet: So normally — I think you have a custom build.
>>Tor Norbyte: Yeah.>>Xavier Ducrohet: So normally, you should
be able to just click there and go directly to the source code.
So Traceview is a great way to profile applications. You can easily either click on that button
so, you know, click on that button to start profiling, do something that takes a lot of
time on your application, click back, and then you get all the threads and everything.
And you can also, if you want to really profile something very specific, there’s a class called
debug, Android.OS.debug that allows you to actually start it from your code so that you
can do that manually. The last thing I want to show you, which is
a little bit similar that we’ve had for a while is this button here, which is basically
going to dump an edge profile. So edge profile, it’s a type of profile that contains a profile
of your HIP. So if you choose any application or just use the same one, it is going to instruct
the VM to send back the edge profile and it’s going to open it.
So what happens is we are getting the edge profile directly from the VM, and we have
to open it somehow. And there’s a great Eclipse tool called MAT, Memory Analyzer Tool, which
if you install it — and it’s free. You should just go on the Eclipse.org Website and download
it and put it inside your Eclipse, then it will open it and you will have it directly.
So basically it’s opening your file, and then there’s a lot of tool in there. And I am not
going into too much detail. There’s another talk after that in this room. No, in the other
room, room 9, at 4:15 that actually talks about memory management.
And if we can go back to the — There we go. So memory management for Android app, room
9 at 4:15, and you learn all about using MAT and helping you profile the memory of your
application. So those two small feature in DDMS that also
exist in the stand-alone version have been here for a while but a lot of developers don’t
know about T those two buttons are really helpful when you want to quickly dump either
the profiling or the memory information. All right. So now we heard that some developer
were having issues with that tool. And we are very aware of it. Trust me.
So, yeah, the emulator running in Honeycomb is a big, big issue. So we are going to talk
about that a little bit. The first thing I want to explain is that
the emulator is not just a small compatibility layer that exposed tom API to an application
to run directly on your host machine. It’s actually emulating a full ARM-based device.
It’s actually emulating hardware. And it’s running all of Android all the way from the
top where you have your application, the framework, the Dalvik VM, the kernel, and hardware driver.
It’s like emulating a full hardware. So this is great for Android because, as you
know, an Android application does not just have a main entry point, you know, a main
method that’s being called. You can launch it from the launcher, you can receive like
a broadcast, and you have a broadcast receiver to get T maybe another application is calling
your content provider and that launch is your application. So there are so many ways that
we can’t really use a simulator that would just be running a fake version of Android
on top of the host. So we have to use that. So there’s two issue with the current emulator.
The first one is, as I said, it’s an ARM device. So it’s actually executing ARM code, not X86
code which is what we support for the host, for the SDK, whatever, Mac, Linux or Windows.
So that’s a bit slow. It’s not that bad. We found out it’s not exactly
the issue why it’s slow. The other issue is that all of the rendering
pipeline is completely software. So there is no hardware GL. But there’s also no hardware
composition. It’s all software. And not only it’s software but it’s software
implemented ARM, and that ARM also has to be translated back into X86 to actually run.
In fact, if you run the Gingerbread emulator in a very tiny resolution, like the smallest
we support is probably QVGA, you will find that, hey, it’s actually not bad. It’s actually
pretty good. And then you create another AVD and you give it the Honeycomb size tablet
and then it’s super slow. So the rendering is really the issue. And
we’re working on it. So the way we’re doing is we decided the best
way to do that is to have full time hardware rendering in the emulator. And we’re working
with a company called Graph Tech. They have a lot of GL expertise, and they are helping
us with that. And so the first issue that we had is that since it’s an ARM device, it
doesn’t know about the host machine; right? On Android, you can’t go and access like the
file system of your Windows PC, because it’s really, it’s sandboxed. So we had to design
a nice and fast pipeline to transmit some other — to transmit all the rendering information
back to the host machine to have actually a native application running, and then have
hardware support for that. The other issue is that most of your machines,
like on Windows, at least, and Mac, you only have GL support, but Android use the ES version
of that. And although GLES 1.1 is translating to GL, GLES 2.0 is much more complex with
shadows that are not fully compatible with GL.
So we are working on that. It’s a lot of work but we are working on it.
So I wanted to give you a quick demonstration of what happens here.
So, now, keep in mind that this is a very fresh build, but also it’s a very ugly prototype,
because we wanted to show you something. So in the — oh, yeah, so you see the emulator
here. If you haven’t noticed, starting with our 9, I think, version 9 of the tools, we
have snapshot support. It basically allows your emulator to boot in like 3 seconds. It
doesn’t actually boot. It just restart your previous nonstate.
So if you enable that when you create an AVD, when you kill your emulator, basically it’s
going to save the state. Now, if you have an emulator that has 256
megs of RAM, it’s going to take a huge size to save the snapshot in the 5- to 600 megabyte.
But then that allows you to reboot super fast. So when you develop, generally you can use
that. It’s currently available. So what I’m going to show you here is that’s
the version that’s not accelerated. And so this is Google Sky map, that uses GLES 1.1
and you are going to see that it’s — a bit slow, but that’s expected nowadays.
Okay. So it’s running 600 by — 800 by 600, which
is slightly bigger than a nexus 1. I am going to switch to manual mode here and when I move
you can see it’s clearly not tracking my mouse very well. It’s very slow.
So the current version of — that we have, as I said, it’s a prototype, and all we are
doing — all we are about to do is render one application and only that one application.
Because one of the other challenge that we have is that the native application that’s
going to run on your host has to be able to endure a lot of GL context. It’s not just
writing one GL application. It’s doing GL context for all of your OS, and you could
have several context. But right now we only support one. So what
I am doing here is I am just doing a force stop on this app. And then I’m going to basically
push a file to the emulator to tell it to basically white list that application as running
— as being able to run in hardware. And….
There we go. So what is happening here is that we have
another application that’s not the GL, the emulator that’s going to do the rendering
for the emulator. And of course in the future you won’t have that. It will be just integrated
with the front end of the emulator. But right now, we have that, and it’s a little bit annoying
because I actually have to do my process here. And so you can see here that the GL part is
there, but the non-GL part is still there. So it’s really the one application. It’s just
that the GL part is being rendered in another application.
So I am going to do the same thing here and switch to manual mode. And you can see here
when I switch, it’s much faster. [ Applause ]
>>Xavier Ducrohet: So you can see that it’s much faster. There’s still some issue with
all of the input and all of that, but it’s going to allow us to scale to much larger
resolution and still have good rendering support. I mentioned this is the bottleneck right now.
And the other bottleneck is it’s maybe the fact that it’s probably running ARM code.
So I actually have another demo here which is going to run a smaller version and I am
going to run a game that’s available on market. So I am going to have to aim properly when
I actually select on it. Let’s see.
So that one is running in half VGA which is the size of the G1.
And, I have become very good at clicking on those button.
>>Tor Norbye: It’s a special on-screen keyboard.>>Xavier Ducrohet: So it’s running in half
VGA. The rendering is fully hardware OpenGLES 1.1. You can see on the top left that I am
running at 60 frame per second. I am using the D-Pad right now to play. It’s actually
me playing, and I am not very good at it. And we’re running between 50 and 70 frames
per second, but here we are actually running ARM code; right? We are not just running — So
this is hardware accelerated, but we are still running and basically dynamically converting
the ARM code into X86 code. So basically we found out that if the rendering
is fast enough, the fact that we are not running X86 code is not really a problem.
We are still investigating that to see what we can do. And, in fact, in the previous session,
the Google TV folks mentioned like an SDK add-on, and you know that one will be running
X86, so we are actually looking to be able to run X86 images on the emulator. If you
have Linux then you can run it through you virtualization, because if you don’t have
the KVM module, then you are going to have X86 inside your emulator and it’s going to
convert it into X86 to run natively, and that’s not very good. So if you have the KVM model
it runs it directly. The problem is that for QMU it is not available for Mac and Windows,
so that’s a problem. So we are investigating what we can do to solve that.
So we’re working on it. We’re like heavily working on it. There’s a lot of work still
to be done. It’s coming. I know there’s going to be a question so I am going to answer right
now: At least a couple more months. But we know that it’s very painful.
Hopefully some of you I heard got some new tablets so at least you can use that while
you wait. For those on live stream, well you need to get a ticket next year.
And you know we are working on it. We already know it’s an issue. And as I said we have
an external company helping us. We are doing what we can.
[ Applause ]>>Xavier Ducrohet: So I wanted to finish quickly.
I mentioned open source at the beginning. And Tor said that actually everything that
we showed you is available right now on the open source tree. So if you go to tools.android.com
you can look at all the information to actually download and build the source code.
>>Tor Norbye: If there’s just one URL you write down, it’s that one. From there you
can find instruction on how to build the bits, how to check them out. We have a blog on there
where we post feature updates as we do them. That’s the place to go.
>>Xavier Ducrohet: Just go to tools.android.com and you have all the information that you
need. The moderator question is there, and there
are two mics in the middle. So we’re going to take a mix of live questions and Google
moderator. And so when I do that — Okay. Why don’t you
start on the first mic.>>Yes, hi.
Is there a way to attach multiple instances of instrumentation to basically multiple processes?
Right now, it seems like only one process can be instrumented at a time so there’s no
way to do automatic testing for multi-processors.>>Xavier Ducrohet: I think it’s only one.
To be honest, I am not entirely sure. Anything that has to do with API and things like that,
we may not be the best ones to answer. Try the Office Hours.
>>Do you know who is there that will be the best person to ask?
>>Tor Norbye: I guess ask when you get there.>>All right. Thank you.
>>Xavier Ducrohet: Sorry. Second mic.
>>Yes, I was wondering if you guys are planning to add some support in the future to help
record videos of our applications to help promote them and whatnot.
>>Xavier Ducrohet: Well, that’s –>>Tor Norbye: That probably would not be the
tools.>>Xavier Ducrohet: It’s more an issue of like
the system image. Like the screen shot during the Fireside Chat there was a question about
enabling screen shots for apps. The security involvement for that, we need to make sure
that no other application can do it and things like that.
I know that some devices are starting to do HDMI out, so you can do that but it’s not
really a tool. It has to come from the framework.>>Okay. Thank you.
>>Tor Norbye: I want do this one. So on the moderator, we have a question, can
we expect better XML error handling as far as Android layout is concerned? The answer
is yes. We didn’t demo that, but in the latest bits we are a bit better about if there’s
a problem during rendering, we log it, we put some hyperlinks up. There’s this new error
bar that shows up below the layout where we try to give some diagnostic information. And
if we recognize certain kinds of errors, for example if it’s a missing resource and we
notice you have AAPT errors in your project, we tell you, hey, you know you have an AAPT
error which would mean AAPT couldn’t run so there are probably missing resources.
So we are trying to work on this and I guess we are not done but it’s definitely better
than it was.>>Xavier Ducrohet: First mic.
>>I was wondering about multi-touch support and specifically being able to generate multi-touch
scripts that I could replay and see how they are being handled since they are very complicated,
to kind of push through the pipeline of UI.>>Xavier Ducrohet: Yes, we don’t really have
a solution for that, and we are aware of it and we are not really working on it.
So with the GL stuff that we are doing, we are going to have to rewrite a new front end
anyway for the emulator. So I think like recording and replaying is probably something that we
will try to do. I mean, there are some now that do support
multi-touch. Windows does it but it’s a little bit complicated because the front end is really
cross platform. Right now it is using SDN and it’s cross platform, so we can’t go and
use really a lot of Windows specific API. But that could be an option, too. I don’t
know how common that is, people having that —
>>Even if there was a way we could write some small script that would animate some
points that, would be helpful.>>Xavier Ducrohet: Yes, I think that’s definitely
something we need to do.>>Tor Norbye: I guess we have addressed the
next moderator question. Do you want to jump to that?
>>Xavier Ducrohet: Let’s go to the second mic first, but yes.
>>On the layout editor, the selection of the configuration, is there a way of setting
the default configuration for when you create a new one or you are opening a resource that
you have had in there for several versions? And it seems to want to open it up with QVGA.
>>Xavier Ducrohet: So the new version is a little bit better on that. The version 11.
Where it will — for example, if you say target 11 — target SDK 11, I think it is going to
try to open them in Honeycomb. We did some heuristic to try to improve that to at least
not open with the worst possible resolution.>>Tor Norbye: We are planning on for the following
release basically look at the layout you are currently in. When you open a new one we are
going to use that as one of the things we consider.
>>Xavier Ducrohet: But we are definitely — it’s a pain, yes.
>>The other thing is like we have our default strings and such are in English. We also have
Spanish translations and it seems to want to open up the Spanish one.
>>Tor Norbye: That is something we have fixed in the new version. When I showed you the
rendering target and the locale, those are project wide. Once you switch it there, open
any other file, it will force the new language. So that is solved, but not the screen size
yet.>>Xavier Ducrohet: When I change a Java file,
Eclipse rebuilds just that file, giving me a new APK.
Yes, so we have noticed if you have a really big project with a lot of resources, building
can be really long if you do resources change. And actually, we are going to look at that
like right after I/O. There’s a lot of things that we need to do
first. Right now, there’s a first pass that does
APT and generate the R class based on all your resources and another one that compile
your resources. So for all the editors we showed you, when
you have that chooser, Eclipse knows — we created some code that knows all of the resources
that you have. So we want to, instead of running APT, which is like an external native tool
running, instead of running it to go do a clean look at all the resources to generate
that class, we want to try to be a little bit more smart and use what we already know
about the resources, see the resource change and do an incremental basically generation
of the R class. The other part is on the second state is already
running APT to do a package of your resources and that’s a little bit long if you have a
lot of P & G file because we process them to crunch them to make sure there’s no extra
data we don’t really need. So I think one of the things we need to do
is allow you to crunch them yourself and then set a flag saying don’t crunch them so that
the packaging of the resources will be faster. First mic.
>>Sure. A couple things. First, I realize if you define a drawable as a part of your
style, those drawables are not contextual. It doesn’t actually link back to a drawable
and it doesn’t do code hinting. So for example, if I define some style and — like some background
style or something like that and I define a drawable as part of that, like some image
–>>Xavier Ducrohet: By “define” you mean like
reference a drawable?>>Sure, sure, reference a drawable. And what
it does right now, the XML doesn’t provide — it’s like I can’t link to the drawable
from the styles dot XML, for example, and I am not able to get code suggestions, even
though the drawing is –>>Tor Norbye: We haven’t released ADT 11 yet,
but it has a lot of improvements in go to declaration and code completion. And we also
just added code completion for drawable files. So before that, you would end up with like
the base Eclipse XML model which knew nothing about Android. So I think there might still
be an issue but a lot of this is going to be a lot better very soon.
>>Another thing is up guys demoed the Android assess tool which is pretty cool. I use it
to for generating icons. As part of that project there’s also a pencil plug-in for mockups.
>>Xavier Ducrohet: Yeah.>>Do you guys have in your future to maybe
integrate that into a part of Eclipse so you can actually, instead of building code, you
can build mockups of shuttle product managers and things like that?
>>Xavier Ducrohet: That’s not a goal right now. It’s a great idea but right now we need
to really focus on improving the layout tool. I think that’s the one thing we need to focus
on besides the emulator. But that’s a good idea for after.
>>Okay. Thank you.>>Xavier Ducrohet: Okay. We’ll take — I just
did that one. Well, if it’s just — so do you have any advice
for getting the emulator to load faster. I mentioned the snapshots, use them. I know
that right now when you close the emulator, it takes a little bit of time because it saved
the snapshot. That’s actually a bug. We fixed it. It will be in the next version and it
will quit instantly.>>Tor Norbye: The other thing to add there
is some people, they run the app and quit the emulator. Leave it running. When you read
a second time from Eclipse it will redeploy very quickly. So that’s very important to
be aware of.>>Xavier Ducrohet: You should launch the emulator
once at the beginning of the day, basically, and just redeploy to the same one all the
time. You don’t have to quit it all the time.>>I have an app that has a lot of hand edited
XML, and so it’s neatly formatted. But when I use the visual tools, everything just goes
on one line. It looks terrible. I end up having to — if I want to be able to look at it —
>>Tor Norbye: This is a high priority for us. I personally want to look at the XML formatting
a bit. There is a couple things you can do. First
of all, Eclipse has some formatting options where you can tell it that you want attributes
on separate lines. However, we don’t automatically apply that formatting. But there is a special
option in the Android settings where you can say format, you know, automatically format
or something like that. It’s not ideal and we are going to try to make this a lot better
but you can do that and it should run the formatter after every edit.
I think we are actually out of time.>>Xavier Ducrohet: Yes.
>>Tor Norbye: I saw a bunch of good questions on the moderator so we might answer at least
the ones easy for us to answer.>>Xavier Ducrohet: Yeah, we can do that.
Thank you for coming.>>Tor Norbye: Thank you.
[ Applause ]

92 thoughts on “Google I/O 2011: Android Development Tools

  1. Great to hear that the emulator is being fixed. Whilst it's cool that 5000 Android developers got a brand spanking new Samsung 10.1 to code on, the rest of us won't have enough willpower to continue development with the emulator in its current state.

  2. Nice, but it seems that for apps that uses Google API the tool is not working, there's no theme availables on the tool.

  3. Just saw the new UI tools… OMG

    The most frustrating part of Android development solved — even made enjoyable? It's so beautiful….

  4. i tried to download from tools.android.com/download/ and followed the steps but it says a new version is already installed and let me guess the new version is just nothing like the one running in the video above ? Can anyone help me out ?

  5. Almost everything shown in the video is available in ADT version 11, which has been released (you can find it at developer.android.com/sdk/eclipse-adt.html ).

    The new relative layout support is in ADT 12, which has not yet been released, but a milestone build is available. See tools.android.com/recent/ and tools.android.com/download/ .

  6. @somegoodboy That feature requires *both* ADT version 11 *and* the new layout library, which has not yet been officially released, but you can download and install preview versions from tools.android.com/download/

  7. Okay, I love Android, am impressed with Google, but please, give your staff some training on effective presentations!!! This presentation irritates the hell out of me: first of all, the speaker can't stand still AT ALL…secondly, he has to work on his pronunciation and tempo … with such an accent, you should speak slower.

    Apart from that, good stuff

  8. @einc70 no shit 🙂

    The accent itself doesn't bother me as much, but it's the way he talks and moves…very irritating to look at and listen too… he should take a course on "Effective Presentations" (IBM used to have such a course…it was brilliant…videotaped you while presenting…damn confronting, but teaches you how to present something without irritating your audience 🙂 )

  9. The new emulator might even be too good. Imagine people playing games on the emulator :). They might have to open up the market so that people can buy and use our apps without a phone 🙂

  10. Please, Google, introduce Qt Libraries in Android… A lot of apps will be ported and let's be sincere, Qt Framework is a lot more better. Android might receive some very good UI love with QtQuick/QML…
    Qt Lighthouse only needs the libraries on the Android, the rest of the job it will do himself…

  11. @jehcrazyjehcmy Only 4GB for my e-mail/browsing computer. Checked Task Manager and Opera uses around only 1GB with 20+ tabs open. lol, right now I have about 50 actually. Nothing a modern computer can't handle really.

  12. @theverylittleone I'm glad you've demonstrated that you know absolutely nothing about technology and the problems associated with making the emulator high performance.

  13. @MrJoso101
    selection of a personal laptop is a matter of taste. notice that Xavier uses Linux on a ThinkPad. Does it matter whether Tor has a Mac? I really don't think so. Besides, many good developers have multiple notebooks, so there's nothing wrong with getting a Mac and using it to develop Android. Google competes with Microsoft too, so what, they can't use Windows anymore?

  14. @edikii I'm not a gay and wanna tell you smth….When you invite your friends to your house, does your mother come and say to everybody: Hi, I think my son is retarded, he has no job or a girlfriend, yesterday I caught him watching porno?
    They are developers and you are only consumer (95%) so keep your expressions.

  15. @Vlaxiti oh..totally france. IDIOT. Before you open your foul mouth, investigate your head and see whether ur brain is there. How do you speak france, duh?!

  16. @edikii how does sexual orientation matter in knowledge delivery? i guess it doesnt. to humans at least…i dont know with birds like you.

  17. @tnorbye: Is V11 = ADT11 = r15? Because all I find for windows is the r15 release, is r15 is what this lecture talking about? I tried to update from within Eclipse and I tried to download and install the r15, both of course same results. If the V11 is different, where can I find it? I appreciate it, thanks. [Also thanks to all who contributed, great Job, Great Work].

  18. Thanks to Xavier and Tor for demonstrating this. It is a very fact intensive topic and the developer will have to put down some effort grasping things. But the video format is great for replaying stuff.

  19. I always thought all the XML was just hardcoded piece of.. that couldn't have any use on anything visual, this video has proven me wrong. Thanks Google!

  20. the irony is you are watching this on youtube owned by google. another irony is that mac os x is unix just like android which is built on linux. only difference – android is fully open source and free.

  21. please anyone can tell how can I got those item which stored in Custome & Library Views?
    Cause my eclipse 3.6.2 doesn't have anything !

Leave a Reply

Your email address will not be published. Required fields are marked *