when I start a new activity in android studio java can't recognize the xml file.
for instance, the java file: register.java
setContentView(R.layout.activity_register)
error shown on activity_register , which said that JVM can't find its corresponding file
I tried to produce java file and xml file separately, but had no luck
the name of xml file is correct, i think.
Please help me how to solve the problem,
thanks!
File -> Invalidate Caches / Restart... -> Select Invalidate and Restart
Related
please help me, when i create a new project in android studio there is an error
Could not load wrapper properties from Could not load wrapper properties from 'C:\Users\baren\AndroidStudioProjects\ToyaGarage\gradle\wrapper\gradle-wrapper.properties'.
1
enter image description here
In my case, I have a blank space at the end of "distributionUrl" row
I Searched for your problem and i found this,maybe this solution can help you https://stackoverflow.com/a/64439711/15805169
Delete the wrapper properties file in your app that is having the problem and copy the wrapper property file from your working apps to the same place where you deleted that file.
this is like the basic path to get to that file
C:\Users\TT Virtual\AndroidStudioProjects\KotlinFirebaseAuth\gradle\wrapper
remember this here is my path to that file
In vs code I hit Ctr+N and then Ctr+Shift+S,which is the sortcut for the 'save as' option . When I try to save a file as .java , it saved automatically as class file.Of course this also happens when I try to save the file without using the sortucts,so the only way to create a java file is after the creation of a txt file. Did anyone ever had the same problem with me ? thank you all in advance .
Do you act like this?
New a file -> Save -> In the 'Save as type' drop-down list select 'Java'.
If you look at it, you will find this: Java(*.class; *.java; *.jav; .java; .jav). And the '.class' was before the '.java', this means the file will be saved with the '.class' filename extension.
It's caused by the VSCode, but for now, you need manually to change the filename extension when you save the file.
I am trying to build my Android project in Eclipse and this error is popping up in my console:
W/ResourceType( 265): Unknown XML block: header type 0 in node at 413
This is causing my R.java to not generate. I have absolutely no idea what this means. It's not even telling me which file is causing the error. This is quite a large project with many XML files and I've looked through every single one and they all seem to be okay. Can anyone shed some light on this?
Any help would be greatly appreciated.
R.java includes all Ids, layouts.. If there is any problem like formating error in id name or any other error of layout. then R.java file will not be generated & your java class file will show you error. so first check your xml file
There might be the possibility that you have put your xml file in the wrong folder under res dir. Like if you are trying to access <wallpaper> tag in Android xml file you must put it in res/xml directory otherwise it will show error.
You can try following options::
close other projects.
clean your project.
check in the source files(java classes), if there import android.R.* is present , remove that.
check in your res folder, if it is showing error in any folders like drawable, layout, values.
5.correct if you get errors.
R.java is not coming because it is not getting id of any/more resource/resources.
this will solve your problem. thanks
Your error may come from incorrect line ending. You should check this Link. Hope this help.
I am using net beans IDE for development and keeping all my xml files under the folder XML(created under Web Pages folder) ..
I am using the following code to read the xml file .
File file = new File("XML/TableNamesAndColumnNames.xml");
but it is giving file not found exception ..
Can any one suggest how to read the file
Thanks in Advance
Raj
Probably the path you are specifying is not the correct one. Find out what you application's working directory is. Run this:
System.out.println(new File(".").getAbsolutePath());
And then adjust from there accordingly.
This is a very simple question for many of you reading this, but it's quite new for me.
Here is a screenshot for my eclipse
When i run this program i get java.io.FileNotFoundException: queries.xml (The system cannot find the file specified) i tried ../../../queries.xml but that is also not working. I really don't understand when to use ../ because it means go 1 step back in dir, and in some cases it works, can anyone explain this? Also how can I refer to queries.xml here. Thanks
Note: I might even use this code on a linux box
I assume it is compiling your code into a build or classes folder, and running it from there...
Have you tried the traditional Java way for doing this:
def query = new XmlSlurper().parse( GroovySlurping.class.getResourceAsStream( '/queries.xml' ) )
Assuming the build step is copying the xml into the build folder, I believe that should work
I don't use Eclipse though, so can't be 100% sure...
Try
file = new File("src/org/ars/groovy/queries.xml");
To check the actual working directory of eclipse you can use
File f = new File(".");
System.out.println(f.getAbsolutePath());
You could try using a property file to store the path of the xml files.
This way you can place the xml files in any location, and simply change the property file.
This will not require a change/recompilation of code.
This would mean you will only need to hardcode the path of the property file.
If you prefer not hardcoding the path of the property file, then you could pass it as an argument during startup in your server setup file. (in tomcat web.xml). Every server will have an equivalent setup file where you could specify the path of the property file.
Alternatively you could specify the path of the xml in this same file, if you don't want to use property files.
This link will show you an example of reading from property files.
http://www.zparacha.com/how-to-read-properties-file-in-java/