4

I have been using IDEA 13.1 and created a Gradle project with it. When I compile the app and start it, it creates only the unaligned APK.

Opening the same project with Android Studio, and rebuilding it and starting the app, generates both unaligned and regular unsigned APK.

Is this a bug in IntelliJ IDEA? If not, where can I set that it always generates a regular, aligned, APK?

sandalone
  • 41,141
  • 63
  • 222
  • 338

1 Answers1

0

The alignment/output does not depend on the IDE but on your gradle config. Both IntelliJ and AndroidStudio just run Gradle in background.

By default, the autogenerated Gradle file build.gradle does not run the zipAlign task, i.e. the one aligning the apk. So you end up with an unaligned apk.

You can easily change it by adding the zipAlignEnabled true property, like this:

    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        zipAlignEnabled true
    }

But let me remind you that archive alignment is just an optimization, it does not change your app.

Also, from the docs:

Caution: zipalign must only be performed after the .apk file has been signed with your private key. If you perform zipalign before signing, then the signing procedure will undo the alignment.

For further information, please have a look at this thread, this thread and the docs.

Community
  • 1
  • 1
Derlin
  • 9,572
  • 2
  • 32
  • 53