Defining package name regarding buildType in cordova android project

前提是你 提交于 2019-12-31 04:11:12

问题


How can I define the right package name regarding my buildType ? I have this command line to build : cordova run android --device --buildType=beta

I have this hook (after prepare) which set the buildType from the command line :

fs.appendFileSync( buildExtras, "ext.postBuildExtras = {\nandroid.buildTypes." +
      ( isRelease ? "release" : "debug" ) + ".applicationIdSuffix='." + buildType + "'\n}" );

but in AndroidManifest.xml packageName in platforms/android/ is not the right.

Only if I change manually in the config.xml file widget id="com.exemple.beta" then the AndroidManifest.xml package name is correct


回答1:


Create a build-extras.gradle file under platforms/android/ with the following content:

android {
  buildTypes {
    debug {
      applicationIdSuffix ".debug"
    }
    release {
      applicationIdSuffix ".release"
    }
  }
}

I also started to read cordova 5 documentation at first, but since I am using cordova 6 I guess it doesn't work like in their documentation anymore (and I couldn't find the same page in the latest documentation).

Edit 1: Doing this will not launch the app automatically when doing cordova run android anymore, so you will have to launch it manually using adb shell am start -n com.application.debug/com.application.MainActivity



来源:https://stackoverflow.com/questions/38248344/defining-package-name-regarding-buildtype-in-cordova-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!