How to install different versions of Android apps on a single device
Source: Internet
Author: User
<span id="Label3"></p><p><p>The first step:</p></p>1. Create the variant dependent strings in your build script<p><p>Edit your <strong>build.gradle</strong> file accordingly:</p></p><p><p></p></p><pre class="brush:objc;gutter:true;"> This line allows parameterization via the terminal and the Gradle VM optionsdef 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 Defau Ltconfig {applicationid = Yourapplicationid//these is 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}.provi Der "} productflavors {dev {applicationid = Yourapplicationid +". dev "+ debugsuffix//reference them a Gain 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", "a Uthority "," ${applicationid}.provider "}}}</pre><p><p> </p></p><p><p>Part Ii:</p></p><p><p></p></p>2. Refer to them in your Android Manifest<p><p>Replace the permissions and provider authorities in your<strong>androidmanifest.xml</strong> with <code>${applicationId}</code> :</p></p><p><p></p></p><pre class="brush:objc;gutter:true;"><pre class="brush:objc;gutter:true;"><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 "... /></pre></pre><p><p> </p></p><p><p></p></p><p><p>Step three:</p></p><p><p></p></p>3. Refactor your Java source files with the build specific strings<p><p>Update every occurrence of static strings for authorities and account types in your source Files.</p></p><p><p></p></p><p><p></p></p><pre class="brush:objc;gutter:true;"><pre class="brush:objc;gutter:true;">public static final String authority = buildconfig.authority; public static final String Auccount_type = buildconfig.account_type; </pre></pre><p><p> </p></p><p><p></p></p><p><p>Fourth Step:</p></p><p><p>Add an XML file</p></p><p><p></p></p>4. Refactor Your SyncAdapter resources<p><p>Use the <strong>resvalue</strong> in the <strong>syncadapter.xml</strong> in Res/xml:</p></p><p><p></p></p><pre class="brush:objc;gutter:true;"><pre class="brush:objc;gutter:true;"><sync-adapter android:contentauthority= "@string/authority" android:accounttype= "@string/account_type" .../></pre></pre><p><p> </p></p><p><p></p></p><p><p>Another nice-utilising, the "the" and "the" the Jenkins build number as a suffix.</p></p><p><p>Et voilà, You can now build and install the different app versions on a single device. Just Make sure to does some heavy testing, as some static strings hide themselves and can break something. During The It turned out of that using the pre-build variable does does work <code>applicationIdSuffix</code> properly, as the application ID gets C Hanged after the Buildflavor. Another important thing to mention are so you have to sync the project with Gradle files after you changed the Gradle VM Options.</p></p><p><p></p></p><p><p>From:</p></p><p><p>https://blog.grandcentrix.net/how-to-install-different-app-variants-on-one-android-device/</p></p><p><p>How to install different versions of Android apps on a single device</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service