Crash in AndEngine - android

I'm using the book Learning Android Game Programming to learn andengine but I can't seem to get to square one.
I'm using eclipse, I've installed the sdk and platforms 4 8 10 and 15.
I've downloaded chapter 2 from this books' website.
When I run it, it crashes and I get the logcat below.
Please help, I've been stuck on this for over a week.
01-27 15:14:31.519: I/System.out(17507): Sending WAIT chunk
01-27 15:14:31.519: W/ActivityThread(17507): Application com.pearson.lagp.v3 is waiting for the debugger on port 8100...
01-27 15:14:32.149: I/dalvikvm(17507): Debugger is active
01-27 15:14:32.319: I/System.out(17507): Debugger has connected
01-27 15:14:32.319: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:32.520: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:32.720: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:32.920: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:33.130: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:33.330: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:33.531: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:33.731: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:33.931: I/System.out(17507): waiting for debugger to settle...
01-27 15:14:34.131: I/System.out(17507): debugger has settled (1324)
01-27 15:14:34.482: D/dalvikvm(17507): threadid=1: still suspended after undo (sc=1 dc=1)
01-27 15:15:12.048: D/AndroidRuntime(17507): Shutting down VM
01-27 15:15:12.048: W/dalvikvm(17507): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
01-27 15:15:12.108: E/AndroidRuntime(17507): FATAL EXCEPTION: main
01-27 15:15:12.108: E/AndroidRuntime(17507): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.pearson.lagp.v3/com.pearson.lagp.v3.StartActivity}: java.lang.ClassNotFoundException: com.pearson.lagp.v3.StartActivity in loader dalvik.system.PathClassLoader[/data/app/com.pearson.lagp.v3-1.apk]
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.os.Looper.loop(Looper.java:130)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-27 15:15:12.108: E/AndroidRuntime(17507): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 15:15:12.108: E/AndroidRuntime(17507): at java.lang.reflect.Method.invoke(Method.java:507)
01-27 15:15:12.108: E/AndroidRuntime(17507): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
01-27 15:15:12.108: E/AndroidRuntime(17507): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
01-27 15:15:12.108: E/AndroidRuntime(17507): at dalvik.system.NativeStart.main(Native Method)
01-27 15:15:12.108: E/AndroidRuntime(17507): Caused by: java.lang.ClassNotFoundException: com.pearson.lagp.v3.StartActivity in loader dalvik.system.PathClassLoader[/data/app/com.pearson.lagp.v3-1.apk]
01-27 15:15:12.108: E/AndroidRuntime(17507): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
01-27 15:15:12.108: E/AndroidRuntime(17507): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
01-27 15:15:12.108: E/AndroidRuntime(17507): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-27 15:15:12.108: E/AndroidRuntime(17507): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
01-27 15:15:12.108: E/AndroidRuntime(17507): ... 11 more

It is classnotfoundexception, I suspect the package name you have in manifest.xml is different from the package you declared for activity.

Related

AVD crashes saying 'Unfortunately, libcocos2dx has crashed'

I just loaded my app created by cocos2dx-3.10 and when I open with it an AVD (again I haven't done any modifications to the app) the app crashes and gives the error: Unfortunately, libcocos2dx has crashed.
here is what I get in my android Monitor:
03-05 18:34:56.668 1435-1435/? D/dalvikvm: Not late-enabling CheckJNI (already on)
03-05 18:34:56.989 1435-1435/com.trying.name E/Trace: error opening trace file: No such file or directory (2)
03-05 18:34:57.419 1435-1435/com.trying.name D/AndroidRuntime: Shutting down VM
03-05 18:34:57.419 1435-1435/com.trying.name W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xb2f2b288)
03-05 18:34:57.518 1435-1435/com.trying.name E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:263)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
03-05 18:35:11.559 1435-1435/? I/Process: Sending signal. PID: 1435 SIG: 9

Google Play Games C++ SDK Samples fails with Library 'ButtonClickerNativeActivity' not found

