Hi,
I created a project with Android Studio
so the directory structure is as follow:
src/
main/
java/
res/
Today I was trying to integrate the TagManager for the first time.
I followed the guide indicated to place a file in res/assets/tagmanager/GTM-XXXXXX.json for the default configuration.
I did.
And it simply printed this in the log when trying to open the container:
09-26 18:39:28.203 1379-1379/com.my.package.debug W/GoogleTagManager﹕ No asset file: tagmanager/GTM-XXXXXX found.
09-26 18:39:28.203 1379-1379/com.my.package.debug W/GoogleTagManager﹕ No asset file: tagmanager/GTM-XXXXXX.json found (or errors reading it).
09-26 18:39:28.203 1379-1379/com.my.package.debug W/GoogleTagManager﹕ No default container found; creating an empty container.
Now I struggled a very long time trying to figure out what was wrong with that but the json was valid.
In the end I checked if the file was actually there using the AssetManager... it wasn't.
So I manually added this to the gradle configuration:
sourceSets {
main {
assets.srcDirs = ['src/main/res/assets']
}
}
With this it included the assets directory and finally my json was loaded.
But wait.
It's not done yet....
It works when I execute it from command line.
I couldn't find any way to make it work from inside Android Studio.
Android Studio simply insisted to ignore the assets directory.
My build.gradle is this:
classpath 'com.android.tools.build:gradle:0.5.+'
final RELEASE_PROVIDER = "com.my.package.sync.provider";
final DEBUG_PROVIDER = "com.my.package.sync.debug.provider";
final RELEASE_ACCOUNT_NAME_DUMMY = "dummyaccount";
final DEBUG_ACCOUNT_NAME_DUMMY = "dummyaccountdebug";
final BUILD_CONFIG_CORMAT = "public static final String PROVIDER_AUTHORITY = \"%s\";\n" +
" public static final String ACCOUNT_TYPE = \"%s\";\n" +
" public static final String ACCOUNT_NAME_DUMMY = \"%s\";";
buildToolsVersion "18.0.1"
assets.srcDirs = ['src/main/res/assets']
buildConfig String.format(BUILD_CONFIG_CORMAT, RELEASE_PROVIDER, RELEASE_ACCOUNT_TYPE, RELEASE_ACCOUNT_NAME_DUMMY);
packageNameSuffix ".debug"
versionNameSuffix "-debug"
buildConfig String.format(BUILD_CONFIG_CORMAT, DEBUG_PROVIDER, DEBUG_ACCOUNT_TYPE, DEBUG_ACCOUNT_NAME_DUMMY);
compile 'com.android.support:appcompat-v7:18.0.0'
compile project(':ViewPagerIndicator:library')
compile project(':volley')
compile files('libs/libGoogleAnalyticsServices_3.0.jar')
The debug/release settings only contains an AndroidManifest with the 3 settings for the SyncAdapter in my app, linking to different xml/ files.
It didn't matter how many times I clicked the icon to sync with gradle or closed/reopened the project. I had to DELETE it from the list of project in Android Studio and re-import it to make it work again.
Have I done something weird?
Am I the only one experiencing this issue?
Shouldn't the assets directory be included by default without me specifying it?
Thanks in advance,
Regards,
Daniele