如何在一台设备上安装不同版本的安卓应用

第一步:

1. Create the variant dependent strings in your build script

Edit your build.gradle file accordingly:

 //This line allows parameterization via the terminal and the Gradle VM Options
def debugsuffix = System.
        getProperty(‘debugsuffix‘, project.getProperties().get(‘debugsuffix‘, null))

def final yourApplicationId = ‘your.application.id‘

android {
  //In the defaultConfig and all your product flavors create build dynamic variables

  defaultConfig {
      applicationId = yourApplicationId

    //These are the values for the authorities and account types.
    //Reference them in the java files with e.g. BuildConfig.ACCOUNT_TYPE.

      buildConfigField "String", "ACCOUNT_TYPE", "\"${applicationId}.account\""
      buildConfigField "String", "AUTHORITY", "\"${applicationId}.provider\""

    //Reference them in .xml files.
      resValue "string", "account_type", "${applicationId}.account"
      resValue "string", "authority", "${applicationId}.provider"
    }
  productFlavors {
    dev {
      applicationId = yourApplicationId + ".dev" + debugsuffix

    //Reference them again so they get overwritten by the flavor.

      buildConfigField "String", "ACCOUNT_TYPE", "\"${applicationId}.account\""
      buildConfigField "String", "AUTHORITY", "\"${applicationId}.provider\""

      resValue "string", "account_type", "${applicationId}.account"
      resValue "string", "authority", "${applicationId}.provider"
    }
  }
}

  

第二部:

2. Refer to them in your Android Manifest

Replace the permissions and provider authorities in yourAndroidManifest.xml with ${applicationId}:

<permission android:name="${applicationId}.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.MAPS_RECEIVE" />

<provider   android:name=".your.provider"
            android:authorities="${applicationId}.your.provider"
            … />

  

第三步:

3. Refactor your Java source files with the build specific strings

Update every occurrence of static strings for authorities and account types in your source files.

public static final String AUTHORITY = BuildConfig.AUTHORITY;
public static final String AUCCOUNT_TYPE = BuildConfig.ACCOUNT_TYPE;

  

第四步:

添加xml文件

4. Refactor your SyncAdapter resources

Use the resValue in the syncadapter.xml in res/xml:

<sync-adapter android:contentAuthority="@string/authority"
              android:accountType="@string/account_type"
           … />

  

Another nice way to use this is utilising the the Jenkins build number as a suffix.

Et voilà, you can now build and install different app versions on a single device. Just make sure to do some heavy testing, as some static strings hide themselves and can break something. During research it turned out that using the pre-build variable applicationIdSuffix does not work properly, as the application ID gets changed after the buildFlavor. Another important thing to mention is that you have to sync the project with gradle files after you changed the Gradle VM options.

From:

https://blog.grandcentrix.net/how-to-install-different-app-variants-on-one-android-device/

时间: 2024-08-01 01:20:15

如何在一台设备上安装不同版本的安卓应用的相关文章

关于同一台机器上安装多个sql实例的连接方法

由于客户需要在一台服务器上安装了两个sql服务器(一个sql2000,一个是sql2005,其实例名不同),默认的端口1433被先安装的sql2000使用,后来安装的的随机启用了一个3045端口.其中错误的过程就不说了,只说结果吧: 首先进行了将服务器上的配置修改: 1.在"外围配置"工具把"允许TCP/IP和命名管道"勾上: 2.设定一个你允许使用的端口号: 3.在防火墙中将你设定的TCP端口号添加到例外中: 最后将连接字符串改成: Data Source=服务器

如何在一台服务器上安装两个mysql或者更多

如何在一台服务器上安装两个mysql 1       前言 上篇写了在一台机器上源码编译安装一个mysql,那么如何在一台机器上源码编译安装两个mysql或者更多呢? 2       环境 mysql软件包: mysql-5.6.31.tar mysql-5.5.32.tar 操作系统环境: CentOS release 6.8 (Final) 3       系统规模 /mysqlsoft 用来存放mysql的各个程序 /mysqlsoft/mysql1 用来存放mysql-5.5.32.ta

