Step 1. Create Android Studio Project
Step 2. Go to the build.gradle file in the app module then add Flavours in that file
productFlavors { demo { applicationIdSuffix ".demo" resValue "string", "app_name", "Demo App" } full { applicationIdSuffix ".full" resValue "string", "app_name", "Full App" } }after changes sync gradle ,their will be option Build Variants their we can switch demo / full application buildFull Source code of build.gradleapply plugin: 'com.android.application' android { compileSdkVersion 25buildToolsVersion "25.0.2" defaultConfig { // applicationId "com.example.nithin.flavoursample"// minSdkVersion 14// targetSdkVersion 25// versionCode 1// versionName "1.0"// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}buildTypes { release { minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'} } productFlavors { demo { applicationIdSuffix ".demo" resValue "string", "app_name", "Demo App" } full { applicationIdSuffix ".full" resValue "string", "app_name", "Full App" } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.1.0'compile 'com.android.support:design:25.1.0'testCompile 'junit:junit:4.12'}
Step 3. Create folders (demo/full) under src
before adding files change build variants option
full application (build variant - fullDebug)
Manifest
Manifest file (main)
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.nithin.flavoursample"> </manifest>
Manifest file (demo)
<manifest xmlns:android="http://schemas.android.com/apk/res/android" > <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.example.nithin.flavoursample.demo.Login"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Manifest file (full)
<manifest xmlns:android="http://schemas.android.com/apk/res/android" > <applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:supportsRtl="true"android:theme="@style/AppTheme"><activityandroid:name="com.example.nithin.flavoursample.full.Login"android:label="@string/app_name"android:theme="@style/AppTheme.NoActionBar"><intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>Login PageLogin Page (demo)package com.example.nithin.flavoursample.demo;public class Login extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); } }
Login Page (full)
package com.example.nithin.flavoursample.full; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import com.example.nithin.flavoursample.R; /** * Created by nithin on 1/11/2017. */ public class Login extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); } }
Comments
Post a Comment