Thursday, November 22, 2012

Android: Jelly Bean forward locks paid apps

Today, a Monkey Write user complained that sound wasn't working on the workbooks he bought. I sell workbooks as separate paid apps on Google Play, which supplies data to the main app. Most of the data is retrieved via a ContentProvider, but for the sound the main app simply reaches out to the other apk and loads the sound file from its assets:

Context workbookContext = context.createPackageContext(
    packageName, 0);
AssetFileDescriptor afd = workbookContext.getAssets().openFd(
    "pronunciations/" + soundFile + ".ogg");

This depends on the resources and assets of an app being world-readable. But from the logcat, it seems that the main app could not find the sound file in the asset folder of the workbook app:

java.io.FileNotFoundException: pronunciations/kou3.ogg
 at android.content.res.AssetManager.openAssetFd(Native Method)
 at android.content.res.AssetManager.openFd(AssetManager.java:331)

I searched and searched on the internet to no avail, until I verified with the user that sound works fine for the free workbooks he downloaded. By including the word "paid" in my queries, I found a StackOverflow post with this critical bit of information:

Paid apps on JB devices are 'forward locked'. This means that the APK is split in two parts -- one with public resources, and one with private ones and code, which is not readable by other apps. I haven't looked into how files are split in detail, but the problem you are seeing suggests that assets are part of the private APK.

More importantly, he provided a way to test forward locking without going through Google Play: adb install -l myapp.apk

With that, I managed to reproduce and fix the problem. Since the assets of the paid app is no longer world-readable, I use a ContentProvider to read the sound file and have the main app query for it. The user has downloaded the updates from Google Play and verified that sound now works for paid workbooks. Yay!

Sunday, November 18, 2012

Devoxx

The grand finale for my Europe speaking tour is Devoxx. And grand is the right word for it.

A grand conference

Devoxx took place in Metropolis, the second largest cinema complex in Europe. The AV system is amazing. Gorgeous floor to ceiling projection with live video of the speaker on the left and slides on the right, plus a beautiful outer space background. Just stunning.

As if that is not grand enough, Stephan and team sprinkled the conference with panache. A troupe of Nao robots opened the conference with a dance, a motorcyle vroomed on stage in the middle of a keynote, celebrity speakers wearing giant hats... really good fun.


Nao robots

Java Posse with their signature hats

Android talks

I first heard about Devoxx from watching an Android talk on Parleys by Romain and Chet. Seems to cover many difference facets of Java, Android being one of them. In May I saw Romain and Chet in person at AnDevCon III, and asked them about Devoxx. That's when I decided to apply to speak there. Lo and behold, I got accepted!

Google delivered many awesome Android sessions at Devoxx, with Nick and Rich holding a hands-on workshop on the SDK, Romain and Chet talking about Jelly Bean, Xavier and Tor talking about the build system.


Chet and Romain talking about the developer options in Android 4.2

There were many great talks from non-Googlers as well. Pierre-Yves Ricau talked about Android Annotations, Jake Wharton showed us the open source libraries used at Square etc.


Jake talking about open source Android libraries

And then there is me, the ex-Googler! I talked about Android Custom Components, and people really liked it.

(Side note: did you know that Storify was started by Belgians?)

Awesome hallway

Although there were many wonderful Android talks, there were spread over 5 days, so for some time slots I ended up sitting out. Which is not a bad thing, because Devoxx has an awesome hallway setup.

There were two rows of tables with power strips in the middle. As we all know, developers swarm towards sockets to charge our gadgets, so this is like the well in the village square, where people gather and socialize. On top of that there was no special speaker preparation room, so everyone hang out here, igniting many interesting conversations. This is a brillant setup that every conference should copy!

Off-season Google I/O

As an Android developer, this tweet sums it up pretty well:

Great sessions, great people, great venue. Yes, it's far away, but I took advantage of that to enjoy some Belgian chocolate and beer. All in all, I'd love to speak at Devoxx again!

Tuesday, November 6, 2012

Droidcon Bucharest

After Droidcon London, I headed to Romania to speak at Droidcon Bucharest.

