I have 2 apps using the same images and resources except the AppIcon.
A common solution for this is having a seperate folder for each app under src and configuring gradle to use the corresponding folder.
In my case 99% of the resources are used from both apps, but only the appicon is different.
Do I have to still use the mechanism of having different res folders or is there also an easier way, so I do not have to clone all the resources ?
I thought I could do something like this:
I have a AndroidManifest Entry as follow :
<application android:name="bla.bla.MyApplication" android:largeHeap="true" android:icon="#drawable/icon" android:label="#string/app_name">
I can overwrite the name in gradle as follow, which works fine:
demo {
resValue "string", "app_name", "This is the Demo"
resValue "drawable", "icon", "demoicon"
}
Is there a way to overwrite the iconname in the same way ?
As you can see in the snippet above, I already tried, but I get an
Duplicate resources error, because my demoicon saved under res/drawable is generated automatically .
Isolved it the following way:
I did not want to clone the res folder for different build types, only to change the app-icon.
It can be done with manifestPlaceholders:
In my build.gradle :
buildTypes {
demo {
manifestPlaceholders = [iconpath:"#drawable/icon_timeline_test"]
}
it will replace the icon in the AndroidManifest, when referenced as follow:
android:icon="${iconpath}"
If your flavours name like production then:
android.sourceSets.production
{
res.srcDirs = ['res', '/path/to/production/res/dir']
}
And then in your /path/to/production/res/dir/drawable-* you would have your launcher icon.
Related
I am running assemble for my library module , I see from logs that it should generate two files myLib-release.aar and myLib-debug.aar inside the myLib/build/outputs/ folder.
However, I always only find one lib there that is myLib.aar, it doesn't matter if I run assemble for both, assembleDbug or assembleRelease.
Why is this happening?
According to this discussion it is an error (or planned feature) in gradle, up to date it is still the same.
https://github.com/gradle/gradle/issues/8328
Workaround can be to implement this:
// in library/library.gradle
afterEvaluate {
def debugFile = file("$buildDir/outputs/aar/library.aar")
tasks.named("assembleDebug").configure {
doLast {
debugFile.renameTo("$buildDir/outputs/aar/library-debug.aar")
}
}
tasks.named("assembleRelease").configure {
doLast {
debugFile.renameTo("$buildDir/outputs/aar/library-release.aar")
}
}
}
You may then implement copy tasks as desired.
I am looking at this https://github.com/lorenwest/node-config, and it seems to do everything I need. However I am wondering if it's possible to specify multiple config files based on their categories.
Is this possible to do this?
./config
default-aws.json or aws-default.json
production-aws.json or aws-production.json
db-default.json
db-production.json
etc..
so the config files can be smaller? I know we could make a giant config that has all of those required in different sections. eg
{
"aws": {
"kinesis": "my-stream"
....
},
"db": {
"host": "my-host"
...
}
}
Anyone has any ideas if this is doable using node-config or different library that works similar to node-config?
Thanks & regards
Tin
The short answer is NO. node-config doesn't support this (As #Mark's response).
The simplest way to do this using node-config is to use JavaScript as config files (https://github.com/lorenwest/node-config/wiki/Configuration-Files#javascript-module---js). This way you still get most of the benefits of using node-config. Then you can simply include other files inside them (https://github.com/lorenwest/node-config/wiki/Special-features-for-JavaScript-configuration-files#including-other-files)
Note that it would be a bit harder to use the multiple config files and overrides for the inner files.
A slightly more complex implementation can use the utility class in config which actually allows you to directly read a specific folder using the same patterns that node-config uses internally (https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities#loadfileconfigsdirectory).
In that case you would probably want to combine all the files to a single config by setting them on the config object before the first call to get (https://github.com/lorenwest/node-config/wiki/Configuring-from-an-External-Source).
I'm a maintainer of node-config. The next version will support a feature to declare multiple NODE_ENV values, separated by a comma.
So if you were doing development in the cloud, you could declare a "development" environment followed by a "cloud" environment.
First the development config would be loaded, followed by the "cloud" config.
The related pull request is #486.
I use nconf. It lets you read multiple configuration files into the same object. Here is an example:
var nconf = require('nconf');
//read the config files; first parameter is a required key
nconf.file('aws', {file: 'default-aws.json'});
nconf.file('db', {file: 'db-default.json'});
console.log(nconf.get('aws:kinesis'));
console.log(nconf.get('db:host'));
default-aws.json:
{
"aws": {
"kinesis": "my-stream"
}
}
db-default.json:
{
"db": {
"host": "my-host"
}
}
I am using the botbuilder framework. I have defined several namespaces for the dialogs I have created, such as help or default. For all of these I have also created json files in my locale/en/ directory, and all is well.
However, I have a few sentences that are very common, and I don't feel like copying those over to each of the individual namespaces. I have tried using index.json as a 'fallback' in case the namespace file doesn't define the string. But it doesn't work for me. Contrary to what the documentation seems to suggest.
/locale
/en
/help.json
/default.json
/index.json <-- Doesn't work
/dialogs
/help.js
/default.js
bot.js
Say I have the following library in help.js, that :
lib = new builder.Library('help')
lib.dialog('/', (session) => {
session.send('custom_cancel')
}
module.exports = lib
The library is used in bot.js:
bot.library(require('./dialogs/help'))
And index.json has this content:
{
"custom_cancel": "My custom cancel"
}
Whereas help.json is empty:
{}
Because help.json does not have custom_cancel, the bot will actually send custom_cancel as the string.
Again. I can copy paste the strings to both locations and there is no more problem. But that seems like an ugly solution to me.
I have tried the more explicit version, which seems to help in more cases, but I am not fully convinced yet.
session.localizer.gettext(session.preferredLocale(), 'custom_cancel')
You can use the third argument for the namespace. It seems that '' will point to the index.json file.
I am working on project whose build logic is defined in gradle and has a build.gradle file for it. Now, we would like to manage property of the project using groovy's config Sluper. And, I have placed config.groovy file in folder that contains all the Helper class for the project. The content of the conf.groovy file is below:
categories {
includeCategories = defaultIncludeCategories()
excludeCategories = defaultExcludeCategories()
}
String defaultIncludeCategories() {
def include = 'default'
if( isAbcJob() ) {
include = 'tier0'
}
logger.info "defaultIncludeCategories: $include"
include
}
Now, as you can see there is a method name isAbcJob() that I need to use in the configuration file but this method is present in build.gradle, which is the file that call conf.groovy file for property management.
Bottom line is how would conf.groovy script would know where isAbcJob() method is?
Please advice.
I found the following question that has been asked on Gradle forums very helpful. And, it looks like that accessing other gradle script's methods is not possible unless you access them through tasks:
https://discuss.gradle.org/t/multiple-apply-froms-dont-seem-to-import-all-methods/2274/6
I have a visual studio solution where one of the projects has somehow acquired several .bin files. They are named bin00001.bin, bin00002.bin, etc... and contains some kind of registry information. The contents of these files are one section repeated a number of times.
bin00001.bin:
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ApplicationName'
'ApplicationName.EXE'
{
val AppID = s '%APPID%'
}
}
}
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ApplicationName'
'ApplicationName.EXE'
{
val AppID = s '%APPID%'
}
}
}
This file had two copies of this section and the other files has. Note that a similar file applicat.bin seems to be the original file with one such section and I guess that it needs to be there.
What are these and why are there so many of them and why are they spread over so many files?
they are referenced in the .rc file and are designated resource identifiers in resource.h. I'm also pretty sure it generated a few of them when I added a couple of ATL classes. (I should maybe mention that this is an MFC project!) I'll add the tag
Update
I should maybe add that the executable contains a COM type library. Would this have anything to do with COM registration?
I figured it out what they are.
Those .bin are replicas of the ApplicationName.rgs file.
I still don't know why Visual Studio created them in the first place though. Some kind of backup, I guess..?