1

I am trying to set up flavours, so I can build different apps in he same project that share the same code... But I am not sure I am doing it fully correct...

I have created a project called com.sharedid.app in folder W:\android-studio-projects\sharedid\

For this I have

1) Created AndroidManifest.xml in W:\android-studio-projects\sharedid\app\src\main looking like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.sharedid.app"
  android:versionCode="1"
  android:versionName="1.0"
>
</manifest>

2) In W:\android-studio-projects\sharedid\app\src\main\java ... I have all .java files

3) In W:\android-studio-projects\sharedid\app\src\main\res I have all shared and/or dummy resources

For my flavour I have:

1) I have created AndroidManifest.xml in W:\android-studio-projects\sharedid\app\src\myflavour (this file is what defines everything - it is unqiue for each flavour)

2) In W:\android-studio-projects\sharedid\app\src\myflavour\res I have a single folder drawable-hdpi conttaining variois graphics

3) In W:\android-studio-projects\sharedid\app\src\myflavour\assets I have all sorts of data, configuration and graphic files for that specifc app. (read by the code at runtime)

Here's how "Gradle Scripts" - "Build Gradle" (Module: app) looks like:

apply plugin: 'com.android.application'

android {
    signingConfigs {
    }
    compileSdkVersion 21
    buildToolsVersion '21.1.2'
    defaultConfig {
        applicationId "com.sharedid.app"
        minSdkVersion 9
        targetSdkVersion 17
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
    repositories {
        maven { url "https://jitpack.io" }
    }     
    productFlavors {
      myflavour {
          applicationId "com.myflavour.app"
      }
    }           
}    
dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:21.1.2'
    compile 'com.github.PhilJay:MPAndroidChart:v2.0.8'
}

My problem is that when working in Android Studio, it currently does not show my any of the "myflavour" in the "project view" listing the files structure of the project?

Tom
  • 3,587
  • 9
  • 69
  • 124
  • 1
    Which view are you in? Android or Project? If you are in Android view, switch to Project view. – Shubham A. Nov 17 '15 at 03:57
  • That solved that issue... I can move on now - thanks! :) – Tom Nov 17 '15 at 13:03
  • Don't forget to accept the answer below. Glad to help :) – Shubham A. Nov 17 '15 at 13:33
  • Done! Thanks again for your help. It allowed me to move on to my next problem - probably a more complex one. But if flavours actually work it will be a major step up from my old Eclipse projects where i never got anything like that working :) – Tom Nov 17 '15 at 13:42
  • If you happen to have experience with flavours here's the new questions about getting google to merge/pick the correct manifest file or the selected variation: https://stackoverflow.com/questions/33758412/android-studio-and-flavours-but-getting-error-that-main-acivity-can-not-be-fou – Tom Nov 18 '15 at 01:53
  • anyone wanna demo for android studio flavor http://code2concept.blogspot.in/2015/12/android-studio-flavors-demo.html – Nitesh Tiwari Jan 23 '16 at 06:49

1 Answers1

2

Which view are you in? Android or Project? If you are in Android view, switch to Project view.

Shubham A.
  • 2,446
  • 4
  • 36
  • 68