Android Studio build file R broken - java

I am working on an android app which has worked and been tested many times. Today, however, in attempting to run the application for further testing, I have encountered the following error message:
C:\Users\1000\AndroidStudioProjects\WarofSol\app\build\generated\source\r\debug\com\blacktentdigital\warofsol\R.java
Error:(1251, 32) error: identifier expected
Error:(1251, 34) error: illegal start of type
Error:(1251, 35) error: identifier expected
Error:Execution failed for task ':app:compileDebugJava'.
Compilation failed; see the compiler error output for details.
>Information:BUILD FAILED
The problem is in the R.java file (as listed above). It is a generated file, so I've never touched it.
The offending line is this:
public static final class drawable {
public static final int 3=0x7f020000;
Hover over the offending line gives the following warning: "Identifier expected | Unexpected token"
Comparisons to other R files reveal that the "3" is not supposed to be a 3, and is evidently corrupted.
Attempts to replace the line or file with older backed-up versions have failed to produce any result because (evidently) the file is regenerating the wrong way each time I attempt the build, and I have no idea what might cause this. As I say, the problem sprang up suddenly without any provocation of which I am aware.
I've also attempted closing the program and restarting the computer to no avail.
Any ideas as to what might cause this and how it might be fixed?

I did get the Same error when i have defined a String in xml file like this.
<string name="3">Settings</string>
Error:
Error:(1426, 32) error: <identifier> expected
Error:(1426, 34) error: illegal start of type
Error:(1426, 35) error: <identifier> expected
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Solution: Resource name must begin with character.
So i have just change String like <string name="S3">Settings</string> and it worked.
So just check if you have any resource name 3 in all your resource file(string.xml, style.xml, attrs.xml) and folder(drawable, layout).

This is a quote from java documentation:
A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_".
And you named drawable with digit, that caused the problem.

Related

Error in generating Java Wrapper in Web3j

I am trying to generate java Wrapper for a smart contract, but it failed because of this error:
Exception in thread "main" java.lang.IllegalArgumentException: not a valid name: Main.sol:main
at com.squareup.javapoet.Util.checkArgument(Util.java:64)
at com.squareup.javapoet.TypeSpec$Builder.<init>(TypeSpec.java:383)
at com.squareup.javapoet.TypeSpec$Builder.<init>(TypeSpec.java:362)
at com.squareup.javapoet.TypeSpec.classBuilder(TypeSpec.java:90)
at org.web3j.codegen.SolidityFunctionWrapper.createClassBuilder(SolidityFunctionWrapper.java:172)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:103)
at org.web3j.codegen.SolidityFunctionWrapper.generateJavaFiles(SolidityFunctionWrapper.java:91)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.generate(SolidityFunctionWrapperGenerator.java:123)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.main(SolidityFunctionWrapperGenerator.java:87)
at org.web3j.codegen.SolidityFunctionWrapperGenerator.run(SolidityFunctionWrapperGenerator.java:48)
at org.web3j.console.Runner.main(Runner.java:38)
I followed what this guy said to remove this error
https://github.com/web3j/web3j/issues/16]
and give a default name (letters alphabetically) for each empty property as the following:
[{"constant":true,"inputs":
[{"name”:”a”,”type":"bytes32"}],"name":"ApprovedTAs","outputs":
[{"name":"Trade_id","type":"bytes32"},{"name":"Trade_producer","type":"address"},{"name":"Trade_consumer","type":"address"},{"name":"Trade_rate","type":"uint256"},{"name":"Trade_from","type":"uint256"},{"name":"Trade_to","type":"uint256"},{"name":"Trade_broker","type":"address"},{"name":"Trade_topic","type":"uint256"},{"name":"approvedByA","type":"bool"},{"name":"approvedByB","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”b”,”type":"address"},{"name”:”c”,”type":"uint256"}],"name":"offersByProducer","outputs":[{"name":"offer_id","type":"uint256"},{"name":"offer_producer","type":"address"},{"name":"offer_topic","type":"uint256"},{"name":"offer_rate","type":"uint256"},{"name":"offer_from","type":"uint256"},{"name":"offer_to","type":"uint256"},{"name":"offer_broker","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getAll","outputs":[{"name”:”d”,”type":"address[]"},{"name”:”e”,”type":"address[]"},{"name”:”f”,”type":"address[]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"mk_producer","type":"address"},{"name":"mk_topic","type":"uint256"},{"name":"mk_rate","type":"uint256"},{"name":"mk_from","type":"uint256"},{"name":"mk_to","type":"uint256"},{"name":"mk_broker","type":"address"}],"name":"mkOrder","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”g”,”type":"uint256"}],"name":"offers","outputs":[{"name":"offer_id","type":"uint256"},{"name":"offer_producer","type":"address"},{"name":"offer_topic","type":"uint256"},{"name":"offer_rate","type":"uint256"},{"name":"offer_from","type":"uint256"},{"name":"offer_to","type":"uint256"},{"name":"offer_broker","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"ofr_topic","type":"uint256"},{"name":"ofr_rate","type":"uint256"},{"name":"ofr_from","type":"uint256"},{"name":"ofr_to","type":"uint256"},{"name":"ofr_broker","type":"address"}],"name":"offer","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”h”,”type":"uint256"},{"name”:”ii”,”type":"uint256"}],"name":"allAdd","outputs":[{"name”:”j”,”type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sndC_id","type":"bytes32"},{"name":"sndC_producer","type":"address"},{"name":"sndC_broker","type":"address"},{"name":"sndC_topic","type":"uint256"},{"name":"sndC_from","type":"uint256"},{"name":"sndC_to","type":"uint256"},{"name":"sndC_count","type":"uint256"}],"name":"sendCCube","outputs":[{"name”:”l”,”type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"id","type":"bytes32"}],"name":"agreeTA","outputs":[{"name”:”m”,”type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sndP_id","type":"bytes32"},{"name":"sndP_broker","type":"address"},{"name":"sndP_topic","type":"uint256"},{"name":"sndP_from","type":"uint256"},{"name":"sndP_to","type":"uint256"},{"name":"sndP_count","type":"uint256"}],"name":"sendPCube","outputs":[{"name”:”n”,”type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name”:”o”,”type":"bytes32"}],"name":"CreatedTAs","outputs":[{"name":"Trade_id","type":"bytes32"},{"name":"Trade_producer","type":"address"},{"name":"Trade_consumer","type":"address"},{"name":"Trade_rate","type":"uint256"},{"name":"Trade_from","type":"uint256"},{"name":"Trade_to","type":"uint256"},{"name":"Trade_broker","type":"address"},{"name":"Trade_topic","type":"uint256"},{"name":"approvedByA","type":"bool"},{"name":"approvedByB","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"nkname","type":"string"},{"name":"code","type":"uint256"}],"name":"register","outputs": [{"name”:”p”,”type":"bool"}],"payable":false,"type":"function"}]
But the error still the same. I also changed the name of the contract rather than "main" but nothing change.
I also changed every variable name has numbers, special characters or even starting with _ but still doesn't work.
Any idea what I should change to solve this error
Thanks
This error is triggered if you are declaring a function o event with only the argument type without a name.for example :
event myevent(string)
should be
event myevent(string message);

