0

I want to change value of app_name string and other string for paid version of our app,to change app name and widget name for paid version of our app. But it not works for me. Help me please,how i can correct modify string resource value of @string/app_name and other string for paid version of our app. Thanks everybody very much for any help.

    flavorDimensions 'orthodoxCalendar'
    productFlavors {
        orthodoxcalendarfree {
            dimension 'orthodoxCalendar'
            applicationId "oleksandr.kotyuk.orthodoxcalendarfree"
            versionCode defaultConfig.versionCode
            versionName defaultConfig.versionName
                    }
        orthodoxCalendarpaid {
            dimension 'orthodoxCalendar'
            applicationId "oleksandr.kotyuk.orthodoxcalendarpaid"
            versionCode defaultConfig.versionCode
            versionName defaultConfig.versionName
//we want write in app_name string value of app_name_paid string. All strings defined in strings.xml file in values folder. The same we do for other string
            resValue "string", "app_name", "@string/app_name_paid"
            resValue "string", "app_name_fz", "@string/app_name_paid_fz"
        }
    }
}
  • Please read: [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question) – Turing85 Nov 17 '21 at 21:30

1 Answers1

0

consider adding custom resources folders per flavor and in paid one keep only one file strings.xml with these two values which you want to change (under same id)

sourceSets{

    main {
        res.srcDirs = ['res']
    }
    orthodoxCalendarpaid {
       res.srcDirs = ['res-paid']
    }

}

more info how to configure this in HERE

snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • You can download example from [here](https://drive.google.com/file/d/1zT-x5QJ9MqzGLWQvrGPZ4L0J04L_ERCQ/view?usp=sharing). In ny app i did,what for each flavor for textview will be different text. But when you will change reference on string,after sync project with gradle files it will be nothing. Why this happend? Also when you will try remove string app_name from strings.xml and move it to gradle,it will be not works too,i.e in this case we will get compilation error. Whether it's issues,which i should immediately report to google or gradle? If yes,how i can correct report thisbugs? – Aleksandr Kozlovskiy Nov 18 '21 at 16:54
  • sadly I don't have idea where do you have problem now... I'm using different `res` folder for changing some strings and drawables (app icon, some logo etc.) in my app per flavor and it works perfectly fine. [some Android doc](https://developer.android.com/studio/build/gradle-tips) shows how to use `resValues` and there is no mention about referencing `@string`, only local gradle/groovy param (build_time in doc) declared line above or hardcoded string replacement – snachmsm Nov 19 '21 at 06:26
  • one and only place in which I've found reference to resources in `resValue` is already linked SO [question](https://stackoverflow.com/questions/36414602/defining-resvalue-using-an-existing-string-definition), in which OP go further and inspect why this is not working: `@string/beta_name`... so Gradle doesn't understand `@string`, takes whole param as `String`. afaik proper way for changing name (still respecting different langs) is to keep separated files per flavor – snachmsm Nov 19 '21 at 06:30
  • you can also check [THIS](https://stackoverflow.com/questions/19830972/different-app-names-for-different-build-flavors) question (in fact: duplicate...), in there you have 9 different answers and not even single one uses `@string` reference as last param for `resValue` – snachmsm Nov 19 '21 at 06:32
  • Ah,for lines,which we use in manifest we should use placeHolders. About sourceSets i had problem,connected with manifest lines,but i solved it by removing main { ... } block or by removing of all code from this block. – Aleksandr Kozlovskiy Nov 19 '21 at 11:49