I am new to android and I started this sample from google but i have a problem and couldn't get pass it.
This line has an error in DictonaryDatabase.java.
InputStream inputStream = resources.openRawResource(R.raw.definitions);
and the error says "raw cannot be resolved or is not in a field."
I have imported the Java.R but this didn't seem to fix it.
I also have created a raw folder but didn't fix it.
thanks for your help.
you need to add definitions.txt. file directory should luk like this /res/raw/definitions.txt .It is just soft copy of dictionary.
and copy below texts inside that definition.txt file
i entered just 'A' and 'B' letters. If u get any text of dictionary words just copy those words till letter 'Z' in this definition file
abbey - n. a monastery ruled by an abbot
abide - v. dwell; inhabit or live in
abound - v. be abundant or plentiful; exist in large quantities
absence - n. the state of being absent
absorb - v. assimilate or take in
abstinence - n. practice of refraining from indulging an appetite especially alcohol
absurd - j. inconsistent with reason or logic or common sense
boycott - n. a group's refusal to have commercial dealings with some organization in
breach - n. an opening (especially a gap in a dike or fortification)
caricature - n. a representation of a person that is exaggerated for comic effect
casual - j. without or seeming to be without plan or method; offhand
I just solved it removing this line
import android.R;
R is a special class holding identifiers of all your resources. It is automatically generated to match the content of your res folder. According to your error, you haven't added raw/definitions to your res folder. You are trying to access a non-existent resource.
it seems you need
import android.R;
Related
I uploaded local photos in drawable files. The photos are approximately 3 mb in size. Its showing this error. However The problem panel shows analizing for 15 minutes till now and it is still showing it. What could be the possible reason for such errors.
Resource name must start with a small case letter or an underscore('_').
For more rules regarding resource naming convention, you can refer to the below-mentioned medium article.
https://medium.com/#AkhilDad/a-designers-guide-for-naming-android-assets-f790359d11e5
There are a few conventions used in resources:
For resources that exist as separate files, they must be
lower_case_underscore_separated. The appt tool makes sure that your
files are only lower-case, because using mixed case can cause issues
on case-insensitive filesystems.
For resources declared only in values/... (attributes, strings, etc)
the convention is generally mixedCase.
There is a convention used sometimes to tag names with a
"classification" to have simple namespaces. This is for example
where you see things like layout_width and layout_alignLeft. In a
layout file the attributes for both the View and the parent layout
management are mixed together, even though they are different
owners. The "layout_*" convention ensures that there are no
conflicts between these names and it is easy to understand which
entity the name impacts.
For more information here is the complete discussion.
Are there conventions on how to name resources?
Resource name must start with letter. You can't start image name with digits.
The reason you can't have a resource with a numeric name is because variable names cannot start with numbers.
The error is actually because the resource name cannot start with a number. Resource name should start with a letter or underscore(_).
I have to maintain an app translated into more than 10 different languages. Whenever a new version is developed, new strings are added to the source values.xml . The translation editor helps me to get an overview about which strings are missing in other languages, but at the moment, it looks like there is no option to get a diff xml with just the new strings added for each language. Since we use translation services we have to pay per translated word. Therefore I always have to manually create the files with the missing translations, which is very time consuming.
I can't imagine I'm the only one needing this particular feature. Is there a workaround / script / plugin which does solve this problem?
Back in the steam age I faced similar problem while trying to keep like 14 translations in sync, so I created small PHP script to to help me with this.
As I said it's pretty dated (2010 :) yet it should work. I just made it available on GitHub: https://github.com/MarcinOrlowski/android-strings-check
Basically what it does is diff two translation XMLs and generate human readable report:
./strings-check.php values/strings.xml values-pl/strings.xml
It will give you the output like this:
Missing in LANG (You need to add these)
File: values-pl/strings.xml
------------------------------------------------------
show_full_header_action
hide_full_header_action
recreating_account
Not present in BASE (remove it from your LANG file)
File: values/strings.xml
------------------------------------------------------------------
provider_note_yahoo
Summary
----------------
BASE file: 'values/strings.xml'
LANG file: 'values-pl/strings.xml'
3 missing strings
1 orphaned strings
Ok, I guess I found the solution to my problem, a python script called android-localization-helper:
https://github.com/jordanjoz1/android-localization-helper
I am trying to create a PDF in my Android application using the Android PDF Writer. This is a very basic library that allows to create simple PDF files. It works quite well, but there is one thing I do not understand:
When I look at the generated PDF source code I can see, that the file starts with the following lines:
%PDF-1.4
%©»ªµ
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
...
What does the second line mean? I searched a lot of different PDF syntax documentations but I have found no hint what that line could mean. In all examples I found the the %PDF-VersionXY line is directly followed by the first object / the catalog.
I am not sure if this is valid PDF code at all, or if this some an error due to some charset/enconding problem with the libraries source code.
Any idea what this could be about? What information could be included at this place and is %©»ªµ valid PDF or some enconding error?**
When taking a look at the pdf-1.4 reference here (or also in the current 1.7 here) in section 3.4.1 it says
Note: If a PDF file contains binary data, as most do (see Section 3.1, “Lexical Conventions”),
it is recommended that the header line be immediately followed by a
comment line containing at least four binary characters—that is, characters whose
codes are 128 or greater. This will ensure proper behavior of file transfer applications
that inspect data near the beginning of a file to determine whether to treat the file’s
contents as text or as binary.
So your generator seems to include this additional comment-line by default, even if there is no binary data to follow. What's in there doesn't matter as long as each byte value is > 128 (that is: outside the ASCII-range). In your case it's hex values A9 BB AA B5, so everything is fine and you don't have to worry about this line.
I sometimes see this declarations in Android source code:
mContext.getString(2131361954);
Notification n = new Notification(2130837696, "123", System.currentTimeMillis());
// Example code - does not match together
I think the numbers are some resources from the project, right? Why sometimes people work with this numbers instead of using the R class? Is it faster or something else?
And how can I check which resource is assigned to that numbers? Is it possible to get number which is used if I only have the file or is this number random? Maybe with the file name or the MD5 hash of the file or something else?
There is no performance difference, as all members of the R class are static and final, and are directly swapped in during compile time. This is equivalent to any code that uses R.x.y, so the performance is the same.
I would strongly recommend against using the numbers directly in your project as they may change during the addition, removal and modification of resources.
You can check the resource to which that number corresponds by converting it to hex, opening up the R.java file and searching for that hex number and seeing what it is assigned to.
You can also use getResources().getResourceEntryName(int resid); and pass it the ID at runtime to retrieve the file name.
I am currently working on a project for android using Tesseract OCR. I was hoping to fine-tune the results given to the user by adding a dictionary. According to tesseract OCR wiki, the best way to go about this would be to
Replace tessdata/eng.user-words with your own word list, in the same
format - UTF8 text, one word per line.
However there is no eng.user-words file in the tessdata folder, I assume that if I just make a text file with my dictionary in it, it will never be used...
Has anybody had a similar experience and knows what to do?
If you're using tesseract 3 (which I assume you are).
You'll have to rebuild your eng.trainddata file.
I intended to replace the word-dawg file completely to try to get better results (ie - the words I'm detecting are always the same).
You'll need combine_tessdata and wordlist2dawg executables in the training directory when you compile tesseract.
unpack everything (i did this just to back up my eng.word-dawg, you'll also need the unicharset later)
./combine_tessdata -u eng.traineddata
create a textfile of your wordlist (wordlistfile)
create a eng.word-dawg
./wordlist2dawg wordlistfile eng.word-dawg traineddat_backup/.unicharset
replace the word-dawg file
./combine_tessdata -o eng.traineddata eng.word-dawg
that should be it.