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.
Related
what is the difference between importing files by `package
import 'package:fileName/colorFile.dart';
and direct import
import 'fileName/colorFile.dart';
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 {
}
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
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.
I am a beginner in android studio. I have read most of the errors with the 2nd argument type in FragmentTransaction.replace(int, Fragment) statement provided in the site. But none matched with the problem I face. I was trying to make a code where when somebody clicked the credit_button in the code, the credit_fragment would open.
When I try to run the code I get the following error
'replace(int, android.app.Fragment)' in 'android.app.FragmentTransaction' cannot be applied to '(int, com.example.rohit.test2.creditfragment)
The part of the code in MainActivity.java where the fragment is being called is
These are my import statements:
import android.app.Fragment;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.content.Intent;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
the import android.app.Fragment is shown as unused import statement
Does your creditfragment extends Fragment? Also there are android.app.Fragment and android.support.v4.app.Fragment, the way your code is implemented your creditfragment should extend android.app.Fragment, make sure you're importing that one on creditfragment class.