I have two ImageButtons on one activity that work completely fine when pressed, one makes a call while the other opens up the sms text messaging app. I also have a 'skip' Button at the bottom of the activity where users can go back to their profile page, however, one I tap on the button once in simulator nothing happens and when I press it twice I receive this error java.lang.OutOfMemoryError. I set all my buttons up the same way so I'm not sure why I'm receiving this error.
I did have the button pressed within its own method, but then switched and put it in the onCreate. But here's the code for my button:
Button _skipButton = (Button)findViewById(R.id.skipButton);
_skipButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(MessageOrCallActivity.this, MyActivity.class));
}
});
Additionally, here's the error printed within the logs:
FATAL EXCEPTION: main
java.lang.OutOfMemoryError: Failed to allocate a 499046412 byte allocation with 1060954 free bytes and 62MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1080)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2635)
at android.content.res.Resources.loadDrawable(Resources.java:2540)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.widget.ImageView.<init>(ImageView.java:152)
at android.widget.ImageView.<init>(ImageView.java:140)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:58)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:54)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:95)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.myApp.myApp.MyActivity.onCreate(MyActivity.java:14)
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)
Anyone know whats going on? I saw several post where this occurred while working with an array, but I have no arrays currently for this activity or the one I'm trying to transition to. Thanks in advance.
Related
I tried to build android app for android box. In my scenario my app need to stream live TV channels by using HDMI input.Why am I getting this kind of exception?
Any help to slow this error would be highly appreciated!
Thank you!
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{eu.danman.zidostreamer.zidostreamer/eu.danman.zidostreamer.zidostreamer.MainActivity}: java.lang.SecurityException: Binder invocation to an incorrect interface
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at java.lang.reflect.Method.invoke(Method.java)
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.SecurityException: Binder invocation to an incorrect interface
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at com.mstar.android.tv.ITvService$Stub$Proxy.getTvCommon(ITvService.java:365)
at com.mstar.android.tv.TvManager.getTvCommon(TvManager.java:205)
at com.mstar.android.tv.TvCommonManager.getService(TvCommonManager.java:136)
at com.mstar.android.tv.TvCommonManager.getCurrentInputSource(TvCommonManager.java:166)
at eu.danman.zidostreamer.zidostreamer.MainActivity.changeInputSource(MainActivity.java:49)
at eu.danman.zidostreamer.zidostreamer.MainActivity.enableHDMI(MainActivity.java:69)
at eu.danman.zidostreamer.zidostreamer.MainActivity.onCreate(MainActivity.java:89)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I know that TransactionTooLargeException occurs when there is a large amount of data being transferred between services in the system. Usually, I would have some kind of control if I were to transfer large amount of data, but in this case, when I'm appying a wallpaper, I don't have that amount of control.
I'm applying a wallpaper by first cropping it with android-image-cropper, and then applying it by
WallpaperManager.setBitmap(bitmap);
...in a separate thread, to avoid overloading the UI thread. Now, when I press "apply wallpaper", and wait for some time, and then return to the homescreen, it works flawlessly, but when I apply the wallpaper and then immediately return to the homescreen, I get the alert that the app has crashed, along with this log:
07-31 18:50:41.611 32720-32720/elementary.elementarywallpapers E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 16385936)
07-31 18:50:41.614 32720-32720/elementary.elementarywallpapers D/AndroidRuntime: Shutting down VM
07-31 18:50:41.621 32720-32720/elementary.elementarywallpapers E/AndroidRuntime: FATAL EXCEPTION: main
Process: elementary.elementarywallpapers, PID: 32720
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 16385936 bytes
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3752)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.os.TransactionTooLargeException: data parcel size 16385936 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3606)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3744)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
How can I fix this?
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 6 years ago.
Hey guys so when I hit this particular button it is supposed to take me to the another layout. However everytime i hit it, the entire app crashes. Here is the onCreate method for that page im trying to get to:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bench_data_entry);
//opens the database
openDB();
//Initializes and declares the sensors, and accelerometer
mInitialized = false;
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
// tv.setText("Aasfdaf");
}
Here is the onClick for the button I am pressing:
public void onClick_Bench(View v){
//Intent to create a new activity
Intent intent = new Intent(MainMenuActivity.this, BenchDataEntry.class);
//Goes to the Data Entry Screen
startActivity(intent);
}
and here is the error log I am getting when I press the button:
08-08 17:30:30.785 31113-31113/com.example.jacob.repcapture E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.jacob.repcapture, PID: 31113
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.jacob.repcapture/com.example.jacob.repcapture.BenchDataEntry}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.findViewById(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
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:5422)
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.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.Window.findViewById(int)' on a null object reference
at android.app.Activity.findViewById(Activity.java:2096)
at com.example.jacob.repcapture.BenchDataEntry.<init>(BenchDataEntry.java:49)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
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:5422)
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)
I think error not in these code blocks logcat about android.view.View android.view.Window.findViewById(int)' on a null object reference
First - do clean project under build-menu, and restart the emulator. After that the exception went away in my situation.
Second - check FindviewById items You need to initialize them in the onCreate too.
I have static values that are deleted after my application is a long time in the background or after opening many different apps, causing that my app crashes.
I think that Android OS is removing data from my app or "killing" it.
Is there any way to keep my app's data to avoid this problem?
NOTE: I can't save this values on SharedPreferences or in a database because there are many HashMaps and ArrayLists, is too much information.
It is necessary that these values are static because I need them available in many classes o my app in any time.
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.proyect/com.proyect.gui.ActivityMenu}: java.lang.NullPointerException: println needs a message
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.access$600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.v(Log.java:117)
at com.proyect.gui.FragmentMenu.onActivityCreated(FragmentMenu.java:145)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1983)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:174)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:597)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5143)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2239)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.access$600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Change this:
Log.v("errorTag", e.getMessage());
To this:
String error = e.getMessage();
if(error == null)
error = "It's crashed here";
Log.v("errorTag", error );
OR SIMPLER
Log.v("errorTag", e );
The point is that e.getMessage() is null. So, always check if e.getMessage() is not null before print it
I am getting this crash log for my application:
java.lang.IllegalStateException
android.widget.ListView.layoutChildren(ListView.java:1544)
android.widget.AbsListView.onTouchModeChanged(AbsListView.java:3543)
android.view.ViewTreeObserver.dispatchOnTouchModeChanged(ViewTreeObserver.java:732)
android.view.ViewRootImpl.ensureTouchModeLocally(ViewRootImpl.java:3170)
android.view.ViewRootImpl.ensureTouchMode(ViewRootImpl.java:3154)
android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3397)
android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3347)
android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4456)
android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4434)
android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4538)
android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
android.os.MessageQueue.nativePollOnce(Native Method)
android.os.MessageQueue.next(MessageQueue.java:125)
android.os.Looper.loop(Looper.java:124)
android.app.ActivityThread.main(ActivityThread.java:4921)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
dalvik.system.NativeStart.main(Native Method)
But i can't see in this lines nothing that point to my code. any idea how i can detect the crash?
The way to get an IllegalStateException in ListView.layoutChildren() is to make the adapter item count differ from what the listview expected.
This can happen if you changed the data in your listview adapter but forgot to call notifyDataSetChanged(), or modified the data in a background thread.