Droidcon Bucharest has a very strong community feel to it. There were about 80 people attending, and each of us introduced ourselves. It started in English, but then people slipped into Romanian. I could guess who were the students since the word in Romanian was really close to English, but it was great when they switched back to English.

From the introductions I gathered that Android is up and coming here in Romania, since there were quite a few student attendees. Around half of the audience said they have never done Android programming. I suppose they would be going to the 3-hour basic Android training in the afternoon.

Barcamp

Just like Droidcon London, we had Barcamp on the first day. I was a bit shocked when I saw the schedule.

15-minute per session? You need to run them with an iron fist to make sure everybody starts and ends on time. Turns out the schedule was merely a guideline. People talked for as long as they wanted, and the audience could asked as many questions as they had. And that's how a barcamp should be - it's over when it's over, no need to be fixated on the timing. I was just amused that they bothered printing time slots in the schedule when they had no plan to follow it.

Conference

Second day is conference day. I was the first speaker, and as usual I polled the audience before I started. Here only a few people made a custom view before, so I spent a lot of time covering the basics.

I noticed that Europeans are not as eager to shout from the audience when I ask questions, but I still wanted some participation, so I was throwing questions at them left and right. By the end they warmed up a bit, and I got a few people to answer loud and clear rather than mumble noncommittally. That made me happy, because it showed me that people are learning.

There was quite a variety of talks at the conference. I really enjoyed the UI makeover by Eugen Arbuleac and Andrei Catinean.

Roman Mazur gave an excellent talk on Android REST best practices. I will definitely be studying his open source project to learn a trick or two.

Regional event

At the end of Droidcon Bucharest the organizers gathered people from different cities to discuss how to foster the Android community in the region. There seems to be a lot of interests from students, and with some professional developers scattered here and there. With events like Droidcon bringing people together, I am sure the Eastern European Android community will flourish.

Here is a picture of me with some awesome Android ladies from Timişoara. It was great fun hanging out with them!

More Droidcon Bucharest coverage

Sunday, November 4, 2012

Droidcon London

The first stop of my European speaking tour is Droidcon London.

I absolutely loved the conference icons with the droid at London landmarks, and was very happy to see them adorning the venue.

Barcamp

The first day was Barcamp. I was astonished by the number of people that got on stage to propose a session. What was more amazing was that there were all super high quality. My experience at unconferences was that people come up with ideas on the spot, gather interested parties and hold an informal discussion. But at Droidcon London, people gave well-prepared, full-length presentations.

For instance I heard about RoboSpice, a library for asynchronous network requests. Stéphane brought a complete deck, pretty much treating it as a proper conference talk. I was impressed.

Conference

Second day was conference day, and once again it was jam-packed with great talks. There is a lot of tribal knowledge in Android, and at Droidcon London I felt that I was among the village elders, telling us creation myths and war stories.


SoundCloud jumped through lots of hoops to make streaming work

At my talk I shared my experience using custom components in Monkey Write. It was a mash-up from my Fluid Android Layouts and Android Custom Components talk, and I was very proud that I managed to trim the 1 hour and 45 minutes of material down to 45 minutes. Imagine my surprise when I got an email from the organizers a few days before the conference, informing us that our talks should be 35 minutes long. I stared at my presentation, unable to chop off any more slides, so I decided to go with the full deck.


Giving my talk. Photo credit: Alexandre Gherschon

At the beginning of my talk I polled the audience for their experience in custom components. As I expected most of them had written one already, allowing me to jump over the basics and went straight for the deep dive. I finished on time, and people came to me afterwards thanking me for sharing the advanced material. Yay!

Awesome people

As always my favorite part of conferences is meeting awesome people, and Droidcon London definitely delivered on that front. Most the attendees I met care deeply about perfecting their craft, and we had many interesting technical discussions in the hallway. I got to hang out with quite a few speakers as well. It was like going to Hollywood and casually chatting with celebrities. Totally awesome.

Droidcon London has a great vibe, and I attribute it to the enthusiastic organizers. The amazing lineup attracted developers from all over Europe, and it was rather magical to hang out with so many awesome people. Thank you very much for such a great conference!


Droidcon London organizers