Since I switched to SDK v4 I notice this in LogCat :
W/GAV3﹕ Thread[main,5,main]: int configuration name not recognized: ga_dispatchPeriod
W/GAV3﹕ Thread[main,5,main]: string configuration name not recognized: ga_appVersion
All the other parameters are good but those really seem to be ignored. Any ideas ?
Thanks.
Apologies for confusing setup. Are you specifying the ga_dispatchPeriod and ga_appVersion values in the global configuration? If not, can you move them to the global configuration? This link specifies how to setup global configuration.
Note that global configuration is different from tracker configuration which is documented here.
If this does not fix your issue, can you paste the complete xml file? and how you are setting it up?
Thanks!
WoW Why is this so over engineered? I use a single xml file for both app tracking specific configs AND global configs and I just add that meta tag in the manifest to point to that single xml file like so
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="#xml/app_global_tracker"/>
And in my code i just do Tracker t = analytics.newTracker(R.xml.app_tracker);
and thats all
Related
I have finished to write my small program and now I want to add locale.
Before I had next structure: /res/value/strings.xml
I have added to the structure new folder with file with another language:
/res/value-uk/strings.xml (it's ukrainian language)
after that I built my APK in AndroidStudio and I got error:
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
Unknown failure (Failure)
Error while Installing APK
I was searching this problem in google and nothing helped me.
Please reccomend me how to solve this problem. Thank you.
I had the same problem and I found a lot of people managed to solve the problem by adding the full package name inside the various manifest "android:name".
It didn't work for me and I found out that my problem was different:
I had two string files, "strings.xml" and "strings-en.xml. In the former one I had some values with the field "translatable=false", such as:
<string name="db_name" translatable="false">my_db</string>
To solve the problem I had to REMOVE that string resource from the strings-en.xml, in order to have those strings only in the default strings.xml.
I hope this can help future developers.
The xliff namespace declaration in your strings.xml file seems to be wrong. Try using <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> instead. Or strip out all the <xliff:g> tags and see if it makes a difference - they are not needed any more after translation. And Chol is right: the default folder name for Ukrainian is values-uk, not value-uk.
I'm writing a library that is used by developers and I have a configuration items like apiKey, environment and others. I want to developer to set these values, my first thought was using Java Properties file that I load in the Application class, but I've seen Google Play and Google Map SDK ask the developers to add their apiKey in meta-data tag in Android Manifest. What is the recommended way?
The recommended android way to let the user define values for your library
from the application module is through meta-tags
it is as easy as using this code on the android-manifest
<meta-data android:name="com.yourproject.apikey" android:value="apikey"/>
and you can get these values from your library like this
try {
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = applicationInfo.metaData;
String apiKey = bundle.getString("com.yourproject.apikey");
} catch (NameNotFoundException e) {
//Resolve error for not existing meta-tag, inform the developer about adding his api key
}
The main benefits of this approach are
1) That you can let the user define different values per device type e.g. phone, tablet or sdk-version
(this may not be applicable for your case but it's a good point for sure)
2) You can add complex data as the value in your meta-tag,
and you can use this if you want to add a string-array with all the value that you want to declare.
3) Since meta-tags are basically a bundle it is easier for you to
Read these values on your library code.
Have default values if the user has not declared the required
meta-tags.
(I believe that parsing properties from assets requires more code without any great advantage)
4) You can also add configuration meta-tags for activities,providers and broadcastreceiver on your AndroidManifest.
5) Also I suppose that it is easier to request for the consumers of your library to add a few meta info on his Android Manifest, than adding a properties file on their assets folder.And i believe that this is the main reason Many known libraries use this approach like google-play-service, google-maps, crash reporting libraries and many libraries that provide user analytic.
Good Luck
It´s seems that using meta-data tag is the Android way to achieve this, although I can´t find any official documentation to argue why.
Using meta-data you can define you property value using a resource instead of a static value, this way you can get different values for the same property based on the resources qualifier. This is very useful if your property needs internalization.
Ex:
<meta-data android:value="foo.bar" android:name="#string/hello" />
is easy using this
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="API_KEY"/>
I am trying to include the ads by making them part of my xml layout, I noticed on this quickstart guide: https://developer.amazon.com/sdk/mobileads/quick-start.html it says that you should have the namespace as "xmlns:Amazon="http://schemas.android.com/apk/res/"". However when I tried this intelij says that the namepace is never used and the ad never shows up in the layout. I looked in the sample provided in the sdk and for their namespace they didn't use their package name but instead: "xmlns:Amazon="http://schemas.android.com/apk/lib/com.amazon.device.ads"". So I am wondering what the correct namepace is that I should be using
I noticed on this quickstart guide it says that you should have the namespace as "xmlns:Amazon="http://schemas.android.com/apk/res/""
I looked in the sample provided in the sdk and for their namespace they didn't use their package name but instead: "xmlns:Amazon="http://schemas.android.com/apk/lib/com.amazon.device.ads""
That first statement is not correct. In the quickstart guide it actually says that the namespace should be:
xmlns:Amazon="http://schemas.android.com/apk/res/<type your package name>"
Note the last part. That's important, because that's exactly the difference you're basing this question on.
As with any custom view on Android, if you want to use one or more attributes that aren't covered by the Android namespace, you have to declare their location first. Normally, that means you copy the line above and append the package name of your project. The Amazon prefix can be pretty much anything you like, but it makes sense to give the namespace a name that is related to its definition.
In this case, declaring the Amazon namespace, enables the usage of the Amazon:adSize attribute in the layout file. Without that declaration, your IDE will not know where to look for the adSize attribute.
That being said, if you don't use any custom attributes, then there is no point in declaring the namespace, as you won't be using it. That's basically what IntelliJ is telling you. In other words: if you're not using Amazon:adSize in your layout, you can safely remove the Amazon namespace declaration.
How do I fix this? I already tried removing the R.java and cleaning the project via eclipse, but it doesn't help.
FYI I am trying to get PhotoStream from here: http://code.google.com/p/apps-for-android/, but so far it has been very difficult to get things work.
Okay..... 5 mins later google tells me the correct answer...
http://www.fairtec.at/en/it-blog-mainmenu-16/168-the-type-r-is-already-defined
I just didnt search hard enough.
"The type R is already defined"
That's the message you get in Eclipse if you try to build the Funambol Android Sync Client.
Reason is that you have checked two Builders that try to generate the same class.
You just have to uncheck the Java-Builder from Project->Properties->Builders.
Then the application even works fine in the Emulator.
Delete the R.java from the src folder and rebuild the project. This file will be automatically rebuit during this process.
http://www.fairtec.at/en/it-blog-mainmenu-16/168-the-type-r-is-already-defined
click right to project click properties
Project->Properties->Builders.
unckeck java Builder
delete file R.java
You may want to change your package names. It looks like you are using a 'PhotoStream'.jar which has it's R.class defined at the same package structure as you.
Here is a link to the R.java from the project on Google Code. Notice you are using the same package:
http://code.google.com/p/apps-for-android/source/browse/trunk/Photostream/src/com/google/android/photostream/R.java?r=83
I had the same issue when I imported a project from work. Turning off the Java builder as suggested in the article you found fixed my problem, but when I made code updates they were not reflected in the running app. In my case there was an R.java in my source which I deleted and that fixed my problem.
In my case,
as i m not using any IDE for programming but using command line Android..
i had two xml files, one in layout and other in layout-land. i was using same id "XXX" for both but while declaring i made small mistake
android:id="#+id/XXX" (in layout xml)
android:id="#+id/XXX " (in layout-land xml)
please observe extra space in second id declaration, so while creating R.java they were different and in R.java i had
public static final int XXX=0x7f040046;
public static final int XXX =0x7f040045;
which are same, so please be aware of extra spaces. Thank you
my app has a styles.xml file with various visual constants defined.
I'd like my users to be able to switch the entire app to an alternative visual theme. I'd like to provide an alternative styles2.xml file and switch at runtime (via the Settings).
Is this possible, and how? I suspect the style names' appearance in the generated R class does not bode well.
If it's not possible, what's my next best option?
Not sure if anyone is still interested but I have found a possible solution. A bit hackish but gets the desired result.
Basically I set up my 2 style files in separate country code directories:
res/values-mcc199/style.xml
res/values-mcc198/style.xml
Then in my activity I use the following to change which is referenced:
Configuration config = new Configuration();
config.mcc = 199;
getBaseContext().getResources().updateConfiguration(config,null);
I've only done some basic testing so far but it appears to work. Obviously if you are already using country code to decide your layouts then this will interfere. I think there may be problems as well if the phone gets an event about a country change.
Actually, after some reading of the doc, it seems that this can be done. Look here.
As it is mentionned :
To create a set of styles, save an XML
file in the res/values/ directory of
your project. The name of the XML file
is arbitrary, but it must use the .xml
extension and be saved in the
res/values/ folder.
Now, if this is logical and I didn't read the doc wrongly, you can create as many styles as you want, reference them in themes.xml with #style/... (if you want to apply it to a whole activity or application) and then, just call
setTheme(R.id.yourtheme)
I think this should work. Have a go at it and tell us?
It's not an exact answer; in my blog post here:
http://blog.blundell-apps.com/switching-android-configurations-using-constants-and-ant/
I switch out a java class at build time using Ant, there is nothing to stop you switching out an XML file, as it compiles after the switch. To amend the tutorial you'd just have to change the path's of the file your templating.
Also mirrored on GitHub: https://github.com/blundell/BuildChoiceTut