My application was working but when I came to start working on it this morning everything is not working. I am getting an error inflating class error which seems to be from an xml file where I get the "Binary XML file line #25" line. As I said this was working fine and now all of a sudden it does not. Below is the exception trace:
01-27 11:20:53.624: E/AndroidRuntime(7831): FATAL EXCEPTION: main
01-27 11:20:53.624: E/AndroidRuntime(7831): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ypmmllc.dailychecklist/com.ypmmllc.dailychecklist.TabbedActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2737)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2753)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.ActivityThread.access$2500(ActivityThread.java:129)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2107)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.os.Looper.loop(Looper.java:143)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.ActivityThread.main(ActivityThread.java:4701)
01-27 11:20:53.624: E/AndroidRuntime(7831): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 11:20:53.624: E/AndroidRuntime(7831): at java.lang.reflect.Method.invoke(Method.java:521)
01-27 11:20:53.624: E/AndroidRuntime(7831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-27 11:20:53.624: E/AndroidRuntime(7831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-27 11:20:53.624: E/AndroidRuntime(7831): at dalvik.system.NativeStart.main(Native Method)
01-27 11:20:53.624: E/AndroidRuntime(7831): Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:677)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.rInflate(LayoutInflater.java:614)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-27 11:20:53.624: E/AndroidRuntime(7831): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.Activity.setContentView(Activity.java:1647)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:180)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:134)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
01-27 11:20:53.624: E/AndroidRuntime(7831): at com.ypmmllc.dailychecklist.TabbedActivity.onCreate(TabbedActivity.java:30)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2701)
01-27 11:20:53.624: E/AndroidRuntime(7831): ... 11 more
01-27 11:20:53.624: E/AndroidRuntime(7831): Caused by: java.lang.reflect.InvocationTargetException
01-27 11:20:53.624: E/AndroidRuntime(7831): at android.support.v7.internal.widget.ActionBarView.<init>(ActionBarView.java:218)
01-27 11:20:53.624: E/AndroidRuntime(7831): at java.lang.reflect.Constructor.constructNative(Native Method)
01-27 11:20:53.624: E/AndroidRuntime(7831): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
Here is the XML file it bombs on in my class at setContentView(R.layout.activity_tabbed), as this is the line where everything bombs out.
activity_tabbed.xml:
<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=".TabbedActivity" >
<view class="com.ypmmllc.dailychecklist.CustomViewPager"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</view>
</RelativeLayout>
And now the CustomViewPager class that I am referencing within the XML file:
package com.ypmmllc.dailychecklist;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class CustomViewPager extends ViewPager {
private boolean enabled;
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
this.enabled = false;
}
public CustomViewPager(Context context)
{
super(context);
this.enabled = false;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
if (this.enabled) {
return super.onTouchEvent(event);
}
return false;
}
#Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (this.enabled) {
return super.onInterceptTouchEvent(event);
}
return false;
}
public void setPagingEnabled(boolean enabled) {
this.enabled = enabled;
}
}
Try to clean up the project and rebuild it:
IntelliJ IDEA: Build -> Rebuild project;
Eclipse: Project -> Clean
Try this:
<com.ypmmllc.dailychecklist.CustomViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
On behalf of OP
It was a settings.xml file I created while trying to create a SettingsActivity for the project. No errors were showing for the file at all and it was named in all lower case. I just completely deleted the file and everything built correctly. I noticed my LogCat was going crazy as well during this time. It just kept scrolling with new information. The whole thing is bizarre because, well, as I stated there were no errors showing within the file and everything was labeled correctly. Also, this was also after doing a clean build of the entire project which no longer produced the error I initially spoke of but than no longer created my R.java file.
Related
I've been having an issue with starting my application recently. It was working fine a few weeks back but during that time I made a few changes including importing refractoring it(I added a bunch of packages but then reverted those changes), updating from the ADT from the android site (which still runs on Eclipse Juno) to eclipse Kepler (and I downloaded the ADT plugin) and I also imported it to my new laptop (also using Kepler). Now when I import the application using Import -> Existing Android Code Into Workspace I get an error message saying that "Could not set the project desciption from "(myappname)" because the project description file (.project) is out of sync with the file system.". If I ignore this message and continue, and run the application on my phone LogCat gives me an error message ClassNotFoundException on my main launcher activity.
I've looked around and tried to solve this problem by rebuilding the path (with android private libraries checked). That's the only relevant fix I've found but it doesn't work.
I should point out a few things that might or might not help:
-I tried to run an older version of the application and that works (after import and on Kepler even though it was written on the Juno Eclipse).
-My application imports the support package v7-compat (which worked before all the changes)
I've been stuck on this problem for a few days now and with no luck. Any and all help would be appreciated. Oh and if anyone needs more information to help me solve this just ask.
Edit:
Here is the error log:
01-27 19:22:59.603: E/AndroidRuntime(16471): FATAL EXCEPTION: main
01-27 19:22:59.603: E/AndroidRuntime(16471): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.Spit.pocketbook/com.Spit.pocketbook.SwipeActivity}: java.lang.ClassNotFoundException: com.Spit.pocketbook.SwipeActivity
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.access$700(ActivityThread.java:143)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.os.Looper.loop(Looper.java:137)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.main(ActivityThread.java:4950)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 19:22:59.603: E/AndroidRuntime(16471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
01-27 19:22:59.603: E/AndroidRuntime(16471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
01-27 19:22:59.603: E/AndroidRuntime(16471): at dalvik.system.NativeStart.main(Native Method)
01-27 19:22:59.603: E/AndroidRuntime(16471): Caused by: java.lang.ClassNotFoundException: com.Spit.pocketbook.SwipeActivity
01-27 19:22:59.603: E/AndroidRuntime(16471): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-27 19:22:59.603: E/AndroidRuntime(16471): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
01-27 19:22:59.603: E/AndroidRuntime(16471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
01-27 19:22:59.603: E/AndroidRuntime(16471): ... 11 more
Thanks ahead of time,
Spit
A class that was declared in manifest was not found in code.
Check that package and class names are the same in your manifest and code. Based on the stacktrace generated by data in your manifest, your code should have class SwipeActivity in package com.Spit.pocketbook. Note that class and package names are case sensitive. By convention, package names are all lowercase so the capital S in the package name looks suspicious.
I want to dynamically add ImageButtons to a layout base on the images in a directory, but I want them all to have the same formatting as specified in an xml file.
I have tried this
XmlPullParser parser = res.getXml(R.layout.imagebuttons);
AttributeSet attributes = Xml.asAttributeSet(parser);
setLayoutParams(new LayoutParams(context, attributes));
to read this xml
<?xml version="1.0" encoding="utf-8"?>
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="90"
android:layout_height="160"
android:scaleType="fitCenter"
android:onClick="zoomImageFromThumb" >
</ImageButton>
but am getting this error
E/AndroidRuntime(16602): java.lang.RuntimeException: Unable to start activity ComponentInfo{package/package.MainActivity}: java.lang.RuntimeException:
Binary XML file line #-1: You must supply a layout_width attribute.
E/AndroidRuntime(16602): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
E/AndroidRuntime(16602): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
E/AndroidRuntime(16602): at android.app.ActivityThread.access$600(ActivityThread.java:130)
E/AndroidRuntime(16602): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
E/AndroidRuntime(16602): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(16602): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(16602): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime(16602): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(16602): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(16602): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime(16602): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(16602): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(16602): Caused by: java.lang.RuntimeException: Binary XML file line #-1: You must supply a layout_width attribute.
E/AndroidRuntime(16602): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
E/AndroidRuntime(16602): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5458)
E/AndroidRuntime(16602): at android.view.ViewGroup$LayoutParams.<init>(ViewGroup.java:5411)
E/AndroidRuntime(16602): at package.ImageButtons.<init>(ImageButtons.java:27)
E/AndroidRuntime(16602): at package.MainActivity.onCreate(MainActivity.java:49)
E/AndroidRuntime(16602): at android.app.Activity.performCreate(Activity.java:5122)
E/AndroidRuntime(16602): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1089)
E/AndroidRuntime(16602): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
E/AndroidRuntime(16602): ... 11 more
I'm lost as to how to fix this problem, is there something really obvious I'm missing?
You forgot to mention "dp" in your xml file's width and height attributes:
<?xml version="1.0" encoding="utf-8"?>
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="90dp"
android:layout_height="160dp"
android:scaleType="fitCenter"
android:onClick="zoomImageFromThumb" >
</ImageButton>
It was something incredibly simple, I was not actually using the parser, I presumed that the AttributesSet did that. This was the answer I used I cannot read the AttributeSet from my XML resources
In my application I have three PNG file that I use as the background of the activity, placed in the folder drawable-nodpi, but the application crashes on tablet Samsung Galaxy Tab 2 10.1, that i used for test and gives me this error:
LogCat:
E/AndroidRuntime(4846): FATAL EXCEPTION: main
E/AndroidRuntime(4846): java.lang.RuntimeException: Unable to start activity ComponentInfo{it.bisemanuDEV.mathTools/it.bisemanuDEV.mathTools.MainActivity}: java.lang.NullPointerException
E/AndroidRuntime(4846): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
E/AndroidRuntime(4846): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
E/AndroidRuntime(4846): at android.app.ActivityThread.access$600(ActivityThread.java:140)
E/AndroidRuntime(4846): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
E/AndroidRuntime(4846): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(4846): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(4846): at android.app.ActivityThread.main(ActivityThread.java:4895)
E/AndroidRuntime(4846): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(4846): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(4846): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
E/AndroidRuntime(4846): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
E/AndroidRuntime(4846): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(4846): Caused by: java.lang.NullPointerException
E/AndroidRuntime(4846): at it.bisemanuDEV.mathTools.MainActivity.onCreate(MainActivity.java:53)
E/AndroidRuntime(4846): at android.app.Activity.performCreate(Activity.java:5163)
E/AndroidRuntime(4846): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
E/AndroidRuntime(4846): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
But the application works on different models of smartphones.
What could be the problem?
You've got a NullPointerException:
Caused by: java.lang.NullPointerException
E/AndroidRuntime(4846): at it.bisemanuDEV.mathTools.MainActivity.onCreate(MainActivity.java:53)
so look at that line 53 to find out what's wrong.
I have a custom listview, each cell has 5 textviews and 2 button. Somehow when i scroll i get NPE for the button in the getView method. Pasting the log
01-27 08:15:40.654: D/AndroidRuntime(15471): Shutting down VM
01-27 08:15:40.654: W/dalvikvm(15471): threadid=1: thread exiting with uncaught exception (group=0x40c181f8)
01-27 08:15:40.662: E/AndroidRuntime(15471): FATAL EXCEPTION: main
01-27 08:15:40.662: E/AndroidRuntime(15471): java.lang.NullPointerException
01-27 08:15:40.662: E/AndroidRuntime(15471): at com.example.collegesoft.ViewAttendance$MyAdapter.getView(ViewAttendance.java:158)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.AbsListView.obtainView(AbsListView.java:2189)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.ListView.makeAndAddView(ListView.java:1772)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.ListView.fillDown(ListView.java:672)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.ListView.fillGap(ListView.java:636)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5312)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3050)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.widget.AbsListView.onTouchEvent(AbsListView.java:3391)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.View.dispatchTouchEvent(View.java:5588)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1962)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1723)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1968)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1737)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1968)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1737)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1968)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1737)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1968)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1737)
01-27 08:15:40.662: E/AndroidRuntime(15471): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2060)
01-27 08:15:40.662: E/AndroidRuntime(15471): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1398)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
01-27 08:15:40.662: E/AndroidRuntime(15471): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2008)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.View.dispatchPointerEvent(View.java:5768)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2957)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2531)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:898)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2540)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.os.Looper.loop(Looper.java:137)
01-27 08:15:40.662: E/AndroidRuntime(15471): at android.app.ActivityThread.main(ActivityThread.java:4514)
01-27 08:15:40.662: E/AndroidRuntime(15471): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 08:15:40.662: E/AndroidRuntime(15471): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 08:15:40.662: E/AndroidRuntime(15471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-27 08:15:40.662: E/AndroidRuntime(15471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-27 08:15:40.662: E/AndroidRuntime(15471): at dalvik.system.NativeStart.main(Native Method)
Any Help would be appreciated. Lemme know if u want to c the code.
Thanx
I found the answer. It was silly mistake. For the buttons i used to use setId() method. Then i changed it to setTag() and everything worked like charm.
Thanx anyways
When I try to run my app on my Samsung Note II, I get a ResourceNotFoundException for this line
setContentView(R.layout.activity_main);
However, I don't get this exception when I run it on the emulator or my Samsung Note 10.1.
Both are running Jellybean and my xml files are in folder called layout-land, and the XML file is in there. I tried cleaning my project and re-building, but it still doesn't work.
Does anyone have an idea what's wrong?
Let me know if I can provide any more information. Thanks!
01-27 22:11:32.975: E/AndroidRuntime(28330): FATAL EXCEPTION: main
01-27 22:11:32.975: E/AndroidRuntime(28330): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ventusthecorgi.hungrycorgi/com.mypackage.app.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030003
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.os.Looper.loop(Looper.java:137)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.main(ActivityThread.java:4898)
01-27 22:11:32.975: E/AndroidRuntime(28330): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 22:11:32.975: E/AndroidRuntime(28330): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
01-27 22:11:32.975: E/AndroidRuntime(28330): at dalvik.system.NativeStart.main(Native Method)
01-27 22:11:32.975: E/AndroidRuntime(28330): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030003
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.content.res.Resources.getValue(Resources.java:1026)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2131)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.content.res.Resources.getLayout(Resources.java:865)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:307)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.Activity.setContentView(Activity.java:1916)
01-27 22:11:32.975: E/AndroidRuntime(28330): at com.ventusthecorgi.hungrycorgi.MainActivity.onCreate(MainActivity.java:22)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.Activity.performCreate(Activity.java:5191)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
01-27 22:11:32.975: E/AndroidRuntime(28330): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
I suspect that you have your problematic layout files only in the layout-land directory (based on what you wrote in the question). This means that if the device is launched in portrait mode, Android will search for your layout in layout-port directory, then layout, but not layout-land. I might be wrong but my hunch is that your Samsung Note II starts in portrait mode and thus doesn't see the layout file.
You have to provide a fallback layout resource. Either copy the layout from layout-land to layout-port and modify it accordingly for portrait mode or just copy it to layout directory as a fallback layout.
AFAIK, Samsung Galaxy Note II 's default orientation is not in landscape
try putting a set of resource files in /res/layout for those devices which are not fit the specific layout characteristics
The xml files are in layout-land so they are only valid when the app/device is in landscape mode. Try moving/copying them to just layout and you should be fine. You may want to put a generic layout in the layout directory and a landscape optimized layout in layout-land (or look at other resource selection criteria).