Re: [android-developers] Re: R cannot be resolved to a variable error in intro example code
What API are you building against? Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Thu, Mar 22, 2012 at 11:20 AM, firebreather michaelirvingbr...@gmail.com wrote: this is the MainActivity.java file in the Hello Android example code: package com.dummies.android.helloandroid; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } this is the error messages it generates: Description ResourcePathLocationType R cannot be resolved to a variable SilentmodetoggleActivity.java / silent mode toggle/src/com/dummies/android/silentmodetoggle line 11 Java Problem Description ResourcePathLocationType The method onAccuracyChanged(Sensor, int) of type AccelerometerPlayActivity.SimulationView must override a superclass method AccelerometerPlayActivity.java /AccelerometerPlayActivity/src/ com/example/android/accelerometerplay line 457Java Problem Description ResourcePathLocationType The method onSensorChanged(SensorEvent) of type AccelerometerPlayActivity.SimulationView must override a superclass method AccelerometerPlayActivity.java /AccelerometerPlayActivity/src/ com/example/android/accelerometerplay line 378Java Problem -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: R cannot be resolved to a variable error in intro example code
yes, the res/layout/main.xml file in the hello world example code in the android adt reads as follows in eclipse for me: ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/hello / /LinearLayout michael brown On Mar 22, 12:02 pm, Justin Anderson magouyaw...@gmail.com wrote: Do you have a file called res/layout/main.xml in your project? Thanks, Justin Anderson MagouyaWare Developerhttp://sites.google.com/site/magouyaware On Thu, Mar 22, 2012 at 11:00 AM, firebreather michaelirvingbr...@gmail.com wrote: when i try to run the intro example hello world code i get the error message R cannot be resolved to a variable, for the setContentView(R.layout.main) line of the intro code. since this bug is the the android adt's own intro example code everyone would encounter this error starting out, and when i do i google search of R cannot be resolved to a variable error i get 61,600,000 results of newbies running into the same bug as me starting out. there havent been many anwers though. one suggestion was: While going through the Android sample tutorials, I would often use the Ctrl + Shift + O command to Organize Imports and generate any missing import statements. Sometimes this would generate the incorrect import statement which would hide the R.java class that is automatically generated when you build. typing Ctrl + Shift + O does indeed make a hidden import android.R; command suddenly appear in the example hello world code. however, just commenting this out doesnt solve anything, it still gives the R cannot be resolved to a variable message and wont compile. typing Ctrl + Shift + O again just makes the hidden import android.R; message appear again. youd think since this is there own hello world example code they'd have this bug fixed or addressed. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: R cannot be resolved to a variable error in intro example code
this is the MainActivity.java file in the Hello Android example code: package com.dummies.android.helloandroid; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } this is the error messages it generates: Description ResourcePathLocationType R cannot be resolved to a variable SilentmodetoggleActivity.java / silent mode toggle/src/com/dummies/android/silentmodetoggle line 11 Java Problem Description ResourcePathLocationType The method onAccuracyChanged(Sensor, int) of type AccelerometerPlayActivity.SimulationView must override a superclass method AccelerometerPlayActivity.java /AccelerometerPlayActivity/src/ com/example/android/accelerometerplay line 457Java Problem Description ResourcePathLocationType The method onSensorChanged(SensorEvent) of type AccelerometerPlayActivity.SimulationView must override a superclass method AccelerometerPlayActivity.java /AccelerometerPlayActivity/src/ com/example/android/accelerometerplay line 378Java Problem -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: R cannot be resolved to a variable error in intro example code
i got an email which solved the first R cannot be resolved to a variable from Chuck Krutsinger, who has been very patient with this newbie: The import you refer to is not technically a bug. The compiler is looking for a file named R, which it will find in the gen directory if your IDE has generated it. So, follow these steps: 1) On the Project menu, make sure Build Automatically is NOT checked. 2) Clean the project in question, making sure that the build checkbox is NOT checked. 3) Remove the import for R.java 4) On the Project menu, select Build Automatically. At this point, you should not need the import because the file R.java should have been generated and placed in the gen directory. If at this point you do a Ctrl-Shift-O it should not put that import back. If you leave the Build Automatically selected, you should not see this problem at all any more. doing the clean command while build automatically was Not checked seems to have fixed the first error, although i still have 2 more, thank you Chuck. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en