• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps :( R.layout.main cannot be resolved :(

ceoceo39

Lurker
Dec 22, 2008
2
1
Hi, I'm beginner with Android.

The first simple code is a fault. I don't know how to fix it.

fault1.jpg



Have anybody help me please???
 
  • Like
Reactions: geohussain1989
Even i got the same error.
R can not be resolved.
kindly post a reply for this
I got the same error. I added & removed the
Code:
import android.R;
to no effect. :( Then I compiled anyways ... and the error disappeared! :) But the red ! doesn't go away. Here's the build output:
Code:
[COLOR=DimGray]clean:[/COLOR]
Deleting directory /home/chris/Projects/Java/FirstAndroid/bin
Deleting directory /home/chris/Projects/Java/FirstAndroid/gen
[COLOR=DarkRed]Creating output directories if needed...[/COLOR]
Created dir: /home/chris/Projects/Java/FirstAndroid/bin
Created dir: /home/chris/Projects/Java/FirstAndroid/gen
Created dir: /home/chris/Projects/Java/FirstAndroid/bin/classes
[COLOR=DarkRed]Compiling aidl files into Java classes...
Compiling RenderScript files into Java classes and RenderScript bytecode...
Generating R.java / Manifest.java from the resources...[/COLOR]
[COLOR=DimGray]compile:[/COLOR]
[COLOR=Blue][U]/home/chris/Projects/android-sdk-linux_x86/tools/ant/main_rules.xml:384[/U][/COLOR]: [COLOR=DarkRed]warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds[/COLOR]
Compiling 2 source files to /home/chris/Projects/Java/FirstAndroid/bin/classes
[COLOR=DarkRed]Converting compiled files and external libraries into /home/chris/Projects/Java/FirstAndroid/bin/classes.dex...
Packaging resources[/COLOR]
Creating full resource package...
Creating FirstAndroid-debug-unaligned.apk and signing it with a debug key...
debug:
[COLOR=DarkRed]Running zip align on final apk...
Debug Package: /home/chris/Projects/Java/FirstAndroid/bin/FirstAndroid-debug.apk[/COLOR]
[COLOR=Green]BUILD SUCCESSFUL (total time: 3 seconds)[/COLOR]
Note: this is the basic, un-modified sample app that comes up in NetBeans for an Android App.
 
Upvote 0
Even i got same Error but i rebuild the r.java also but no use getting same error
this is my Sudoku.java
if i remove android.R i get error at each button element in the below phrase.
package com.wipro.sudokuActivity;

import android.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;;
public class Sudoku extends Activity implements OnClickListener
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/** set up click listeners for all buttons */

View continueButton = this.findViewById(R.id.button1);
continueButton.setOnClickListener(this);
View newButton = this.findViewById(R.id.button2);
newButton.setOnClickListener(this);
View instructionButton = this.findViewById(R.id.button3);
instructionButton.setOnClickListener(this);
View exitButton = this.findViewById(R.id.button1);
exitButton.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.button3:
Intent i = new Intent(this, Instructions.class);
startActivity(i);
break;
}

}
}





this is Instructions.java file
here also r.layout .main cant be resolved ..
by aim is to create a button .when user clicks on dat button it should give description of that game....

package com.wipro.sudokuActivity;
//import android.R;
import android.app.Activity;
import android.os.Bundle;

public class Instructions extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.instructions);
}

}


this is my main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:eek:rientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:gravity="center"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/Main_Title"
android:textSize="15pt"
android:layout_marginBottom="25dip"
/>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/first"
/>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/second"
/>
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/third"
/>
<Button

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/fourth"
android:id="button1"/>
</LinearLayout>


this is my instuctions .xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:padding="10dip">
<TextView android:id="@+id/instructions_content"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="@string/Instructions_text" />
</ScrollView>



please let me know as early as possible ...i appreciate your reply
 
Upvote 0
>>R.layout.main cannot be resolved

This problem still exist's even today I am trying to get this code to compile a straight HelloWorld application, based on a blank new project from Eclipse 'Kepler'(I think).

I have read through your replies and it would seam as if i am missing a file, or an import option. I have added the import option but have had no luck with it the compiling stage still fail's on the R.layout.main

If I am simply missing a file how do I generate the file' and whats in said file.

A Blast from the past hopefully we can answer this for others this is my first post so HI and go easy.:mad:
 
Upvote 0
these are pretty common and have a couple fixes

1. Your layout is incorrect. Check all your XML files AGAIN AND AGAIN. you might think they are fine but they might not be so keep checking.
2. make sure you're not importing android.R
3. check your Jar dependencies. you may have an MD5 mismatch throwing it off.
4. Try rebuilding your project
5. Try cleaning your project
6. Try closing out of eclipse and reopening it.

One of these will prob fix it. If not, try them again
 
Upvote 0
Hi, I'm beginner with Android.

The first simple code is a fault. I don't know how to fix it.

fault1.jpg



Have anybody help me please???
I found solution :)))
Please follow me:
Project->Properties->Android->Project Build Target (choose Android Open Source Project 4.4 or higher version I choosed 5.1.1 )
Next
Project->Built all (Ctrl + B)

Please test it.
 

Attachments

  • Problem solving 1.jpg
    Problem solving 1.jpg
    178 KB · Views: 741
  • Problem solving 2.jpg
    Problem solving 2.jpg
    162.6 KB · Views: 553
  • Problem solving 3.jpg
    Problem solving 3.jpg
    57.8 KB · Views: 457
  • Problem solving and running.jpg
    Problem solving and running.jpg
    303 KB · Views: 571
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones