String is not translated android - android

When I tried to open my android project in eclipse a few minutes ago I got these errors telling me the the strings in the strings.xml file are not translated to other languages (this morning everything was good).
I found something online that said I should change MissingTraslation to Warning instead of Error, but it didn't help.
What should I do?

it's shown by the Lint tool.
just change its settings (to warning/info/... instead of error), and run Lint again (the button on the toolbar, near the button of launching the app, looks like a checkbox with a "V" in it, looks similar to this one ).

Try this:
http://tools.android.com/recent/non-translatablestrings
juste put translatable="false.
Best regards,
Yassine

Related

"is translated here but not found in default locale" error in strings.xml with translatable="false"

Here is my values\strings.xml (the default file) and everything is self explanatory:
My question(s):
How can it be "not found in default locale" if I am editing the default locale (values\strings.xml)?
How can it be a lint translation error if I set translatable="false"? In the values-pl\strings.xml (and values-ru, values-iw folders as well) the strings don't exist even? it shouldn't anyway.
I can't seem to understand why I don't get the error for the Russian string.
(I would show the values-ru\string.xml or values-pl\string.xml here but there is nothing there of interest, since the strings are missing anyway...)
this happened to me too
I do 2 things:
Verify entire file to see another translate not done ( I have ones in file en but in pt-br)
Clean, update gradle and quit and restart the Android Studio
Rebuilding can take a long time. YMMV, but...
Simply remove the offending line and re-add it.
Worked for me. Very fast.
In my case this helped me:
Select the strings that cause error.
Cut them.
Paste them again
If it doesn't work for you, try adding the same strings to strings.xml(v21) file.
Press Invalidate Caches / Restart ... to restart android studio. It worked for me. Actually this happened when I had copied files from my other computer and pasted via file explorer.
I solved this issue by following below steps:
cleaning my project
rebuilding it
and finally pressing invalid caches/ Restart in file menu
If you just Clean Project it probably works. It worked for me.
I had the same error message, just with the weird issue that it was thrown in the default locale itself and all translations. Turns out you should not use dots in your name (e.g. name="bla.blub") because it will be internally converted to "bla_blub" and then it cannot match with "bla.blub", hence the error.
I only had to change the dots to underlines in the default locale and then all other errors in other translations (including dots in the name) were gone as well.
But be aware that other build tools can still create issues, so replace all the dots with underlines instead!
Quitting Android Studio and restarting it fixed it for me.
You simply just have to copy the offending line (or just one of the multiple of offending lines), remove it, and re-paste it. That removed the issue for me.
Just make sure that you have same naming conventions on all strings files including the same capitalization.
let's say if you have "sign_in" in strings.xml and "sign_In" in your fr/string.xml, so it will give you error on fr/strings.xml like "is translated here but not found in default locale". So, when you edit to "sign_in". The error will remove.
I was having this problem for all the strings in my xml file.
The thing is, your default strings.xml shouldn't have a tools:locale attribute as the other translated files have. If it does, whenever I compile the app in release mode, it treats it as another translated file.
I've created a tool to manage the translation status of android apps.
It not only tells you what strings are missing on the other languages, but it can also report, and clean the left over strings that you may have deleted on your default translation file.
https://github.com/gubatron/android-missing-strings
To clean all left overs in other languages invoke like this
./ams --cleanleftovers -o all.txt
This will clean the left over strings and it will output the missing strings report for all the languages into the all.txt file
Copy and paste didn't work for me.
I also tried Clean and restart, the previous error was gone but new entered strings still have new errors occur.
I tried closing the opened strings.xml file and Translations Editor, then restart.
strings.xml file and Translations Editor
That works for me.
Well, in my case, this happened when there was a format error with the previous string of the string that's being reported. Unfortuantely that format error was not reported. Correcting the format error solves the issue.
Add this,It will work
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ExtraTranslation">
Press double shift for open Translations Error and then check and uncheck in Untranslatable column the item with error.

Android Studio not recognizing Espresso/Hamcrest static method names without prefacing with the classname

