简体   繁体   中英

Android studio and flavours - can not see all files

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM