0

Ich habe eine Anwendung, die vollständig entwickelt ist. Jetzt muss ich in mipmap Ordner nur gleiche Anwendung mit minimalen Änderungen erstellen und strings.xmlProductFlavours mit nur Ressourcenwechsel

Ich habe Artikel Flavors in build.gradle erstellt als

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:[email protected]' 
     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:[email protected]' 
     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:[email protected]') { 
     transitive = true 
    } 
    compile 'com.github.d-max:spots-dialog:[email protected]' 
    compile files('libs/aws-android-sdk-1.0.4-debug.jar') 
} 

und modifizierte meine Ordnerstruktur als

Project 
--/app 
    --/src 
    --/flavour1 
     --/res 
     --strings.xml 
    --/flavour2 
     --/res 
     --strings.xml 
    --/main 
     --/java 
     --/res 
     --/AndroidManifest.xml 

und dann bekomme ich 2 Fehler

EDIT:

Geänderte Ordnerstruktur wie unten als

Project 
--/app 
    --/src 
    --/flavour1 
     --/res 
     --/values 
      --strings.xml 
    --/flavour2 
     --/res 
     --/values    
      --strings.xml 
    --/main 
     --/java 
     --/res 
     --/AndroidManifest.xml 
+0

"public static final String PAID_DETAILS = "p ändern müssen, verwenden";" - Wo ist das vorhanden? – takrishna

+0

in einer meiner Klassen, es funktionierte gut, wenn es keine Productflavours gab –

Antwort

2

Das Problem ist hier erwartet zu funktionieren:

buildConfigField "String", "CITY_ID", "1" 

Es wird in Ihrem BuildConfig erstellen:

public static final String CITY_ID = 1; 

und es ist ein n Fehler.

Sie haben

buildConfigField "String", "CITY_ID", "\"1\"" 

Auf die gleiche Weise Sie buildConfigField "String", "CITY_ID", "2"

+0

Es war eine große Freude, eine Antwort von Ihrem Herrn Gabriele Mariotti zu erhalten. Du hast mein Problem gelöst, aber meine Strings werden nicht vom jeweiligen Geschmack ausgewählt. Was ist falsch an der Art, wie ich sie erstellt habe? –

+0

sry mein Schlechter !!!!! hab das behoben ... benutzte strings.xml im Ordner res. änderte es in Res-Werte-Strings und es hat gut funktioniert. –