I'm trying to have same activity
name in different flavors, and install the right one for each flavor.
build.gradle :
android {
....
buildscript {
productFlavors {
flavor1 {
applicationId "com.example.MyApp.flavor1"
}
flavor2 {
applicationId "com.example.MyApp.flavor2"
}
flavor3 {
applicationId "com.example.MyApp.flavor3"
}
}
}
}
AndroidMAnifest.xml :
<activity
android:name="${applicationId}.LaunchActivity"
android:noHistory="false" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*"
android:path="*"
android:scheme="@string/app_scheme_name" />
</intent-filter>
...
<\activity>
and every flavorX.java looks like this :
package com.example.MyApp.flavorX;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.example.MyApp.MainActivity;
public class LaunchActivity extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
String flavor = "~~~ flavorX ~~~~";
Log.i("flavor", flavor);
super.onCreate(savedInstanceState);
Toast.makeText(this, flavor,Toast.LENGTH_SHORT).show();
}
}
now...
for every flavor i run (with its build variant
) by pressing the A.S. "green play button" these things happens:
1. build + compile ends successfully.
2. on the Run
view tab i get this message :
Installing com.example.MyApp.flavorX
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.MyApp.flavorX"
pkg: /data/local/tmp/com.example.MyApp.flavorX
Success
Could not identify launch activity: Default Activity not found
3. the app is being installed on the device with the correct icon and name.
4. when pressing the icon that was just installed (=running from device) - everything is OK and the app acts just as requested - with it own flavor for each installation.
this is awful for debugging and fluent developing...
what should i do in order to be able to run each flavor with its variants through A.S??
thanks :)