Obsolete
Status Update
Comments
te...@gmail.com <te...@gmail.com> #2
Information redacted by Android Beta Feedback.
te...@gmail.com <te...@gmail.com> #3
Thank you for reporting this issue. For us to further investigate this issue, please provide the following additional information:
Screen record of the issue, for clarity Please capture screen record or video of the issue using following steps: adb shell screenrecord /sdcard/video.mp4 Subsequently use following command to pull the recorded file: adb pull /sdcard/video.mp4
Note: Please upload the files to google drive and share the folder to
Description
When I compile a debug build, before Proguard is run, BuildConfig.BUILD_TYPE is set to "release". After Proguard has completed, the BuildConfig file is regenerated so that the BuildConfig.BUILD_TYPE variable is updated to reflect the real type of build "debug". I have confirmed this issue by building a debug build and then decompiling the apk.
This is the my test code within the application:
Log.i(TAG, "Build Type: " + BuildConfig.BUILD_TYPE.equals("debug") + "('" + BuildConfig.BUILD_TYPE + "')");
The same line from the decompiled apk looks like:
Log.i(TAG, "Build Type: " + "release".equals("debug") + "('" + "release" + "')");
However, BuildConfig.java from the decompiled apk shows that it is a debug build type.
public static final String BUILD_TYPE = "debug";
My guess is that Gradle is initializing the BuildConfig file with default values. Proguard runs and then the BuildConfig file is regenerated. This causes problems with any variable defined in BuildConfig because Proguard will optimize any code that references the BuildConfig file using the default values.
The BuildConfig file needs to have the proper values set before Proguard is run, so that optimizations don't cause unexpected behavior when the application is run.
I'm using
Android Studio 1.3.1
Build #AI-141.2135290, built on August 3, 2015
JRE: 1.6.0_65-b14-466.1-11M4716 x86_64
JVM: Java HotSpot(TM) 64-Bit Server VM by Apple Inc.
OS: OSX version 10.10.2
Gradle Version: 2.2.1
Android Plugin Version: 1.2.3
Android SDK Tools: 24.3.3
Module Compile Sdk Version: API 22: Android 5.1 (Lollipop)
Module Build Tools Version: 22.0.1