cannot resolve symbol R.raw - android

In the above screenshot you can clearly see that I have created a raw folder with two files but when I do R.raw it says "cannot resolve raw".
here's all of my import statements:
package com.raunak.alarmdemo4.Activities;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.arbelkilani.clock.Clock;
import com.ebanx.swipebtn.OnStateChangeListener;
import com.ebanx.swipebtn.SwipeButton;
import com.raunak.alarmdemo4.HelperClasses.AlarmsDBhelperClass;
import com.raunak.alarmdemo4.R;
import java.io.IOException;
import java.util.Calendar;
import static com.raunak.alarmdemo4.R.*;

Try cleaning your project and building again. If this not work :
Remove the import for the R.symbol, because probably you have imported R.class in your file, then click on the imported file and press ALT + Enter.
If this also doesn't work then access it like this : your.project.package.R.raw .file_name
Also try to remove the capital letter from the name of your audio.

Just make sure you have imported correct Resource
import your.package.name.R
not like or similar
import android.R
After that
Clean & build

Related

what is difference between import by package and import direct code in flutter

what is the difference between importing files by `package
import 'package:fileName/colorFile.dart';
and direct import
import 'fileName/colorFile.dart';

Function in Android Studio programs worked fine before, but then this problem shows up

I tried to check all the code I write, edit some of it and some are fixed, but this problem still unfixed.
i expect the program could run
Can not extract resource from com.android.aaptcompiler.ParsedResource#796f578a.,Can not extract resource from com.android.aaptcompiler.ParsedResource#7d50cc7f.,Can not extract resource from com.android.aaptcompiler.ParsedResource#38525db1.,Can not extract resource from com.android.aaptcompiler.ParsedResource#af0056b.
package com.example.inorasmart;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
}

why import static android.R.*; is Suppress: Add #SuppressLint("SuspiciousImport") annotation?

After updating android studio this error appeared to me even though it always worked !!
Suppress: Add #SuppressLint("SuspiciousImport") annotation
What I do not understand is why he never gave it to me before the update !!!
Below I am entering all my imports:
package com.dooale.dooale;
import android.Manifest.permission;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.nfc.Tag;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
import com.google.android.gms.maps.model.LatLng;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.StringTokenizer;
import static android.Manifest.permission.*;
import static android.R.*;
I can not understand
R is a generated class that contains IDs of resources. There's one for each of
your app project
each Android library you add (.aar)
Android framework
Typically you
import your.applicationId.R;
because R for your application also includes resource IDs of all libraries.
Resource IDs from the framework android.R are NOT part of your app's R class. They have to be referenced separately.
Because you can only import one class with name R and android.R is shorter than whatever.your.applicationId.is.R the convention is this:
import your app's R and reference it like e.g. R.layout.activity_main,
DON'T import Android R and reference it fully like e.g. android.R.id.home.

Why android.os.IServiceManager in Android not resolving

I am coding for DialerDemo, But import android.os.IServiceManager;import android.os.ServiceManagerNative; import android.telephony.IPhone; are not resolving
CODE:
package com.umesh.umeshfilereadwritedemo1;
import android.app.Activity;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.IServiceManager;
import android.os.ServiceManagerNative;
import android.telephony.IPhone;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class DialerDemo extends Activity
{
...
...
}
These are all internal classes of the SDK, and are not available publicly.
You cannot build source.android.com applications on their own. They can only be built as part of a firmware image. Please follow the instructions to build the entire firmware. While you can use Eclipse to edit the firmware source, you will still use make to build the firmware.

Regenerated R file, but not detecting previous view controls

I have regenerated my R file via cleaning the proejct but now the problem is more complex. All my previous view controls arnt detected. What should I do.
package newsapp.com;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import newsapp.com.PullToRefreshListView.OnRefreshListener;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import facebook.src.com.facebook.android.DialogError;
import facebook.src.com.facebook.android.Facebook;
import facebook.src.com.facebook.android.FacebookError;
import facebook.src.com.facebook.android.Facebook.DialogListener;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.webkit.URLUtil;
import android.webkit.WebView;
import android.widget.AbsListView;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ViewFlipper;
R.java is autogenerated on build. It's content is based on the resource files (including layouts and preferences).
When you deleted it, it was recreated, but if you create your own, you will get into trouble as the build system will not replace it.
You can simply delete it again (manually or by choosing Project->Clean) and rebuild your program.
Do Project->Clean and rebuild your program.
The problem "R cannot be resolved" happens when you change your package name in the AndroidManifest.xml file. It uses your Android package name to create a subdirectory under the "gen" directory where it stores the R.java file.
R is an automatically generated class that holds the constants used to identify your Resources. If you don't have an R.java file.I would recommend closing and reopening your project or going to >Project > Build all (and selecting "Build Automatically" )
ok....in android you cannot have icon and drawable resource with capital letters. So i was having an image as GreenBolt.png so which should have been greenbolt.png. You need to wait for 2 days before accepting your own answer. Thanks for helping out all of you.

Categories

Resources