why error is not going from R.java in android - android

public static final class id {
public static int Phone Number=0x7f050043;
error shows in a above link Phone Number=0x7f050043.
What could be the problem? I have already changed the XML id from #+id/Phone Number to #+id/phoneNumber.
I've done many things related with this like clean the project, delete gen folder, but the error persists. My project submission is tomorrow. Please help me find a Solution.
my XML file is
<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="com.example.pgfinder.Add_PG" >
<RelativeLayout
android:layout_width="400dp"
android:layout_height="470dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" >
<EditText
android:id="#+id/gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/house"
android:layout_below="#+id/house"
android:layout_marginTop="20dp"
android:ems="10"
android:gravity="center"
android:hint="Pg For Male or Female" />
<EditText
android:id="#+id/landmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/city"
android:layout_below="#+id/city"
android:layout_marginTop="17dp"
android:ems="10"
android:gravity="center"
android:hint="Landmark" />
<EditText
android:id="#+id/phone_number"
android:gravity="center"
android:hint="Phone Number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/landmark"
android:layout_below="#+id/landmark"
android:layout_marginTop="23dp"
android:ems="10" />
<EditText
android:id="#+id/house"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:ems="10"
android:gravity="center"
android:hint="House Address" />
<EditText
android:id="#+id/meal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/gender"
android:layout_below="#+id/gender"
android:layout_marginTop="25dp"
android:ems="10"
android:gravity="center"
android:hint="Pg With Meal or Not" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/meal"
android:layout_below="#+id/meal"
android:layout_marginTop="14dp"
android:ems="10"
android:gravity="center"
android:hint="City" />
<Button
android:id="#+id/add_pg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Phone Number"
android:layout_below="#+id/Phone Number"
android:layout_marginTop="24dp"
android:text="Add New PG" />
<Button
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/add_pg"
android:layout_alignBottom="#+id/add_pg"
android:layout_alignRight="#+id/Phone Number"
android:text="Cancel" />
</RelativeLayout>
</RelativeLayout>

rename into
#+id/phoneNumber
save Ctrl s
try manual allocating by yourself in R.java
public static int phoneNumber=0x7f050050;
save ctrl s

Same thing happen to me , and i passed a day to fix this. really this is a stupid error. i am just shearing my experience, may be it would helpful to you . First look carefully when you type this setContentView(R.layout.activity_to_do_list); hear your starting point R.l then eclipse should open a suggestion for you look like this
you import the second one not layout-android.R . the second one is created in your project hear com.example.gridtest is the project package name . then focus your imported section in your code
ok look this import com.example.gridtest.R; its important . If you already import this android.R then remove it. Thank you hope it works . ( you don't need to do this always but if you face this kinda problem then do this )
There are more option you can try this click

Step 1: Delete build folder from project, and recompile your code. Recompilation will recreate build folder (and R file). It will solve the issue.
Step 2: If above step doesn't work rename id i.e. #+id/phoneNumber to #+id/phoneNumber1 and perform step 1 again.
Update
Replace each instance of Phone Number with phone_number like in
android:layout_below="#+id/Phone Number" or android:layout_alignLeft="#+id/Phone Number". Do it in both buttons i.e. add_pg and back.
See:
<Button
android:id="#+id/add_pg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/Phone Number"
android:layout_below="#+id/Phone Number"
android:layout_marginTop="24dp"
android:text="Add New PG" />
Replace it with :
<Button
android:id="#+id/add_pg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/phone_number"
android:layout_below="#+id/phone_number"
android:layout_marginTop="24dp"
android:text="Add New PG" />

Related

Android studio error: resource not found Exception

i have a problem with my app: i'm using crashlytics by Fabric, (my app is pubblishes in the play store) to have log of possible crash, and i have this error ".. MainActivity: android.content.res.Resource$NotFoundException:Resource ID#0x7f09001b"
(Crashlytics say to me that the device is a samsung galaxy s4 with Android 5.1 and root )
CrashLytics screen
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main); <---- LINE 102 THAT GIVE
THE ERROR , ACCORDING TO
CRASHLYTICS
ping = (ImageButton)findViewById(R.id.ping);
internet =(TextView)findViewById(R.id.Internet);
banda5Ghz =(TextView)findViewById(R.id.BandeSupp);
SpeedNet =(TextView)findViewById(R.id.VR);
ipv6 =(TextView)findViewById(R.id.showIPv6);
txVsegnale =(TextView)findViewById(R.id.intensità);
aggiorna = (ImageButton)findViewById(R.id.Aggiorna);
share = (ImageButton)findViewById(R.id.sharebtn);
clipboard = (ImageButton)findViewById(R.id.clipboard);
rating = (ImageButton)findViewById(R.id.ratebtn);
IP =(TextView)findViewById(R.id.IP);
showIPv4 =(TextView)findViewById(R.id.showIPv4);
// TextViewWifi =(TextView)findViewById(R.id.TextViewWifi);
TextViewwifi_info = (TextView)findViewById(R.id.wifi_info);
MacA = (TextView)findViewById(R.id.MacAdd);
//switch gestione notifiche
notifiche = (Switch)findViewById(R.id.switchNot);`
......
The same device crash 2 times in a short time, with same error.
My app is an app that show infos on your wifi connection, such as IP, network velocity, etc etc, also have system notification and widgets and a service that run in background .
I have also done different layout for different devices with different screen size and different screen dpi
My Layouts
No other logs from other device with same problem .I want to know if is a specific problem of this device ( may be related to root access given to this device ) or is a problem of my application.
Not sure if it is linked to this, but, i was tryeing to add split screen function to my app, and , adding android:resizeableActivity="true" to manifest, make app crash in the same code line, so, i solve by settings to false and not include split screen feature in my app.
I CONFIRMED THAT TRIEING TO USE SPLIT SCREEN GIVE ME THE SAME ERROR, SAME RESOURCE NOT FOUND EXCEPTION, how can i see which resource have this id ?
android.content.res.Resources$NotFoundException: Resource ID #0x7f09001b
THE APP Crash only in this case , no other crash, do i have to define a minimum width and weight to use split Screen ?
`<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ShowMyIp.utente.ShowMyIp.MainActivity">
<TextView
android:id="#+id/Internet"
android:layout_width="match_parent"
android:layout_height="225dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/roundcorner"
android:layout_marginTop="8dp"
android:paddingTop="27dp"
android:textColor="#646464"
android:textSize="13sp"
android:layout_marginLeft="7dp"
android:layout_marginRight="8dp"
android:textStyle="italic" />
<TextView
android:id="#+id/Internet2"
android:layout_width="match_parent"
android:layout_height="195dp"
android:layout_alignEnd="#+id/internet4"
android:layout_below="#+id/internet4"
android:layout_marginTop="14dp"
android:layout_marginLeft="7dp"
android:background="#drawable/roundcorner" />
<TextView
android:id="#+id/internet4"
android:layout_width="match_parent"
android:layout_height="195dp"
android:layout_alignStart="#+id/Internet"
android:layout_below="#+id/Internet"
android:layout_marginRight="8dp"
android:layout_marginTop="17dp"
android:background="#drawable/roundcorner"
android:textSize="13sp" />
<TextView
android:id="#+id/MacAdd"
android:layout_width="275dp"
android:layout_height="35dp"
android:layout_alignStart="#+id/txtMac"
android:layout_below="#+id/BandeSupp"
android:layout_marginTop="35dp"
android:textAlignment="viewStart"
android:textColor="#android:color/black"
android:textSize="15sp" />
<TextView
android:id="#+id/IP"
android:layout_width="150dp"
android:layout_height="45dp"
android:layout_alignBaseline="#+id/Internet"
android:layout_alignBottom="#+id/Internet"
android:layout_alignStart="#+id/internet4"
android:layout_marginStart="45dp"
android:text="IP Address"
android:textColor="#E1E140"
android:textSize="18sp"
android:textStyle="italic" />
<TextView
android:id="#+id/showIPv4"
android:layout_width="230dp"
android:layout_height="45dp"
android:layout_alignStart="#+id/IP"
android:layout_below="#+id/intensità"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/wifi_info"
android:layout_width="220dp"
android:layout_height="55dp"
android:layout_alignStart="#+id/showIPv4"
android:layout_below="#+id/showIPv4"
android:text="Non Connesso"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="italic" />
<TextView
android:id="#+id/velocita"
android:layout_width="155dp"
android:layout_height="45dp"
android:layout_above="#+id/VR"
android:layout_alignEnd="#+id/txvIPV6"
android:text="Velocità rete"
android:textColor="#E1E140"
android:textSize="18sp"
android:textStyle="italic" />
<TextView
android:id="#+id/VR"
android:layout_width="135dp"
android:layout_height="45dp"
android:layout_alignBottom="#+id/wifi_info"
android:layout_alignEnd="#+id/velocita"
android:textColor="#android:color/black"
android:textSize="16sp"
android:textStyle="italic" />
<ImageButton
android:id="#+id/Aggiorna"
android:layout_width="200dp"
android:layout_height="75dp"
android:layout_alignEnd="#+id/intensità"
android:layout_alignTop="#+id/Internet2"
android:layout_marginEnd="21dp"
android:layout_marginTop="56dp"
android:background="#android:color/transparent"
android:scaleType="fitCenter"
android:textColor="#android:color/white"
app:srcCompat="#drawable/btn_aggiorna" />
<TextView
android:id="#+id/intensità"
android:layout_width="190dp"
android:layout_height="65dp"
android:layout_alignEnd="#+id/Internet"
android:layout_alignTop="#+id/IP"
android:layout_marginEnd="21dp"
android:textColor="#android:color/black"
android:textSize="18sp" />
<TextView
android:id="#+id/txtMac"
android:layout_width="140dp"
android:layout_height="35dp"
android:layout_alignStart="#+id/showIPv4"
android:layout_alignTop="#+id/internet4"
android:layout_marginTop="28dp"
android:text="MAC Address"
android:textColor="#E1E140"
android:textSize="18sp" />
<Switch
android:id="#+id/switchNot"
android:layout_width="145dp"
android:layout_height="85dp"
android:layout_alignStart="#+id/MacAdd"
android:layout_alignTop="#+id/Aggiorna"
android:layout_marginStart="28dp"
android:textColor="#E1E140"
android:textSize="18sp"
tools:text="Notifiche" />
<TextView
android:id="#+id/txvIPV6"
android:layout_width="75dp"
android:layout_height="45dp"
android:layout_alignBottom="#+id/txtMac"
android:layout_alignEnd="#+id/Aggiorna"
android:text="IPV6"
android:textColor="#E1E140"
android:textSize="18sp" />
<TextView
android:id="#+id/showIPv6"
android:layout_width="220dp"
android:layout_height="45dp"
android:layout_alignBottom="#+id/MacAdd"
android:layout_alignStart="#+id/Aggiorna"
android:textAlignment="viewStart"
android:textColor="#android:color/black"
android:textSize="17sp" />
<ImageButton
android:id="#+id/ratebtn"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_alignEnd="#+id/Internet2"
android:layout_alignParentBottom="true"
android:layout_marginBottom="22dp"
android:layout_marginEnd="10dp"
android:background="#android:color/transparent"
app:srcCompat="#drawable/rating_button"
android:scaleType="fitCenter"
/>
<ImageButton
android:id="#+id/sharebtn"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_alignTop="#+id/ratebtn"
android:layout_marginEnd="23dp"
android:layout_toStartOf="#+id/ratebtn"
android:background="#android:color/transparent"
android:scaleType="fitCenter"
app:srcCompat="#drawable/share_button" />
<ImageButton
android:id="#+id/clipboard"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_alignTop="#+id/sharebtn"
android:layout_toStartOf="#+id/VR"
android:background="#android:color/transparent"
android:scaleType="fitCenter"
app:srcCompat="#drawable/clipboard" />
<TextView
android:id="#+id/BandeSupp"
android:layout_width="130dp"
android:layout_height="55dp"
android:layout_alignTop="#+id/txvIPV6"
android:layout_toEndOf="#+id/showIPv4"
android:textColor="#android:color/black"
android:visibility="invisible"
android:textSize="17sp" />
<ImageButton
android:id="#+id/ping"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_alignBottom="#+id/clipboard"
android:layout_alignEnd="#+id/switchNot"
android:background="#android:color/transparent"
android:visibility="invisible"
app:srcCompat="#drawable/ping" />
</RelativeLayout>`
here is my layout (large-port-mdpi)
App still crash entering in split screen mode, with "no found exception ..." ; i've made another simple app , following Android developer guide to make multiview support, and this app work, no problem when entering in split screen, , i only added to the Manifest same code i wrote for this app " android:resizeableActivity="true"". Anyone know about to resolve this error? why my app, dosen't find layout resource entering in split screen mode??
Check your MainActivity Layout Xml in Text Format, There Has to be Line with a Yellow Warning on it, Or a Red Line.
Check the Layout Xml, And Then,
Check If You Missed Something Like LinearLayout Being RelativeLayout and you Declared it with this mistake.
Then Check If You've Used Anything like below:
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) myRelativeLayout.getLayoutParams();
LinearLayout.LayoutParams Param1 = (LinearLayout.LayoutParams) myLinearLayout.getLayoutParams();
If Yes, Reply me and I'll tell you what to do.

Rendering Problems NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts

I have a project in Android and everything is okay then when i open the project yesterday this kept giving me this error
Rendering Problems
NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts.
"invisible" in attribute "visibility" is not a valid integer (109 similar errors not shown)
Tip: Try to refresh the layout.
even when i start a new project and i go to the layout it kept giving me the error.
<LinearLayout 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:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#color/backgroundDark"
tools:context="coalesce.collabup.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/Logo"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="CollabUp"
android:textSize="70sp"
android:lineSpacingExtra="8sp"
android:typeface="normal"
android:textAlignment="center"
android:textStyle="normal|bold" />
<TextView
android:id="#+id/motto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="Collaboration at its finest"
android:textStyle="normal|bold"
android:textAlignment="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="50dp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:textSize="18sp"
android:padding="10dp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:imeActionId="#+id/login"
android:imeActionLabel="Sign In"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<CheckBox
android:text="keep me log in?"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/checkBox2"
android:layout_marginTop="10dp" />
<Button
android:id="#+id/email_sign_in_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:text="Sign In"
android:textStyle="bold"
android:layout_marginLeft="250dp"
android:layout_marginBottom="10dp"
/>
</RelativeLayout>
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/registertxt"
android:text="New to CollabUp? Create an Account now!"
android:textStyle="normal|bold"
android:textAlignment="center"
android:textSize="14sp"
android:onClick="gotoRegister"
android:layout_marginBottom="20dp" />
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/forgettxt"
android:text="Forgot your password?"
android:textStyle="normal|bold"
android:textAlignment="center"
android:onClick="gotoSendForget"
android:textSize="14sp" />
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/creditstxt"
android:text="Coalesce 2016 - All rights Reserved - CollabUp"
android:textStyle="normal|bold"
android:textColor="#android:color/white"
android:textAlignment="center"
android:textSize="14sp"
android:layout_marginTop="20dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
The issue is resolved by these changes:
Close Android Studio
Go to C:\Users\UserName.android and rename the build-cache folder to buildcache.bak
Go to C:\Users\UserName.AndroidStudio3.2\system and rename these folders
(1) caches to caches.bak
(2) compiler to compiler.bak
(3) compile-server to compile-server.bak
(4) conversion to conversion.bak
(5) external_build_system to external_build_system.bak
(6) frameworks to frameworks.bak
(7) gradle to gradle.bak
(8) resource_folder_cache to resource_folder_cache.bak
Open the Android Studio and open your project again.
This issues is caused in newer versions of android studio 3.2 you can fix the error by deleting the cache files.
step 1 : close android studio.
step 2: Go to .AndroidStudio3.2->system->caches.
step 3: Delete all files.
step 4: open Android studio
Your template is corrupted. Just go file and then setting. On the top search box, search templates and find file and code template. Choose that then choose other tab at the right hand side. click android and click layoutResourcesFile.xml.
copy and paste the below code on it and make sure you click live templates.
<?xml version="1.0" encoding="utf-8"?>
<${ROOT_TAG} xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="${LAYOUT_WIDTH}"
android:layout_height="${LAYOUT_HEIGHT}">
</${ROOT_TAG}>
I also got this error. I was helped by the following:
Remove the Android Studio files
To delete any remains of Android Studio setting files, in File Explorer, go to your user folder (%USERPROFILE%), and delete .android, .AndroidStudio and any analogous directories with versions on the end, i.e. .AndroidStudio1.2, as well as .gradle and .m2 if they exist.
The source is here
But I have not deleted these folders. I removed the dots in the folder name. After that, I launched Android Studio. She suggested that I export the settings from the old folders (in which I removed the dots in the title). I refused and re-tuned the studio. After that I opened the project and everything works.
Sorry for my english. I hope you understand my answer :)
The only thing that worked for me.
1. Download Android studio from the official website https://developer.android.com/studio/#downloads.
2. Install
You can even import settings from the previos install.
Now the render is fixed
I used the simple feature of Clean Project (Build -> Clean Project) and it somehow worked for me!

Null Pointer at Textview

The answer may be staring right at me but I just can't see it!
Am getting a null pointer exception when setting the text on a Textview with a string from a ArrayList of Strings. Have initialised everything and checked the ArrayLiist has data, everything seems to check out. But when the textview is been declared in onCreate() I can see in the debugger the value remains null.
OnCreate():
private TextView title;
//onCreate()
setContentView(R.layout.gallery);
imageNames = new ArrayList<String>();
title = (TextView) this.findViewById(R.id.tv_imageDescriptionGallery);
setImageAndTitleArrays();
//check size of arrays and build correctly
Log.d("GALLERY VIEW:" , "IMaegNaem array Size: "+imageNames.size() + " Image Array Size: "+ bitmapArray.size());
Log.d("GALLERYVIEW: ", "First Image Name of Array: "+ imageNames.get(0));
//set default image title and description, we will update every tome a image clicked
//exception throne here as title=null on debugger
title.setText(imageNames.get(0));
The textview :
<TextView
android:id="#+id/tv_imageDescriptionGallery"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Image Name"
android:textColor="#55bbfa"
/>....
Gallery XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/background2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Astro Gallery"
android:textColor="#55bbfa"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Gallery
android:id="#+id/gallery1"
android:layout_marginTop="100dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/splitter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sample_note"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:src="#drawable/splitter" />
<ImageView
android:id="#+id/imageView1"
android:layout_marginTop="100dp"
android:layout_width="420dp"
android:layout_gravity="center_horizontal"
android:layout_height="350dp"
android:src="#drawable/camera1" />
<TextView
android:id="#+id/tv_imageDescriptionGallery"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Image Name"
android:textColor="#55bbfa"
/>
<Button
android:id="#+id/send"
android:layout_marginTop="10dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Set Wallpaper"
android:background="#drawable/button_bg"
android:textColor="#fff" />
<ImageView
android:id="#+id/shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#drawable/shadow" />
</LinearLayout>
</ScrollView>
Only 2 hypothesis :
Maybe you tried to import R.java and you imported the wrong one ?
Or try to remove "this" in front of findViewById?
The 2 only ideas that come to mind, hope it can help.
Although I checked all the imports, removed all the ref to 'this, rename the class and all refs to it, cleaned and build, could not resolve the NPE.
I deleted the class and xml from the project, then made a new class and xml file with same code and worked fine.
I had a class with exact same name in a separate project, not sure if this has anything to do with it.

Cannot resolve symbol 'container' - Android Studio

I just created a new projet, building some layouts, writing some code. Everything was fine except I got this error as shown in the picture below.
I tried to remove and type it again and when typing 'R.id.', there was no 'container' showing up in the list. So that means theres no problem with my R file, just that the 'container' word lost somewhere.
Those code above are actually default code in onCreate() method in your main activity everytime you create a new project in Android Studio. (I actually tried to create a new project to compare and yes it's the same, and without error as it's brand new.).
All I did was comment out the if statement block so the error goes away, and the application has run just fine on the emulator. I just don't know why I got that problem and how I can handle it as I may need to do that in the future. Thank you!
Edit after #Raghunandan has mentioned: Below is my xml.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/provide_information"
android:id="#+id/provideInfoButton"
android:layout_alignParentTop="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/take_picture"
android:id="#+id/takePictureButton"
android:layout_below="#+id/provideInfoButton"
android:layout_alignParentLeft="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_below="#+id/takePictureButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/classNameTextView"
android:layout_above="#+id/personNametextView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginBottom="38dp"
android:layout_above="#+id/emailTextView"
android:layout_alignLeft="#+id/emailTextView"
android:id="#+id/personNameTextView" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/emailTextView"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#+id/classNameTextView"
android:layout_marginBottom="82dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/send_button"
android:id="#+id/sendButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
The reason is that I changed the root layout to RelativeLayout (the default of Android Studio was FrameLayout which has an id of "container"). My bad :). Thanks for mentioning about posting the xml file. I have not noticed that as I'm not as familiar with Android Studio as with Eclipse yet.

String types not allowed (at 'id' with value ' #id/bAdd')

I am getting an error saying
String types not allowed (at 'id' with value ' #id/bAdd')
I've cleaned the project.
Everything was working earlier, I don't what happened, causing this error.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Your total is 0"
android:textSize="45dp"
android:layout_gravity="center"
android:gravity="center"
android:id="#+id/tvDisplay"
tools:context=".StartingPoint" />
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Subtract One"
android:layout_gravity="center"
android:textSize="20dp"
android:id="+#id/bSub"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Add One"
android:layout_gravity="center"
android:textSize="20dp"
android:id="+#id/bAdd"
/>
You can give your id as #+id/bAdd
instead of +#id/bAdd
Also edit in
android:id="#+id/bSub"
^^
instead of
android:id="+#id/bSub"
^^
+ Symbol must be after # Symbol.
android:id="+#id/bAdd" to android:id="#+id/bAdd"
and also change
android:id="+#id/bSub" to android:id="#+id/bSub"
OR
you can declare is it
android:id="#id/bSub"
but you have to declare bSub value in ids.xml file located in values folder.
Example
<resources>
<item type="id" name="bSub" />
please use #+id/yourId instead of #id/yourId

Categories

Resources