Tuesday, May 14, 2013

[android help] R file is missing android


I had this same issue today and figured it out. The reason this happens so often when including external/example files is because often times these examples reference layouts in your application, but do not have access to the package and therefore cannot see the R.java file in that package. to make things clear, here's the beginning of the R.java file:



/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package com.conceptualsystems.dashboard;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int csc_logo=0x7f020000;
public static final int icon=0x7f020001;
}
public static final class id {
public static final int activation_code=0x7f070012;
public static final int alpha_bar=0x7f07000b;
public static final int alpha_label=0x7f07000a;


notice the package name is whatever the package name of your application is. .java files that are not included in this package (ie, your example code you just dropped in) will need to explicitly reference that package file like this:



package com.example.android.apis.graphics;

import android.app.Dialog;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.SeekBar;
import com.conceptualsystems.dashboard.R;


the last line is the one to pay attention to. after importing the resources explicitly, the resources will be available in your example code.



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...