Hey everyone I'm new to android programming so this should be pretty basic.
No matter what I do the android emulator crashes. To show how little it takes for this to happen, I've opened a new project called MyApplication, added a button to my xml file, and ran the button. After I run this button I get "Unfortunately MyApplication has stopped" When it should just allow me to click constantly. Ive already tried changing the ram, making sure the emulator is on host GPU, and making sure i opened a brand new application while changing no defaults and adding nothing but a simple button. Why is this happening?
Button code:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Here"
android:onClick="onClick"
android:id="#+id/button"
/>
Logcat:
12-05 13:06:35.459 1974-1974/com.example.owner.myapplication I/art: Not late-enabling -Xcheck:jni (already on)
12-05 13:06:35.459 1974-1974/com.example.owner.myapplication I/art: Late-enabling JIT
12-05 13:06:35.461 1974-1974/com.example.owner.myapplication I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
12-05 13:06:35.488 1974-1974/com.example.owner.myapplication W/System: ClassLoader referenced unknown path: /data/app/com.example.owner.myapplication-1/lib/x86
12-05 13:06:35.567 1974-1989/com.example.owner.myapplication D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-05 13:06:35.568 1974-1974/com.example.owner.myapplication D/: HostConnection::get() New Host Connection established 0xab795310, tid 1974
12-05 13:06:35.607 1974-1989/com.example.owner.myapplication I/OpenGLRenderer: Initialized EGL, version 1.4
12-05 13:06:35.641 1974-1989/com.example.owner.myapplication W/EGL_emulation: eglSurfaceAttrib not implemented
12-05 13:06:35.641 1974-1989/com.example.owner.myapplication W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabf217e0, error=EGL_SUCCESS
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication D/AndroidRuntime: Shutting down VM
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: Process: com.example.owner.myapplication, PID: 1974
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: java.lang.IllegalStateException: Could not find method onClick(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'button'
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.support.v7.internal.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:310)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.support.v7.internal.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:269)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.view.View.performClick(View.java:5198)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:21147)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-05 13:06:36.999 1974-1974/com.example.owner.myapplication E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-05 13:06:38.800 1974-1974/? I/Process: Sending signal. PID: 1974 SIG: 9
Just make sure your activity has the following method:
public void onClick (View view) {
// your logic
}
Try to write somw logic inside the Onclick function
Unless you write a code in the onclick function the emulator will show you an error
As you have not defined what needs to be done Onclicking the button
Try writing a code of toast or new Intent in the onclick so that something actually happens and the OS knows what shall be done after clicking the button
Related
I am learning Android Studio from a book called "Learn Android Studio: Build Android Apps Quickly and Effectively" By: Clifton Craig; Adam Gerber. I am following a tutorial on how to build a Reminders app and can't get the app to load. In the tutorial, I have been instructed to alter the onCreate() method with what is provided in the book, making sure to import what they provided.
The altered code is provided here.
The logcat is provided below:
01-18 06:04:55.460 2212-2212/com.apress.gerber.reminders I/art: Not late-enabling -Xcheck:jni (already on)
01-18 06:04:55.800 2212-2212/com.apress.gerber.reminders W/System: ClassLoader referenced unknown path: /data/app/com.apress.gerber.reminders-2/lib/x86_64
01-18 06:04:55.960 2212-2212/com.apress.gerber.reminders D/AndroidRuntime: Shutting down VM
01-18 06:04:55.960 2212-2212/com.apress.gerber.reminders E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.apress.gerber.reminders, PID: 2212
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.apress.gerber.reminders/com.apress.gerber.reminders.RemindersActivity}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.ListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.ListView
at com.apress.gerber.reminders.RemindersActivity.onCreate(RemindersActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-18 06:05:00.980 2212-2212/com.apress.gerber.reminders I/Process: Sending signal. PID: 2212 SIG: 9
The app will not load. The emulator gives an error. Any feedback on this would be greatly appreciated.
I am new to android and stuck at point. Please help!
I have created a dummy Hello world program (with project name testneha) in android studio. I created a new package "AppTest" folder inside the "com.example.ospune.testneha" folder. Inside the package, have created a JAVA class file with name AppTest1.
Folder Structure
com.example.ospune.test
AppTest(package folder)
AppTest1(java file)
MainActivity(file)
In AppTest1 file, onCreate folder I am calling "apptest layout file".
Now In the mainActivity file, I have added a button; which on being clicked calls startActivity mentioned in the AppTest1 class.
public void sendMessage(View view)
{
Intent intent = new Intent(this, com.example.ospune.test.neha.AppTest.AppTest1.class");
startActivity(intent);
}
My problem is when I click the button, I get a pop up saying "unfortunately, Test has stopped."
AndroidManifest.xml was also updated with the AppTest1.class activity
<activity
android:name=".AppTest.AppTest1"
android:parentActivityName=".MainActivity"
</activity>
I am clueless as what is the reason for this :(
LogCat error -
11-03 04:34:43.409 2055-2055/com.example.ospunelap_130.testneha I/art: Not late-enabling -Xcheck:jni (already on)
11-03 04:34:43.410 2055-2055/com.example.ospunelap_130.testneha I/art: Late-enabling JIT
11-03 04:34:43.419 2055-2055/com.example.ospunelap_130.testneha I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
11-03 04:34:43.507 2055-2055/com.example.ospunelap_130.testneha W/System: ClassLoader referenced unknown path: /data/app/com.example.ospunelap_130.testneha-2/lib/x86
11-03 04:34:43.914 2055-2083/com.example.ospunelap_130.testneha D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-03 04:34:43.918 2055-2055/com.example.ospunelap_130.testneha D/: HostConnection::get() New Host Connection established 0xad7f0110, tid 2055
11-03 04:34:44.008 2055-2083/com.example.ospunelap_130.testneha D/: HostConnection::get() New Host Connection established 0xad7f0420, tid 2083
11-03 04:34:44.033 2055-2083/com.example.ospunelap_130.testneha I/OpenGLRenderer: Initialized EGL, version 1.4
11-03 04:34:44.145 2055-2083/com.example.ospunelap_130.testneha W/EGL_emulation: eglSurfaceAttrib not implemented
11-03 04:34:44.145 2055-2083/com.example.ospunelap_130.testneha W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabebf2c0, error=EGL_SUCCESS
11-03 04:34:45.360 2055-2055/com.example.ospunelap_130.testneha I/Choreographer: Skipped 66 frames! The application may be doing too much work on its main thread.
11-03 04:35:03.158 2055-2055/com.example.ospunelap_130.testneha D/AndroidRuntime: Shutting down VM
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: FATAL EXCEPTION: main
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: Process: com.example.ospunelap_130.testneha, PID: 2055
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ospunelap_130.testneha/com.example.ospunelap_130.testneha.AppTest.AppTest1}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.support.v7.widget.Toolbar.getTitle()' on a null object reference
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.support.v7.widget.Toolbar.getTitle()' on a null object reference
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.support.v7.internal.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:100)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.support.v7.internal.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:93)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.support.v7.internal.app.ToolbarActionBar.<init>(ToolbarActionBar.java:78)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:206)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:99)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at com.example.ospunelap_130.testneha.AppTest.AppTest1.onCreate(AppTest1.java:22)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6237)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-03 04:35:03.159 2055-2055/com.example.ospunelap_130.testneha E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-03 04:35:07.335 2055-2055/com.example.ospunelap_130.testneha I/Process: Sending signal. PID: 2055 SIG: 9
EDIT:
The error is due to invoking toolbar.getTitle() method. The toolbar object is returning null. Try this:
Toolbar toolbar = (Toolbar) findviewById(R.id.toolbar);
to initialize the toolbar. The error is at line no. 22 according to logcat.
I just started developing with parse. I downloaded the android ParseLoginUI and the sample apps. Two things I had done to be able to start the app: for ParseLoginUI add a reference to the FacebookSDK and copy the "bolts-android-1.1.2.jar" file from the FacebookSDK libs folder to the ParseLoginUI lib folder.
The ParseLoginSampleBasic runs, the first screen comes up, but when I click on the Log in button , this exception comes up:
12-05 12:02:31.151: E/dalvikvm(24615): Could not find class 'com.parse.ui.ParseLoginActivity', referenced from method com.parse.ui.ParseLoginBuilder.build
12-05 12:02:32.606: E/AndroidRuntime(24615): FATAL EXCEPTION: main
12-05 12:02:32.606: E/AndroidRuntime(24615): Process: com.parse.loginsample.basic, PID: 24615
12-05 12:02:32.606: E/AndroidRuntime(24615): java.lang.NoClassDefFoundError: com.parse.ui.ParseLoginActivity
12-05 12:02:32.606: E/AndroidRuntime(24615): at com.parse.ui.ParseLoginBuilder.build(ParseLoginBuilder.java:309)
12-05 12:02:32.606: E/AndroidRuntime(24615): at com.parse.loginsample.basic.SampleProfileActivity$1.onClick(SampleProfileActivity.java:71)
12-05 12:02:32.606: E/AndroidRuntime(24615): at android.view.View.performClick(View.java:4456)
12-05 12:02:32.606: E/AndroidRuntime(24615): at android.view.View$PerformClick.run(View.java:18482)
12-05 12:02:32.606: E/AndroidRuntime(24615): at android.os.Handler.handleCallback(Handler.java:733)
12-05 12:02:32.606: E/AndroidRuntime(24615): at android.os.Handler.dispatchMessage(Handler.java:95)
12-05 12:02:32.606: E/AndroidRuntime(24615): at android.os.Looper.loop(Looper.java:136)
12-05 12:02:32.606: E/AndroidRuntime(24615): at android.app.ActivityThread.main(ActivityThread.java:5097)
12-05 12:02:32.606: E/AndroidRuntime(24615): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 12:02:32.606: E/AndroidRuntime(24615): at java.lang.reflect.Method.invoke(Method.java:515)
12-05 12:02:32.606: E/AndroidRuntime(24615): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
12-05 12:02:32.606: E/AndroidRuntime(24615): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
12-05 12:02:32.606: E/AndroidRuntime(24615): at dalvik.system.NativeStart.main(Native Method)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am developing an app for all android devices. It is working good on all device and I tested it on Samsung Galaxy S1, Galaxy Nexus, Motorola Xoom, HTC One and also on Amazon Kindle Fire.
It runs perfectly on all devices but when i tried using it on Nexus 7, it crashes and in log it says Out of Memory Error. I tried using System.gc(); in Activity#onPause() method but in vain. There are alternative drawables and layouts exist in app.
Please help me to resolve this issue. This issue is only specific to Nexus 7.
Below is stacktrace:
12-05 16:42:45.625: E/AndroidRuntime(8759): FATAL EXCEPTION: main
12-05 16:42:45.625: E/AndroidRuntime(8759): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.app/com.android.app.activity.MyListActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.os.Looper.loop(Looper.java:137)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Method.invoke(Method.java:511)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-05 16:42:45.625: E/AndroidRuntime(8759): at dalvik.system.NativeStart.main(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.Activity.setContentView(Activity.java:1881)
12-05 16:42:45.625: E/AndroidRuntime(8759): at com.android.app.activity.MyListActivity.onCreate(MyListActivity.java:39)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.Activity.performCreate(Activity.java:5104)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-05 16:42:45.625: E/AndroidRuntime(8759): ... 11 more
12-05 16:42:45.625: E/AndroidRuntime(8759): Caused by: java.lang.reflect.InvocationTargetException
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Constructor.constructNative(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-05 16:42:45.625: E/AndroidRuntime(8759): ... 23 more
12-05 16:42:45.625: E/AndroidRuntime(8759): Caused by: java.lang.OutOfMemoryError
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.content.res.Resources.loadDrawable(Resources.java:1965)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.View.<init>(View.java:3328)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.view.ViewGroup.<init>(ViewGroup.java:431)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
12-05 16:42:45.625: E/AndroidRuntime(8759): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
12-05 16:42:45.625: E/AndroidRuntime(8759): ... 26 more
Thanks in advance.
Ya i had faced this issue too but not found a valid solution but you can try using android:largeHeap="true" in manifest at application level
Help!
I’m having problems with my Sudoku application. I plugged in all the code to have my application remember the current position. Now when I run the application and I try to either start a new game or continue my Sudoku application says:
Sorry the application Sudoku (process org.example.sudoku) has stopped unexpectedly. Please try again.
It hasn’t done this in the past yet and I’m confused on where to go from here. I took a look at the logcat but I’m not sure what I should look for and how to fix it. Here is the logcat below
12-05 14:47:32.376: DEBUG/AndroidRuntime(289): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
12-05 14:47:32.376: DEBUG/AndroidRuntime(289): CheckJNI is ON
12-05 14:47:32.796: DEBUG/AndroidRuntime(289): —registering native functions --
12-05 14:47:34.306: DEBUG/AndroidRuntime(289): Shutting down VM
12-05 14:47:34.325: DEBUG/dalvikvm(289): Debugger has detached; object registry had 1 entries
12-05 14:47:34.345: INFO/AndroidRuntime(289): NOTE: attach of thread ‘Binder Thread #3’ failed
12-05 14:47:35.246: DEBUG/AndroidRuntime(297): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
12-05 14:47:35.246: DEBUG/AndroidRuntime(297): CheckJNI is ON
12-05 14:47:35.625: DEBUG/AndroidRuntime(297): —registering native functions --
12-05 14:47:36.985: INFO/ActivityManager(60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0×10000000 cmp=org.example.sudoku/.Sudoku }
12-05 14:47:37.126: DEBUG/AndroidRuntime(297): Shutting down VM
12-05 14:47:37.146: DEBUG/dalvikvm(297): Debugger has detached; object registry had 1 entries
12-05 14:47:37.186: INFO/AndroidRuntime(297): NOTE: attach of thread ‘Binder Thread #3’ failed
12-05 14:47:37.359: INFO/ActivityManager(60): Start proc org.example.sudoku for activity org.example.sudoku/.Sudoku: pid=304 uid=10037 gids={}
12-05 14:47:39.327: INFO/ActivityManager(60): Displayed activity org.example.sudoku/.Sudoku: 2047 ms (total 333042 ms)
12-05 14:47:44.516: DEBUG/dalvikvm(128): GC_EXPLICIT freed 205 objects / 9864 bytes in 134ms
12-05 14:48:14.936: DEBUG/Sudoku(304): clicked on 0
12-05 14:48:14.957: INFO/ActivityManager(60): Starting activity: Intent { cmp=org.example.sudoku/.Game (has extras) }
12-05 14:48:15.146: DEBUG/AndroidRuntime(304): Shutting down VM
12-05 14:48:15.146: WARN/dalvikvm(304): threadid=1: thread exiting with uncaught exception (group=0×4001d800)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): FATAL EXCEPTION: main
12-05 14:48:15.295: ERROR/AndroidRuntime(304): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.example.sudoku/org.example.sudoku.Game}: java.lang.NullPointerException
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.os.Looper.loop(Looper.java:123)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at java.lang.reflect.Method.invoke(Method.java:521)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at dalvik.system.NativeStart.main(Native Method)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): Caused by: java.lang.NullPointerException
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.content.ContextWrapper.getPackageName(ContextWrapper.java:120)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.Activity.getLocalClassName(Activity.java:3478)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.Activity.getPreferences(Activity.java:3512)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at org.example.sudoku.Game.<init>(Game.java:104)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at java.lang.Class.newInstanceImpl(Native Method)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at java.lang.Class.newInstance(Class.java:1429)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-05 14:48:15.295: ERROR/AndroidRuntime(304): ... 11 more
12-05 14:48:15.376: WARN/ActivityManager(60): Force finishing activity org.example.sudoku/.Game
12-05 14:48:15.455: WARN/ActivityManager(60): Force finishing activity org.example.sudoku/.Sudoku
12-05 14:48:15.927: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{44049308 org.example.sudoku/.Game}
12-05 14:48:27.095: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{43f562c0 org.example.sudoku/.Sudoku}
12-05 14:48:27.202: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{44049308 org.example.sudoku/.Game}
12-05 14:49:20.407: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol
Any help would be greatly appreciated. Thank you
-James
You need to look at line 104 of Game.java as it seems it may be the cause of a NullPointerException
Your error of interest is:
12-05 14:48:15.295: ERROR/AndroidRuntime(304): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.example.sudoku/org.example.sudoku.Game}: java.lang.NullPointerException
Usual error - your intent is not in the Manifest.xml