在Cordova Android项目中定义关于buildType的包名称 [英] Defining package name regarding buildType in cordova android project

查看:162
本文介绍了在Cordova Android项目中定义关于buildType的包名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为我的buildType定义正确的软件包名称? 我有此命令行来构建: cordova run android --device --buildType=beta

我有这个钩子(准备之后),可以从命令行设置buildType:

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

但是在platform/android/中的AndroidManifest.xml packageName中是不正确的.

仅当我在config.xml文件中手动更改时 widget id="com.exemple.beta",则AndroidManifest.xml程序包名称正确

解决方案

platforms/android/下创建具有以下内容的build-extras.gradle文件:

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

我也开始阅读 cordova 5文档起初,但是由于我使用的是cordova 6,我想它不再像他们的文档那样工作了(而且我在最新文档中找不到相同的页面).

这样做将不会再执行cordova run android时自动启动该应用程序,因此您将不得不使用adb shell am start -n com.application.debug/com.application.MainActivity

手动启动它.

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

解决方案

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

这篇关于在Cordova Android项目中定义关于buildType的包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