I wasn't sure exactly what headline to give this question because I'm not sure what this is technically called. In Android Studio while typing out Espresso tests I noticed that it refuses to accept something like this:
onView(withId(R.id.someId)).perform(click());
and instead will only accept this:
Espresso.onView(ViewMatchers.withId(R.id.someId)).perform(ViewActions.click());
even though every example that I've seen online shows the first example as correct code. Why is Android Studio forcing me to preface every ViewMatcher/Espresso/ViewActions/etc. method with the classname even after the imports are included in my class?
To clarify - trying to use the first example shows "cannot resolve method" and using autocomplete on it (which I have to do several times before it will work) invariably autocompletes to the second example. In all the "regular" code for my project autocomplete works correctly and short method names are recognized. I've tried doing a "clean" and "invalidate cache and restart" but no change.
Example of Google doc that shows usage according to the shortened code:
https://developer.android.com/training/testing/ui-testing/espresso-testing.html
You can try to check out your Android Studio Preferences for imports. Just go to Preferences -> Search "imports"
Here are the settings that I use and I don't have that issue:
What fixed the issue for me: just removed red withId in one place. Then just re-entered "withId": after that all the other red withId were replaced with black text color withId and now it compiled successfull!

Android - Strange bug or something wrong with my file structure?

After today's work on my Android app, this started happening:
1: Android Studio say that the ID: welldana_image isn't there, even though it's right above: (Image below)
^ This problem persists all the way through this .xml file (activity_calculate_mine.xml)
2: The two project "show package" types aren't matching. In the first picture (Android style), the layout file activity_calculate_mine.xml isn't there, but in the second (Package style) picture, it is. (Pictures below)
EDIT: Everything works fine. I just don't want to push this to the marketplace, and suddenly it won't work. But everything works fine at the moment, though seeing these errors.
EDIT 2: Now this has happened? Is there an error in my manifest that I can't spot?
EDIT 3: Luckily I saved myself a copy of the project before everything went nuts. Apparently I deleted the activity_calculate_mine.xml. I solved this problem by simply placing the old version in the same directory as of before, and then just copy pasting the activity_calculate_mine.xml back into it's original placement.
Problem solved. Thank you.
Remove the "+" sign in the line android:layout_below="#+id..."
The #+id defines an id value, the #id referes to one.
Change this:
android:layout_below="#+id/welldana_image"
To this:
android:layout_below="#id/welldana_image"

My android app does not recognize R.string resources - what could be the reason?

I learn android with sample apps from textbook. In the given sample source R.string.something is recognized:
However, in my own EXACT source code, same R.strings are not recognized- highlighted as errors:
Does anyone know how to fix it?
I've had this many time with eclipse, and it was not a setup / code problem on my side. Generally, cleaning, rebuilding and sometime even stopping and restarting eclipse solved it. And yes, it's a pain in the neck ...
Try a clean of your project, if that does nothing then click on the problems tab and see if there's any build related issues, you may be missing a required jar or something!
These are following reason possible.
1-: You import android.R;
2-: Any error in xml files.
3-: Please check you String.xml file may be any error or declare a string more then two time.
I assume you are new to Android.
If so, there are two ways of using text strings in Buttons, textviews and so on:
1) Hardcoded string - you put the text you want in quotation marks (""), for example:
yourTextview.setText("Hardcoded string");
2) You can call the text from your String resources (res/values/strings.xml).
That is a much better approach seeing is is easier to translate, make changes and so on.
In your strings.xml file you can create all your string values, and call them from there.
Like in you example, if in your strings.xml file you have for example:
<string name="delete">This is String resource</string>
you can then call the string from there, like so :
yourTextview.setText(R.string.delete);
Hope this helps!

java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditView

I get the error in the title when i run my application, I have checked the forums but all my Edit, text views are closed. I dont really understand what the problem is, everything looks fine to me.
<EditText
android:id="#+id/fairgroundName"/>
<EditText
android:id="#+id/rideName"/>
ride =(EditText)findViewById(R.id.rideName);
fairground =(EditText)findViewById(R.id.fairgroundName);
But I don't get what the problem is. Can anyone help please
Your code looks fine to me too. Looks like the code for your EditText was not generated properly in R.java.
Clean the project. Hopefully, it would remove the error.
Project -> Clean
Don't forget to uninstall the application from the phone before you try running it again.
Do you change The order of your views in layout file? Sometimes doing it cause this error. As swayam said do a Project -> Clean to regenerate your R.

Categories

Resources