Running an Imported android project

I have a problem with running an imported android project. In fact, when i run it i get an error from BuildConfig.java ( this file is not editable) the error is
"Error:(18, 69) error: illegal escape character".
and this is the line that the error is pointing to:
public static final String[] TRANSLATION_ARRAY = new String[]{"C:\gpslogger\gpslogger\src\main\res\values","C:\gpslogger\gpslogger\src\main\res\af","C:\gpslogger\gpslogger\src\main\res\ar","C:\gpslogger\gpslogger\src\main\res\ca","C:\gpslogger\gpslogger\src\main\res\cs","C:\gpslogger\gpslogger\src\main\res\cy","C:\gpslogger\gpslogger\src\main\res\da","C:\gpslogger\gpslogger\src\main\res\de","C:\gpslogger\gpslogger\src\main\res\el","C:\gpslogger\gpslogger\src\main\res\es","C:\gpslogger\gpslogger\src\main\res\es-ES","C:\gpslogger\gpslogger\src\main\res\es-MX","C:\gpslogger\gpslogger\src\main\res\es-PE","C:\gpslogger\gpslogger\src\main\res\fa","C:\gpslogger\gpslogger\src\main\res\fi","C:\gpslogger\gpslogger\src\main\res\fr","C:\gpslogger\gpslogger\src\main\res\fr-CA","C:\gpslogger\gpslogger\src\main\res\gl","C:\gpslogger\gpslogger\src\main\res\he","C:\gpslogger\gpslogger\src\main\res\hi","C:\gpslogger\gpslogger\src\main\res\hr","C:\gpslogger\gpslogger\src\main\res\hu","C:\gpslogger\gpslogger\src\main\res\is","C:\gpslogger\gpslogger\src\main\res\it","C:\gpslogger\gpslogger\src\main\res\ja","C:\gpslogger\gpslogger\src\main\res\ko","C:\gpslogger\gpslogger\src\main\res\lt","C:\gpslogger\gpslogger\src\main\res\lv","C:\gpslogger\gpslogger\src\main\res\mk","C:\gpslogger\gpslogger\src\main\res\ms","C:\gpslogger\gpslogger\src\main\res\nl","C:\gpslogger\gpslogger\src\main\res\no","C:\gpslogger\gpslogger\src\main\res\pl","C:\gpslogger\gpslogger\src\main\res\pt","C:\gpslogger\gpslogger\src\main\res\pt-BR","C:\gpslogger\gpslogger\src\main\res\pt-PT","C:\gpslogger\gpslogger\src\main\res\ro","C:\gpslogger\gpslogger\src\main\res\ru","C:\gpslogger\gpslogger\src\main\res\sk","C:\gpslogger\gpslogger\src\main\res\sl","C:\gpslogger\gpslogger\src\main\res\sr","C:\gpslogger\gpslogger\src\main\res\sv","C:\gpslogger\gpslogger\src\main\res\sv-SE","C:\gpslogger\gpslogger\src\main\res\ta","C:\gpslogger\gpslogger\src\main\res\th","C:\gpslogger\gpslogger\src\main\res\tl","C:\gpslogger\gpslogger\src\main\res\tr","C:\gpslogger\gpslogger\src\main\res\uk","C:\gpslogger\gpslogger\src\main\res\vi","C:\gpslogger\gpslogger\src\main\res\zh","C:\gpslogger\gpslogger\src\main\res\zh-CN","C:\gpslogger\gpslogger\src\main\res\zh-TW"};
\g is an illegal escape character in "C:\gps..."
All windows path strings need to have \\, for example "C:\\"
You should find the file that is editable and correct those strings
P.S. the (18, 69) in the error means line 18, column 69 of the file.