[转]如何:在设备上安装 SQL Server Compact 3.5

将设备连接到计算机,或者将仿真程序插入底座. 有关更多信息,请参见如何:将设备仿真程序插入底座和移除底座. 说明: 计算机上必须已安装了 Windows Mobile Device Center 或 Microsoft ActiveSync. 在桌面计算机上,启动 Windows 资源管理器,然后转至文件夹 驱动器:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Devices\wce400 或 wce500\CPU 体系结构类型

Android问题-新电脑新系统WIN764位上安装简版本的XE8提示“Unit not found: &#39;System&#39;”

问题现象:电脑太慢,重安新系统,所以要安DELPHIXE8,但安装过程中出现二次杀软件提示,我都选的是通过.但是XE8过程到最后的"Create AVD"时出现一个错误(具体是什么,我没注意看,好像是说什么东东建立时失败了).之后用安装好的XE8生成EXE没有问题,生成android程序就不行了.提示"[DCC Fatal Error] Project1.dpr(1): F1027 Unit not found: 'System' or binary equivalents

如何在Ubuntu上安装最新版本的Node.js

如何在Ubuntu上安装最新版本的Node.js 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs Node.js是一个软件平台,通常用于构建大规模的服务器端应用.Node.js使用JavaScript作为其脚本语言,由于其非阻塞I/O设计以及单线程事件循环机制,使得它可以交付超高的性能. Node.js包含了Google V8 JavaScript引擎,libuv库和核心库几乎都是使用JavaScript编写的.libuv库提供了异步事件I/O的抽象

Vmware vSphere 6.0之在一台服务器上安装Platform与vCenter Server

简介: vCenter Server 为数据中心提供单一控制点.它提供基本的数据中心服务,如访问控制.性能监控以及配置.它将各台计算服务器的资源统一在一起,使这些资源在整个数据中心中的虚拟机之间共享.其原理是:根据系统管理员设置的策略,管理虚拟机到计算服务器的分配,以及资源到给定计算服务器内虚拟机的分配. 在 vCenter Server 无法访问(例如,网络断开)的情况下(这种情况极少出现),计算服务器仍能继续工作.服务器可单独管理,并根据上次设置的资源分配继续运行分配给它们的虚拟机.恢复与

iOS 5.1.1 设备无法安装AdHoc版本的问题

苹果之前更新了审核规范,要求必须支持64位架构的应用才能通过苹果审核. 但运营方反馈说,用iOS5.1.1的系统无法安装我们打包的Adhoc版本. 觉得很莫名,因为我们在Deployment Target上确实写着5.1.1,全公司也都没人用这个系统了. 在运营纠结这个问题的时候,我去查了下资料,貌似确实是这样.iOS5.1.1是无法安装支持64位架构的AdHoc版本的.其实影响不大,因为只是AdHoc版本无法安装而已,正式发布签名的包经过AppStore发布后是可以在用户的iOS5.1.1系统

centos7在单台服务器上安装FastDFS的方法

准备环境: #安装依赖包 yum -y install gcc gcc-c++ libtool pcre* zlib openssl openssl-devel mkdir /FastDFS/ #上传下载工具 yum -y install lrzsz yum -y install unzip cd /FastDFS/ 上传fastdfs-dep.zip rz #安装libfastcommon cd /FastDFS/ unzip fastdfs-dep.zip cd /FastDFS/fastd

如何在未越狱iOS设备上安装IPA

转载自:http://blog.163.com/l1_jun/blog/static/1438638820133505210779/ 2013-04-05 12:52:10|  分类: Apple|字号 订阅 Ad-Hoc 是苹果公司是为应用发布提供的一种发布前测试方法,所要安装的设备无需越狱.  其用途在于:如果你开发了一款App, 想在发布之前,让周围人帮忙测试一下. 这时,你需要得到测试人的设备的 UDID,  生成一个 Ad-Hoc 应用,并将该应用和对应的 mobileProvisio