how do build a apk in AOSP

4,169 views
Skip to first unread message

allstars

unread,
Nov 15, 2011, 4:43:52 AM11/15/11
to Android Building
Hi
I download the Icecream AOSP
and now try to build my apk

but I found the built APK won't include classes.dex
and there's another APK.odex separated from apk

for example

source build/envsetup.sh
lunch full-eng
make HelloActivity

it will generate
Install: out/target/product/generic/system/app/HelloActivity.odex
Install: out/target/product/generic/system/app/HelloActivity.apk

and the HelloActivity.apk doesn't include classes.dex

What should I do to make it as usual before??


thanks

CultOf Droid

unread,
Nov 15, 2011, 3:23:12 PM11/15/11
to Android Building
I'm having the exact same problem.

Here is my question thread:
http://groups.google.com/group/android-building/browse_thread/thread/5515ef0a15a6b724/126a46b7286ab73a?hl=en#126a46b7286ab73a

I've made a little progress, by basically snooping around in the out
directory.

I found $HOME/WORKING_DIRECTORY/out/target/product/generic/obj/APPS
directory which contains all the intermediate build stages. If you
navigate to the app you're interested in, you'll find:

1> package.apk.unaligned
2> package.apk.unsigned
3> package.odex
4> package.apk

If you observe the timestamps on these files, you'll notice that my
list is in the order that they were created. It seems to me like 1 and
2 get created first, and then the build scripts scrape out the
classes.dex file, and separate out the app into a .odex and .apk file :
(

SO, we have 2 options:

1> Manually sign, and zipalign wither of files package.apk.unaligned
and package.apk.unsigned
2> Change the build configuration to let the system do it for us.

All help is appreciated.

Magnus Bäck

unread,
Nov 15, 2011, 3:41:49 PM11/15/11
to Android Building
On Tuesday, November 15, 2011 at 10:43 CET,
allstars <allsta...@gmail.com> wrote:

Why is this a problem for you? Anyone, you can set DISABLE_DEXPREOPT to
true to disable this behavior. In pre-ICS, Dex pre-optimization was only
enabled for certain types of builds, but now it appears to be generally
enabled for all builds on Linux hosts. See the recent thread on this
list at http://goo.gl/amKTo.

--
Magnus B�ck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

Ying Wang

unread,
Nov 15, 2011, 5:54:46 PM11/15/11
to android-...@googlegroups.com
On Tue, Nov 15, 2011 at 12:41 PM, Magnus Bäck <magnu...@sonyericsson.com> wrote:
On Tuesday, November 15, 2011 at 10:43 CET,
    allstars <allsta...@gmail.com> wrote:

> I download the Icecream  AOSP
> and now try to build my apk
>
> but I found the built APK won't include classes.dex
> and there's another APK.odex separated from apk
>
> for example
>
> source build/envsetup.sh
> lunch full-eng
> make HelloActivity
>
> it will generate
> Install: out/target/product/generic/system/app/HelloActivity.odex
> Install: out/target/product/generic/system/app/HelloActivity.apk
>
> and the HelloActivity.apk doesn't include classes.dex
>
> What should I do to make it as usual before??

Why is this a problem for you? Anyone, you can set DISABLE_DEXPREOPT to
true to disable this behavior. In pre-ICS, Dex pre-optimization was only
enabled for certain types of builds, but now it appears to be generally
enabled for all builds on Linux hosts. See the recent thread on this
list at http://goo.gl/amKTo.

From ics on, dex pre-optimization has been enabled for the generic device (which the emulator build target "full" is based on), 
see build/target/board/generic/BoardConfig.mk.
The purpose is to speed up the emulator bootup.
To disable dex preopt, set DISABLE_DEXPREOPT to false on your build command:
$ make -j DISABLE_DEXPREOPT=false

For other build configuration things didn't change:
If you are building a "user" (instead of "userdebug" or "eng") on Linux, dex preopt will be enabled.

 
--
Magnus Bäck                   Opinions are my own and do not necessarily

SW Configuration Manager      represent the ones of my employer, etc.
Sony Ericsson

--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

allstars

unread,
Nov 15, 2011, 10:21:01 PM11/15/11
to Android Building
thanks for your tips

I also found that I can add
LOCAL_DEX_PREOPT := false
in my Android.mk
then for my apk I dont have to type extra DISABLE_DEXPREOPT=false

thanks

On Nov 16, 6:54 am, Ying Wang <wangy...@android.com> wrote:
> On Tue, Nov 15, 2011 at 12:41 PM, Magnus Bäck
> <magnus.b...@sonyericsson.com>wrote:
>
>
>
>
>
>
>
>
>
> > On Tuesday, November 15, 2011 at 10:43 CET,
> >      allstars <allstars....@gmail.com> wrote:
>
> > > I download the Icecream  AOSP
> > > and now try to build my apk
>
> > > but I found the built APK won't include classes.dex
> > > and there's another APK.odex separated from apk
>
> > > for example
>
> > > source build/envsetup.sh
> > > lunch full-eng
> > > make HelloActivity
>
> > > it will generate
> > > Install: out/target/product/generic/system/app/HelloActivity.odex
> > > Install: out/target/product/generic/system/app/HelloActivity.apk
>
> > > and the HelloActivity.apk doesn't include classes.dex
>
> > > What should I do to make it as usual before??
>
> > Why is this a problem for you? Anyone, you can set DISABLE_DEXPREOPT to
> > true to disable this behavior. In pre-ICS, Dex pre-optimization was only
> > enabled for certain types of builds, but now it appears to be generally
> > enabled for all builds on Linux hosts. See the recent thread on this
> > list athttp://goo.gl/amKTo.
Reply all
Reply to author
Forward
0 new messages