Android Studio 2.2, which was first previewed at Google I/O 2016 and later released in September, is packed with new developer enhancements and changes under the hood of the Android Gradle plug-in. The Android Developer team released a few tips and details this week to make sure developers fully understand these changes so they can use the latest release of the IDE.
According to Android developer advocate Wojtek Kalicinski in a developer blog post, Android Studio 2.2 comes with a rewritten integrated APK packaging and signing step, which works in the Android Gradle plug-in.
The reason for the changes to how Android verifies APKs is so there is enhanced security and extensibility of the new signing format, wrote Kalicinski, and so developers have performance enhancements. With the new signature, it takes less time to verify over the binary contents of the whole APK file, “as opposed to decompressed file contents of each file in the archive in version one,” he wrote.
Developers should understand that with this new signing format, there are now constraints on the APK creation process. Compression, aligning and signing is now a single and integrated step in the build process, and “running zipalign is no longer possible after signing,” wrote Kalicinski.
There’s also a new tool in the Android SDK called apksigner for developers that want to do signing and aligning manually. Developers who want to “disable adding v1 or v2 signatures when building with the Android Gradle plug-in can add lines of code to the signingConfig section in build.gradle,” wrote Kalicinski.
Developers will also notice changes to the size of release APKs, like how files in the archive are now sorted to minimize the differences between APK builds. All file timestamps, as well as metadata, are zeroed out, and “native libraries are stored uncompressed and page-aligned in the APK,” wrote Kalicinski.
He also cautioned developers that “the APK files created for Instant Run or by invoking a debug build are not meant for distribution on the Play Store.
“They contain additional instrumentation code for Instant Run and are missing resources for device configurations other than the one that was connected when you started the build. Make sure you only distribute release versions of the APK, which you can create using the Android Studio Generate Signed APK command or the assembleRelease Gradle task.”
Developers can look at this video, which details the new Android layout editor, APK Analyzer, Firebase integration, and C/C++ improvements.