Reputation: 2258
I have an application which is completely developed.
Now I have to create same application with minimal changes only in mipmap
folders and strings.xml
I have created Product Flavours in build.gradle as
apply plugin: 'com.android.application'
apply plugin: 'sonar'
apply plugin: 'sonar-runner'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "16.1.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
productFlavors {
flavour1 {
buildConfigField "String", "BASE_SERVER_URL", '"http://flavour1.com"'
buildConfigField "String", "CITY_ID", "1"
}
flavour2 {
buildConfigField "String", "BASE_SERVER_URL", '"http://flavour2.com"'
buildConfigField "String", "CITY_ID", "2"
}
}
}
repositories {
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.eftimoff:androidplayer:1.0.3@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.google.code.gson:gson:2.4'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'se.emilsjolander:stickylistheaders:2.5.2'
compile('org.simpleframework:simple-xml:2.7') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile files('libs/xmlutils.jar')
compile 'cc.cloudist.acplibrary:library:1.2.1'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile files('libs/json-20140107.jar')
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-rc.1@aar') {
transitive = true
}
compile 'com.github.d-max:spots-dialog:0.4@aar'
compile files('libs/aws-android-sdk-1.0.4-debug.jar')
}
and modified my folder structure as
Project
--/app
--/src
--/flavour1
--/res
--strings.xml
--/flavour2
--/res
--strings.xml
--/main
--/java
--/res
--/AndroidManifest.xml
and then I'm getting 2 errors
`1`
`error: incompatible types: int cannot be converted to String
public static final String PAID_DETAILS = "p";
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.`
`2`
Execution failed for task ':app:compileflavour1DebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
EDIT:
Changed folder structure as below to work as expected
Project
--/app
--/src
--/flavour1
--/res
--/values
--strings.xml
--/flavour2
--/res
--/values
--strings.xml
--/main
--/java
--/res
--/AndroidManifest.xml
Upvotes: 0
Views: 234
Reputation: 363825
The issue is here:
buildConfigField "String", "CITY_ID", "1"
It will create in your BuildConfig
:
public static final String CITY_ID = 1;
and it is an error.
You have to use
buildConfigField "String", "CITY_ID", "\"1\""
At the same way you have to change buildConfigField "String", "CITY_ID", "2"
Upvotes: 2