Add language resources in android apk application - android

Well I have a single language android application that I translated strings in res/values/strings.xml to make it multi language application. I made for instance values-fr/strings.xml, values-es/strings.xml ...
When compiling my application, I get this error
mayapp/res/values-fr/strings.xml:1: error: Error parsing XML: XML declaration not well-formed
mayapp/res/values-es/strings.xml:1: error: Error parsing XML: XML declaration not well-formed
How to solve this problem.
I need your help since I'am new in android development.

use numerical code for special character:
<string name="app_name">Répondeur</string>

Related

Android Studio - XML Serialization and XML Validation against .xsd schema

I'm working with a Android App and XML.
By using Jaxb, I had java xml classes from a .xsd file.
I want to generate a xml file from these xml classes then validate against the .xsd file.
I found here an example:
http://www.mkyong.com/java/jaxb-hello-world-example/
But I cannot use javax.xml.bind.Marshaller:
Error:(76, 27) error: cannot access XMLEventWriter
class file for javax.xml.stream.XMLEventWriter not found
Then I add javax.xml.stream lib:
java.exe finished with non-zero exit value 1
I also posted a question about xml validation against xsd but till now I have not get any suggestion yet:
Android XML validation using XSD ( both xerces and SchemaFactory) error
Any suggestion for me?
Thanks,
Short answer:
XML Validation: xerces for android: https://code.google.com/p/xerces-for-android/source/checkout
XML Serialization: http://simple.sourceforge.net/
.xsd to java objects: Jaxb or Jibx
Is there a need in JAXB implementation for Android?

eclipse - android- Error parsing XML: not well-formed (invalid token)

I downloaded an android project and opened it in eclipse. eclipse can not resolve R in "setContentView(R.layout.ayat)" so I guess I may have problem in "res" folder and yes!! one of my xml files in "res" folder has a big red X with "Error parsing XML: not well-formed (invalid token)" message.
I know that It means there is a compilation error in my XML file, something that shouldn't be there: a spelling mistake/a spurious character/an incorrect namespace.error but unfortunately i cant find the bad typed command.
this is the XML file:
The <resources> tag, and in your case the <string-array> tags, doesn't accept xmln attributes, such android:layout_width or android:layout_height. Getting rid of them will fix your issue.

First Android Project Errors

I'v just started building my first Android project with eclipse, according to Lynda's course Up and Running with PhoneGap.
When i try to run the project (like the demonstration on Lynda), i get the following error message:
"your project contains error(s), please fix them befor running your application."
Description Resource Path Location Type
error: Error: No resource found that matches the given name (at 'label' with value
'#string/app_name'). AndroidManifest.xml /android_project line 49
Android AAPT Problem error: Error: No resource found that matches the given name (at 'label'
with value '#string/app_name'). AndroidManifest.xml /android_project line 52 Android
AAPT Problem
The import org.apache.cordova cannot be resolved android_project.java
/android_project/src/com/example/android line 23 Java Problem
DroidGap cannot be resolved to a type android_project.java
/android_project/src/com/example/android line 25 Java Problem
The method onCreate(Bundle) of type android_project must override or implement a supertype
method android_project.java /android_project/src/com/example/android line 28 Java
Problem DroidGap cannot be resolved to a type android_project.java
android_project/src/com/example/android line 30 Java Problem
Config cannot be resolved android_project.java /android_project/src/com/example/android
line 32 Java Problem
Attached the error screenshot
I can guess what some of the error messages means, but i don't know how to solve them.
Any suggestion?
I'm using windows 8.
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Thanks,
Liron
Check your strings.xml inside your project>res>values and add the string values you are going to use in your project.
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="app_name">AppName</string>
</resources>
Plus, I think you need to update your .jar file of cordova.
You can download it from the phonegap github repo.
You can find the lib in the lib/android/ folder.
To create a new project, you can use the lilb/andoird/bin/create.bat file.
Don't forget to clean the project.
Hope this helps you.
I think You forgot to set the string values. I haven´t read that tutorial, but there are some strings missin. Check the tutorial, You have to set some strings inside strings.xml in Your res/values folder
EDIT
go to folder inside Your project "res/values" and open strings.xml. Then begin a new line and put
<string name="example_string">This is an example!</string>
The first part "example_string" is the name of the string. This is to refer to this for example inside an xml layout. imagine You have a button in any xml layout:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/example_button"
android:text="#string/example_string"/> <-- here you refer to that string inside strings.xml
The second part "This is an example" is what will be appear on that button.
But I think it would be better if You learn the basics instead of starting with PhoneGap.
http://developer.android.com/training/basics/firstapp/index.html

no resource found that matches the given name Android 1.6

I've got 'no resource found that matches the given name' but everything is set up correctly.
error: Error: No resource found that matches the given name (at 'text' with value '#string/labReminderClear').
In AndroidManifest.xml:
<application android:label="MyName"
.....
In Strings.xml:
<string name="app_name">MyName</string>
...
<string name="labReminderClear">Clear</string>
What could be wrong?
The project you've mentiond contains errors in strings.xml file. It is connected with % sign used for example in following line (NOTE: there are multiple in that file):
<string name="msgYouHaveASTS">You have %d appointment(s)\n..and %d task(s)</string>
This is due to aapt (Android Asset Packaging Tool) becoming strict and being used for all versions of Android. See detailed explanation in this answer.
If you want to fix the code so that it works correctly, you have to add info about parameters positions. For example line from above should become:
<string name="msgYouHaveASTS">You have %1$d appointment(s)\n..and %2$d task(s)</string>
If you're using Eclipse try using (from menus above):
Project->Clean....
Select project, in which you have problem, to be rebuilt.
If that doesn't help Error Log view might help you nail what is the real issue here. From Eclipse menus choose:
Window->Show view->ErrorLog

Android resources for languages with only 3 letter codes

While trying to add localized resources for the Sakha language in my android app, I kept getting errored out with the following message:
[aapt] invalid resource directory name: /Users/yuvipanda/code/WikipediaMobile/res/values-bho
BUILD FAILED
/Users/yuvipanda/adk/tools/ant/build.xml:539: The following error occurred while executing this line:
/Users/yuvipanda/adk/tools/ant/build.xml:568: null returned: 1
Trying to add variants for any three letter language code gives me the same error (values-bho, values-kbd, values-sah, etc).
Is there a trick I'm missing, or does Android not support having localizations for languages with only 3 letter language codes?
From Providing Alternative Resources in the developer guides, it looks like Android supports only two-letter ISO 639-1 language codes.
The naming convention is different for apps that include three letter language codes. Instead of having your resources in the folder values-bho, put them into a folder called values-b+bho. the -b+ identifies the following language tags as pertaining to BCP 47 (language codes, dialects, regions, scripts, and the rest of the kitchen sink), rather than ISO 639-1 (two-letter codes).

Categories

Resources