I need to experiment with the Google Play Games C++ SDK Samples for Android.
Running it from an emulator fails to sign in requesting to install the Google Play Games... which requires to be done manually, as I understand...
Running it from the Samsung Samsung Galaxy Note 10.1 GT-N8010 executing Android 4.1.2, the Button Clicker application fails at launch with the following error:
Cannot load library: load_library[1094]: Library
'ButtonClickerNativeActivity' not found
Note: This error does not show up when I run it from the emulator.
I don't understand why this fails and how to fix or work around this failure.
The sample loads the so this way:
public class ButtonClickerNativeActivity extends NativeActivity {
// Load SO
static {
System.load("libButtonClickerNativeActivity.so");
}
I confirm the package (ButtonClicker-debug.apk) contains the library in lib folder for armeabi, armeabi-v7a and x86.
Here is the logcat listing of the app start up:
01-28 15:18:44.885 31258-31258/? D/dalvikvm: Late-enabling CheckJNI
01-28 15:18:44.900 31258-31264/? E/jdwp: Failed sending reply to debugger: Broken pipe
01-28 15:18:44.900 31258-31264/? D/dalvikvm: Debugger has detached; object registry had 1 entries
01-28 15:18:44.945 31258-31258/? W/ActivityThread: Application com.google.example.games.ButtonClicker is waiting for the debugger on port 8100...
01-28 15:18:44.960 31258-31258/? I/System.out: Sending WAIT chunk
01-28 15:18:45.915 31258-31264/com.google.example.games.ButtonClicker I/dalvikvm: Debugger is active
01-28 15:18:45.965 31258-31258/com.google.example.games.ButtonClicker I/System.out: Debugger has connected
01-28 15:18:45.965 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:46.165 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:46.365 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:46.565 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:46.765 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:46.965 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:47.170 31258-31258/com.google.example.games.ButtonClicker I/System.out: waiting for debugger to settle...
01-28 15:18:47.370 31258-31258/com.google.example.games.ButtonClicker I/System.out: debugger has settled (1325)
01-28 15:18:47.510 31258-31258/com.google.example.games.ButtonClicker D/dalvikvm: Trying to load lib ButtonClickerNativeActivity 0x423b2428
01-28 15:18:47.515 31258-31258/com.google.example.games.ButtonClicker W/dalvikvm: Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/google/example/games/ButtonClicker/ButtonClickerNativeActivity;
01-28 15:18:47.515 31258-31258/com.google.example.games.ButtonClicker W/dalvikvm: Class init failed in newInstance call (Lcom/google/example/games/ButtonClicker/ButtonClickerNativeActivity;)
01-28 15:18:47.515 31258-31258/com.google.example.games.ButtonClicker D/AndroidRuntime: Shutting down VM
01-28 15:18:47.515 31258-31258/com.google.example.games.ButtonClicker W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41c3d2a0)
01-28 15:18:47.525 31258-31258/com.google.example.games.ButtonClicker E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library[1094]: Library 'ButtonClickerNativeActivity' not found
at java.lang.Runtime.load(Runtime.java:340)
at java.lang.System.load(System.java:521)
at com.google.example.games.ButtonClicker.ButtonClickerNativeActivity.(ButtonClickerNativeActivity.java:29)
at java.lang.Class.newInstanceImpl(Native Method) 
at java.lang.Class.newInstance(Class.java:1319) 
at android.app.Instrumentation.newActivity(Instrumentation.java:1068) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 
at android.app.ActivityThread.access$700(ActivityThread.java:140) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4921) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 
at dalvik.system.NativeStart.main(Native Method) 
01-28 15:18:58.720 31258-31258/? I/Process: Sending signal. PID: 31258 SIG: 9
I changed the following line in the sample code (ButtonClickerNativeActivity.java) and the application launched on the Samsung device without the exception.
public class ButtonClickerNativeActivity extends NativeActivity {
// Load SO
static {
//System.load("libButtonClickerNativeActivity.so");
System.loadLibrary("ButtonClickerNativeActivity");
}

Android Application gets a ClassNotFoundException

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.

NPE for button in Custom ListView

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

ResourceNotFoundException when running on phone but not on tablet

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).

Categories

Resources