EDIT#3--changing directory structures since advised wrong.
Based on this link I followed from a SO question, I need my file structure to appear like this in Android Studio (AS) 1.1.0 in order to get both a free and for-pay version of my GPS (Google Play Store) app:
+-- main
¦ +-- AndroidManifest.xml
¦ +-- java
¦ ¦ +-- com
¦ ¦ +-- whatever
¦ ¦ +-- kakurocombos
¦ ¦ +-- MyActivity.java
¦ +-- res
¦ +-- layout
¦ ¦ +-- activity_main.xml
+-- FreeVersion
¦ +-- java
¦ +-- com
¦ +-- whatever
¦ +-- kakurocombos
¦ +-- Free.java (where FREE = true;)
+-- Pro
+-- java
¦ +-- com
¦ +-- whatever
¦ +-- kakurocombos
¦ +-- Free.java (where FREE = false;)
+-- res
+-- values
+-- string.xml
EDIT--
All of the above structure must be under src
as pointed out below in comments.
I chose that structure because this is how that link (above) shows its structure:
├── main
│ ├── AndroidManifest.xml
│ ├── ic_launcher-web.png
│ ├── java
│ │ └── be
│ │ └── tamere
│ │ └── gradlebuildtypesexample
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ └── activity_main.xml
│ ├── menu
│ │ └── main.xml
│ ├── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── values-v11
│ │ └── styles.xml
│ └── values-v14
│ └── styles.xml
├── production
│ └── java
│ └── be
│ └── tamere
│ └── gradlebuildtypesexample
│ └── Constants.java
└── staging
├── java
│ └── be
│ └── tamere
│ └── gradlebuildtypesexample
│ └── Constants.java
└── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── drawable-xxhdpi
│ └── ic_launcher.png
└── values
└── string.xml
Note the absence of res
under production
because it will use res
under main
.
Note the presence of res
under staging
since it uses different resources since it's the 2nd APK/package.
Here's how the directory structure looks in Windows 7 Explorer:
Here's how it looks in AS: (EDITED!)(TWICE)
Here's build.gradle
:
apply plugin: 'com.android.application'
android
{
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig
{
applicationId "com.dslomer64.kakurocombosbuildvariants"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors
{
paid
{
applicationId "com.dslomer64.kakurocombos.paid"
}
free
{
applicationId "com.dslomer.kakurocombos.free"
}
}
}
dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
The link alluded to at beginning of post has a few errors, including failure to append .paid
to the first package in the productFlavors
block.
- The project 'KakuroCombosBuildVariants' may be using a version of Gradle that does not contain the method.
**Open Gradle wrapper file**
- The **build file may be missing a Gradle plugin.**
Apply Gradle plugin
See edited original questoin for gradle wrapper file. Also, missing plugin leads me nowhere.\
– DSlomer64 May 03 '15 at 02:04