Use different VersionCode for Debug/Release android gradle build

前端 未结 6 1678
感动是毒
感动是毒 2020-12-15 07:30

I\'d like to apply different VersionCode to make apk file. For debug only fix it to 1, and for release whatever number specified in defaultConf

6条回答
  •  佛祖请我去吃肉
    2020-12-15 07:45

    Me too, but I think defaultConfig.versionCode was set when build.gradle be compiling. It's global static variable, and assigned at compiletime, not runtime.

    I think we can intercept gradle task execution, and modify defaultConfig.versionCode at runtime.


    After goooooooogle, I found this one works for me: https://gist.github.com/keyboardsurfer/a6a5bcf2b62f9aa41ae2

提交回复
热议问题