synonyms() error in wordnet

I want to use synonyms () described in 'Intro to the tm package' for R. It uses the wordnet package. The wordnet package downloaded from CRAN does not have Dict (dictionary) in its directory. I downloaded it from the Princeton site and copied it over to the directory. After using sys.setenv() and setDict() for setting paths, I still get this error:
Error in sort(unique(unlist(lapply(synsets, getWord))))
error in evaluating the argument 'x' in selecting a method for function 'sort': Error in unique(unlist(lapply(synsets, getWord))) :
error in evaluating the argument 'x' in selecting a method for function 'unique': Error in .jcall(synset, "Ljava/util/List;", "getWord") :
java.lang.NumberFormatException: For input string: "t"
when I try synonyms("company", pos = "NOUN") or another English word in place of 'company'. The problem is in getSynonyms() called from synonyms(). Any idea on how to fix this problem?
Different combinations lead to different input string NumberFormatException. My Java is version 1.8. I tried all the online resources. I added two paths to PATH for R's bin and RJava's jri. Discussion on the exception indicates it is a string to numeric conversion issue. I have made sure that Java to R linkage (via rJava) works (URL: https://www.rforge.net/rJava/ ).

Android - Error retrieving parent for item: No resource found that matches the given name

This issue has been covered before, but none of the solutions I looked at worked for me. I used apktool to decompile an APK I created a while back, but didn't have the code for. At first I was getting issues I found out were a result of not having a support library, so I set that up, then almost every single line of code in attrs.xml. A solution I found for that told me to just rename the name that had been assigned to it, so I did that, and the errors were gone. Now I'm getting these errors every time I try to run my project, despite no errors being highlighted in any of the files:
[2014-08-26 11:49:10 - CoolSketch] C:\Users\MyName\Desktop\Eclipse\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat\res\values\styles_base.xml:261: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Base.DropDownItem'.
[2014-08-26 11:49:10 - CoolSketch] C:\Users\MyName\Desktop\Eclipse\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat\res\values\styles_base.xml:323: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.Base'.
[2014-08-26 11:49:10 - CoolSketch] C:\Users\MyName\Desktop\Eclipse\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat\res\values\styles_base.xml:347: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Base'.
[2014-08-26 11:49:10 - CoolSketch] C:\Users\MyName\Desktop\Eclipse\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat\res\values\themes_base.xml:189: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Base'.
[2014-08-26 11:49:10 - CoolSketch] C:\Users\MyName\Desktop\apktool\CoolSketch\res\values-v14\styles.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat'.
I believe I set the appcompat support library up wrong, although the only thing I changed was the build target, although I changed that back after errors arose, figuring it would be best to change it later if needed. Any ideas on what the issue/s is/are?

Viewing a Compiler error output

I am new to Netbeans and I am given a simple exercise by my professor to find the compiler errors in a given program. This is a simple hello world program but all I get is
Compiling 1 source file to D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\build\compiled
D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\src\myfirstmidlet\MyFirstMIDlet.java:12: error: ';' expected
form.addCommand(exit)
1 error
D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\nbproject\build-impl.xml:359: Compile failed; **see the compiler error output for details.**
BUILD FAILED (total time: 0 seconds)
So I want to know where I can find the details of the compiler errors as I have to include those in my assignment. Thank you
The compile error is the first bit of the error message:
D:\UCC\CS6312-Mobile Devices and Systems\Lab\MyFirstMIDlet\src\myfirstmidlet\MyFirstMIDlet.java:12: error: ';' expected
form.addCommand(exit)
This could mean exactly what it says, and that you're missing a semicolon on this line, but doesn't necessarily - it might be something else that's wrong that's causing the compiler to produce that error. You may also run into the case where you fix that error then have to fix some others that come up afterwards - such is the nature of compilers!

Categories

Resources