Question

I just created a new activity (project-> new-> android activity) and I get an error where the R file, which does not recognize the layout created by the activity. I use Ubuntu 13.10 (64 bits)

public class OrderKaraokeActivity extends SherlockActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_karaoke);
    }
}

activity_order_karaoke:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".OrderKaraokeActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

enter image description here

Console: Description Resource Path Location Type activity_order_karaoke cannot be resolved or is not a field OrderKaraokeActivity.java /src/com/example/adicionalesprueba line 18 Java Problem

Import:

enter image description here

Console problem:

enter image description here

Was it helpful?

Solution

remove the following

import com.twable.R;
import com.twable.R.layout;
import com.twable.R.menu;

and include import com.example.adicionalesprueba.R

----

Check your package explorer (the left pane of eclipse), open the gen folder of your project, open the package of your project, You should see a R.java file. If you do not, you're R file is not being generated. Try to clean your project, Project --> Clean. If the file is still not there, then you're R file is not being built. This can happen for many reasons. A very common one is that one of your XML files is not properly structured

enter image description here

OTHER TIPS

Check your imports. Remove import android.R if it's generated there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top