0

I have a launcher for people with bad eyesight and a simple music player, this is my second APP so bear in mind I'm a complete noob in android and eclipse.

I tried to merge both my launcher and music player. I added the activity to the manifiest with a different intent, copied layouts and drawables to the launcher project and I added the player's package inside my /src folder.

Afterwards on the first lines of com.easyplayer.java I got this error:

import com.easyplayer.R;   // the import com.easyplayer.R cannot be resolved

This is the only bug I'm getting so I suppose I did everything else fine. I imagine R must reference the player's layout, but I'm not sure how to fix it (cleaning/rebuilding doesn't work). What is the R class? And what can I do to fix this?

lisovaccaro
  • 32,502
  • 98
  • 258
  • 410

2 Answers2

1

The R class you see is auto-generated by Android. It is a utility class that contains references to all the resources in your project. There is a few answers detailing its contents here.

You mentioned you performed a clean of your project, but you need to do a full build as well to regenerate this file.

edit: The import of the new code may have somehow invalidated your xml files. Check to see if there are any errors there, which could be preventing the R file from being re-created during a build.

Community
  • 1
  • 1
Ben Siver
  • 2,758
  • 1
  • 25
  • 42
  • project > clean > clean all projects > (x) start a build automactically > accept. ? that's what I am doing. I tried android tools > fix project properties. How do I regenerate the file? – lisovaccaro Jan 04 '13 at 22:03
  • the only error (found by eclipse) is inside /src/com.easyplayer/mainactivity.java on the line mentioned, there are others afterwards on the same file that steam from this one – lisovaccaro Jan 04 '13 at 22:04
  • What happens when you remove the import? – Ben Siver Jan 04 '13 at 22:09
1

if you have several packages like, com.example.app.package1 and com.example.app.package2, then import the R.java file like,

import com.example.app.R;

And if you already have import android.R; then please delete that and save the file and clean the project, problem will be solve...:)

gotwo
  • 663
  • 8
  • 16
Vishesh Chandra
  • 6,951
  • 6
  • 35
  • 38