diff options
Diffstat (limited to 'docs/html/tools/building/configuring-gradle.jd')
-rw-r--r-- | docs/html/tools/building/configuring-gradle.jd | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/docs/html/tools/building/configuring-gradle.jd b/docs/html/tools/building/configuring-gradle.jd index 7cca5b4..73a048b 100644 --- a/docs/html/tools/building/configuring-gradle.jd +++ b/docs/html/tools/building/configuring-gradle.jd @@ -198,6 +198,75 @@ settings from the Android SDK installation. Android Studio adds the module-speci <code>proguard-rules.pro</code> at the root of the module, where you can add custom ProGuard rules.</p> + + +<h3>Application ID for package identification </h3> +<p>With the Android build system, the <em>applicationId</em> attribute is used to +uniquely identify application packages for publishing. The application ID is set in the +<em>android</em> section of the <code>build.gradle</code> file. +</p> + + <pre> + apply plugin: 'com.android.application' + + android { + compileSdkVersion 19 + buildToolsVersion "19.1" + + defaultConfig { + <strong>applicationId "com.example.my.app"</strong> + minSdkVersion 15 + targetSdkVersion 19 + versionCode 1 + versionName "1.0" + } + ... + </pre> + +<p class="note"><strong>Note:</strong> The <em>applicationId</em> is specified only in your +{@code build.gradle} file, and not in the AndroidManifest.xml file.</p> + +<p>When using build variants, the build system enables you to uniquely identify different +packages for each product flavors and build types. The application ID in the build type is added as +a suffix to those specified for the product flavors. </p> + + <pre> + productFlavors { + pro { + applicationId = "com.example.my.pkg.pro" + } + free { + applicationId = "com.example.my.pkg.free" + } + } + + buildTypes { + debug { + applicationIdSuffix ".debug" + } + } + .... + </pre> + +<p>The package name must still be specified in the manifest file. It is used in your source code +to refer to your R class and to resolve any relative activity/service registrations. </p> + + <pre> + <?xml version="1.0" encoding="utf-8"?> + <manifest xmlns:android="http://schemas.android.com/apk/res/android" + <strong>package="com.example.app"</strong>> + </pre> + +<p class="note"><strong>Note:</strong> If you have multiple manifests (for example, a product +flavor specific manifest and a build type manifest), the package name is optional in those manifests. +If it is specified in those manifests, the package name must be identical to the package name +specified in the manifest in the <code>src/main/</code> folder. </p> + +<p>For more information about the build files and process, see +<a href="{@docRoot}sdk/installing/studio-build.html">Build System Overview</a>.</p> + + + <h3 id="configureSigning">Configure signing settings</h3> <p>The debug and the release versions of the app differ on whether the application can be |