I need to start an activity in my titanium module.Then I have to setContent of my Layout in my pure java code, But I cannot locate the layout file in Titanium module.
I used below code but i get error that file not found.
int id = TiRHelper.getApplicationResource("layout.activity_main");
If i put my layout files inside "platform/android/res" i get error,any idea to help me?
invalid resource directory name:
[ERROR] Error generating R.java from manifest
Regards
Might have nothing to do with it but I once ran across this problem and solved by putting the application id in the com.company.app format
If your XML's contain errors your generated file might not build try erasing most of their content and making sure id's and file names are not duplicated and no capitals and spaces are used. If it works you can start adding stuff.
(or)
You're importing invalid R class I Think,
import yourpackage.R class
for example
com.example.R
what actully happends that u import android.R class not yourpackages.R
Related
Hey,
I've been trying for hours to add this to my project to make a fuel gauge.
I've been doing everything as it is shown in the instructions. But I happen to encounter some problems that I can't resolve.
I've pasted the .java file as instructed evidence but I get 2 problems here. First the "gradle" folder is highlighted in red and the .java file in question has a red J in its icon. I've tried to search how to solve those but nothing works for me.
I don't know if the next problem is because of the previous ones but when I try to add xmlns:app="http://schemas.android.com/apk/res/com.devadvance.circulartest"
in the parent view in xml file i get the error to use xmlns:app="http://schemas.android.com/apk/res-auto" to "automatically" search for the custom view but it doesn't work. So I can't import the .java in the activity(its like its not there") and I can't use it in the layout file.
Please help I've tried searching on SO but I could't find anything to work for me.
Beginner android dev here :)
Thanks in advance.
I have tried to use your given customseekbar in a basic hello world app. It works perfectly fine for me.
I see you've put the com/devadvance/circulerseekbar/circularseekbar.java in the src folder instead of main/java. So it should be in src/main/java/com/devadvance/circulerseekbar/circularseekbar.java.
Also I found out that you don't really need to add the namespace xmlns:app="http://schemas.android.com/apk/res/com.devadvance.circulartest instead the default namespace of xmlns:app="http://schemas.android.com/apk/res-auto in the xml file should be fine.
Finally, don't forget to add import com.myapplication.R; in the customseekbar class to use your resource class R in the customseekbar class.
Hope it helps, otherwise let me know!
My code has gotten quite large and so I've decided to build a runnable JAR to see how it's done. I probably should've tried sooner because I'm getting 2 different errors related to the project structure, first is the "no main manifest attribute error" when trying to run the JAR from command prompt. Double-clicking the JAR does nothing (Win7). The second issue is related to the FXMLLoader explained lower down.
I followed the steps here to build the JAR, which involved moving all Maven files into the JAR directory. The compiled JAR gave me the manifest error, so I followed this which adds a Maven plugin in my pom.xml file. The error might be caused by a wrong naming convention with the line <mainClass>com.primary.Drag</mainClass> where primary is the package and Drag is my Drag.java file (class) which has the main method.
Inititally I was using the default package but read that this is not recommended for larger projects, so I put all my files into "primary". Here is my current hierarchy as shown in IntelliJ:
The problem is that ever since I created the "primary" package, I can no longer even compile the program via IntelliJ, let alone build a runnable JAR. This is due by the second error I mentioned, which is java.lang.IllegalStateException: Location is not set. on this line within primary/Drag.java:
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("firstlaunch.fxml")); It used to work with the default package, but not anymore.
I tried replacing firstlaunch.fxml with /primary/firstlaunch.fxml and /resources/firstlaunch.fxml (with and without moving resources into primary package) but no luck.
3 Related Questions:
Is my project structure incorrect?
How do I reference the fxml file from the primary package?
Is this what I should write in Maven's mainClass tags? <mainClass>com.primary.Drag</mainClass>
Is my project structure incorrect?
Answer:
Your package name should be like com.primary.******
How do I reference the fxml file from theprimary package?
Answer:
Always make sure that you are trying to load firstlaunch .xml from the class which is located in same package where that xml is kept. Means class which you wrote the loading code and xml file should be in same package
Is this what I should write in Maven's mainClass tags?com.primary.Drag
Answer:
If you package name corrected to com.primary , your main class Drag will correctly added by maven
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 trying to play sound effects in a application. Everywhere I look, I am being told to add a raw folder in the res directory(working in eclipse).
First, I add the raw folder under res. Then I put my .wav files inside. When I try to use R.raw.filename in my code, I get an error "raw cannot be resolved". So I clean and rebuild the project. Suddenly, everywhere that I used R.id or R.anything is underlined as an error. When I looked up the error, it turns out that it had something to do with Android.R. Nothing I did could fix it. So I removed the raw folder and rebuilt the project. All of a sudden, everything is fine.
I've repeated this process about 4 times and I have no idea why it's such a pain to add the raw folder. Can anyone tell me what I'm doing wrong?
Do any of your .wav files contains invalid characters in their name? Check if maybe the following messages are shown somewhere in your build:
Unparsed aapt error(s)! Check the console for output.
and
Invalid file name: must contain only [a-z0-9_.]
Only lowercase characters, digits, underscore and period are valid for the names plus extensions.
Use assets folder and ...
InputStream sound = getAssets().open("filename.mp3");
... or raw folder and ...
InputStream sound = getResources().openRawResource(R.raw.filename);
Just make sure that the file called filename exists in the directory called raw.
If all uses of R.* are underlined, delete the import android.R in the upper part of your class as Maxim mentioned.
Apparently your activity added import android.R, after that all references with R goes to android framework (android.jar) which doesn't know anything about your raw files. Just check imports and if you see android.R, delete it and add com.my_app_namespace.R Should work after that
I am not sure if this counts as a solution, but when I used .ogg files instead of .wav files, everything worked perfectly.
I am having trouble with my R file, I was able to get it running again but then i seem to have another issue. Nothing seems to be generating after all the work I put into it. I think my problem is coming from the fact that my src cannot see the xml files and I don't know why. My find_bluetooth_devices is underlined in red squiggles and says it cannot be resolved or is not a field. However, I know for sure that I have created a xml file that included everything for it to work. I feel as though the xml file is not being seen by the src as it should be. Does anyone know what I can do in order for the src file to see my xml file?
setContentView(R.layout.find_bluetooth_devices);
Make sure your import statement is for the correct R file. You could have mistakenly imported android.R instead of your projects R file.
Here, read through this and the next one and see if you can solve the problem:
Also, make sure you dont have import android.R at the top.
Where did my R file go?
Try cleaning the project
Project>Clean
There are two things that can cause that:
There's a syntax error in one of your XML files, this causes the R file to not be generated.
The R file is not included in your class, make sure you import com.yourproject.R in the class.
Clean your project
the project will rebuild and R.java generated
Change the compiler the project will rebuild and R.java generated
Create New Project and copy all java file and resources into new project