Having error messages in my new activity in my android app - android

I just created a new activity called "activity_direction" in my android app,but I discovered an error message in two lines of my new activity. First one is on setContentView(R.layout.activity_direction); of the onCreate() method.The error message says:
"activity_direction cannot be resolved to a type or is not a field".
The second error message is at getMenuInflater().inflate(R.menu.direction, menu); of the onCreateOptionsMenu() method.The error message also says:
"activity_direction cannot be resolved to a type or is not a field".

Select project from menu options in eclipse and click build project.
This issue mey occure when R.java file does could not create id for layout. if problem still remain, just restart your eclipse

Assuming that you have already created activity_direction.xml under res/layout directory and direction.xml under res/menu. Try this.
In Eclipse,
Select Project -> Clean
In Android Studio,
Select Build -> Clean Project

Related

Unhandled event loop exception while I try to add a second Activity

I'm new to Android app development. I'm using Eclipse v4.6 (Neon) for this. When I try to add a second Activity to my project, an error occurs which says:
Unhandled event LoopException occurred.
Other details of the error are:
The details of the log file are:
Unhandled event loop exception
java.lang.StackOverflowError
The details of the log file are:
Plug In: org.eclipse.ui
Severity: error
Exception Stack Trace:
java.lang.StackOverflowError
at org.eclipse.core.internal.filesystem.local.LocalFileNatives.internalGetFileInfoW(Native Method)
at org.eclipse.core.internal.filesystem.local.LocalFileNatives.fetchFileInfo(LocalFileNatives.java:113)
at org.eclipse.core.internal.filesystem.local.LocalFileHandler.fetchFileInfo(LocalFileHandler.java:27)
at org.eclipse.core.internal.filesystem.local.LocalFileNativesManager.fetchFileInfo(LocalFileNativesManager.java:62)
at org.eclipse.core.internal.filesystem.local.LocalFile.fetchInfo(LocalFile.java:159)
at org.eclipse.core.filesystem.provider.FileStore.fetchInfo(FileStore.java:258)
at org.eclipse.core.internal.localstore.FileSystemResourceManager.fastIsSynchronized(FileSystemResourceManager.java:463)
at org.eclipse.core.internal.localstore.FileSystemResourceManager.isSynchronized(FileSystemResourceManager.java:735)
at org.eclipse.core.internal.resources.Resource.isSynchronized(Resource.java:1446)
at org.eclipse.core.internal.resources.File.getContentDescription(File.java:257)
How do I fix these errors?
In Android Studio there is a AndroidManifest.xml file which all activities are registered in. Maybe you should register your activities in Eclipse as well.
Try to add an activity with your IDE tools, not by yourself. In Android Studio you can easily right click on the project folder → New → Android activity.
In Eclipse you can click on the new project button and choose Android Activity (below Android Application Project).

R.Java id error

can some help me here??
i am getting error in following line of code in R.java file
public static final int login_user-fb=0x7f0d00bf;
the identifier "-" is creating problem as you all know.
i have not declared this id anywhere in my project, i am using facebook sdk in my project since than it is giving error.
things i have done to rectify the error till now.
1.removed facebook sdk and rebuilt projct.
2.clean project
3.as you know i cannot edit R.java file, i tried doing everything but every time it is creating that code in my R.java file as whenever i run my project.
please help me out here.
Could you please check through your xml-files, and see that you have the correct naming convention for all your id's etc.
I am thinking of these type of naming errors:
android:id="#+id/text-view-example"
and rename them to:
android:id="#+id/text_view_example"
OR
Search in your project by right-clicking on 'app', in your left side panel (android-view), and click on 'Find in Path', and then type in that exact query, login_user-fb, and then replace them to login_user_fb.

Android Studio Mac new project errors after freshly created project

When I create a new project on android studio, I get the error. "URI is not registered" on my xmlns:android="http://schemas.android.com/apk/res/android" . I go to my event log, click configure, and the error goes away, yet I get errors in the "android:icon, label and theme" values under application along with the "android:name and label" attributes under activity in the AndroidManifest.xml.
Also, when trying to open my activity_main.xml layout files, I get the error
10:23:12 AM IllegalStateException: #NotNull method com/android/tools/idea/rendering/ManifestInfo.getActivityThemes must not return null
It works on the PC, but I am definitely missing something on the Mac. Thanks for all of the help!
Update to version 3.0 Canary build on Mac. Fixes all problems.

How to show compilation errors in android studio

I want to know how to show compilation errors in Android Studio. I tried the following one:
Android Studio: Where is the Compiler Error Output Window?
But it is showing another error:
javac: invalid target release: 1.8
Anybody who knows the actual solution please reply.
There is a 'Problems' view in the project window:
Just click on the drop down (Android setting is default) and select 'Problems'. Not comparable to eclipse problems view tough...
Using F2
In addition to what the other answers say, you can find errors by pressing F2 or Shift+F2. This is useful when you can't see the where the red indicator is on the side bar.
There's "Messages" tab in Android Studio. Complilation errors and warning go there. You can select it by pressing alt+0 (⌘+0 in OS X - a shortcut to View|Tool Windows|Messages).
I was looking for the "Problems" view that you can see in Eclipse when building projects. For that, you can go to Analyze -> Inspect Code
Where is the warnings view in Android Studio?
and then I clicked on "Group by Severity" so that I could see the warnings and errors.
In the toolbar, go to Analyze -> Inspect Code
After That, you will have the Inspection Results window with the detailed errors and warnings. see image:
Next / Previous highlighted error: F2/Shift + F2
Show descriptions of error at caret: Ctrl+F1

Content Provider Resources$NotFoundException

Created a profile using content provider. After running it correctly, added 3 fields to the table. But now its not working correctly.It shows an error like android.content.res.Resources$NotFoundException: String resource ID #0x4d2.Any solution?
If you are using Eclipse, try to do Project|Force Clean. If you are working outside of Eclipse, run ant clean. Your error message is probably because your resources, the generated R.java file, and some of your other compiled code are collectively out of sync.

Categories

Resources