BluetoothChat example: NullPointerException [duplicate] - android

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
getActionBar returns null
Complete Android noob. I am trying to run the BluetoothChat example from a Galaxy S3, and it appears to crash the moment the application is run.
Here is the LogCat output:
09-14 15:47:23.400: E/AndroidRuntime(6098): FATAL EXCEPTION: main
09-14 15:47:23.400: E/AndroidRuntime(6098): java.lang.NullPointerException
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.example.android.BluetoothChat.BluetoothChat.setStatus(BluetoothChat.java:235)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.example.android.BluetoothChat.BluetoothChat.access$4(BluetoothChat.java:233)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.example.android.BluetoothChat.BluetoothChat$2.handleMessage(BluetoothChat.java:260)
09-14 15:47:23.400: E/AndroidRuntime(6098): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 15:47:23.400: E/AndroidRuntime(6098): at android.os.Looper.loop(Looper.java:137)
09-14 15:47:23.400: E/AndroidRuntime(6098): at android.app.ActivityThread.main(ActivityThread.java:4514)
09-14 15:47:23.400: E/AndroidRuntime(6098): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 15:47:23.400: E/AndroidRuntime(6098): at java.lang.reflect.Method.invoke(Method.java:511)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
09-14 15:47:23.400: E/AndroidRuntime(6098): at dalvik.system.NativeStart.main(Native Method)
Code is exactly per the example in the SDK:
private final void setStatus(int resId) {
final ActionBar actionBar = getActionBar();
actionBar.setSubtitle(resId);
}
It appears getActionBar returns null. What might I be doing incorrectly?
This is only the 2nd Android app I have run, so go easy on me :)
Cheers

Solution found here: getActionBar returns null
this needs to go to the onCreate() method in bluetoothChat.java
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

Related

Bitmap factory Error

Hi I have been trying to develop a simple game in Eclipse I'm at the stage of trying to add the background image however when I try to run the app I get the "unfortunately has stopped working" looking at the log cat my best guess is that something is wrong with the bitmap factory line below:
background = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.underwater), ScreenWidth, this);
Here is the Log Cat I am recieving:
FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:500)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:376)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:406)
at com.example.deepseadiver.GamePanel.<init>(GamePanel.java:21)
at com.example.deepseadiver.Game.onCreate(Game.java:69)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2139)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
at android.app.ActivityThread.access$600(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
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:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
Any help or suggestions for how to fix this are much appreciated.
Update you manifest file,inside application tag set large heap -
.
.
<application
android:largeHeap="true"
. .
>
....
</application>

ArrayIndexOutOfBoundsException in android.view.WindowManagerGlobal

I have received this error in my remote app crash reporter:
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at android.view.WindowManagerGlobal.closeAll(WindowManagerGlobal.java:325)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3590)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3756)
at android.app.ActivityThread.access$800(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1286)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Is this a known bug in Android? I have no more information about the crash. Do you have any idea about what can I do to get the cause?
Array index start at 0
you have to subsract 1

NoClassDefFoundError: org.htmlcleaner.HtmlCleaner

I an trying to read an html page. i used the following link: http://thinkandroid.wordpress.com/2010/01/05/using-xpath-and-html-cleaner-to-parse-html-xml/ as an example but I get the following error
09-14 11:27:54.624: E/AndroidRuntime(10223): FATAL EXCEPTION: main
09-14 11:27:54.624: E/AndroidRuntime(10223): java.lang.NoClassDefFoundError: org.htmlcleaner.HtmlCleaner
09-14 11:27:54.624: E/AndroidRuntime(10223): at com.example.htmltest.MainActivity.getBlogStats(MainActivity.java:43)
09-14 11:27:54.624: E/AndroidRuntime(10223): at com.example.htmltest.MainActivity.onCreate(MainActivity.java:29)
09-14 11:27:54.624: E/AndroidRuntime(10223): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-14 11:27:54.624: E/AndroidRuntime(10223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-14 11:27:54.624: E/AndroidRuntime(10223): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-14 11:27:54.624: E/AndroidRuntime(10223): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-14 11:27:54.624: E/AndroidRuntime(10223): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
I can't seem to figure out what is causing this error. any thoughts?
There are many questions already relating to the error NoClassDefFound
NoClassDefFoundError for code in an Java library on Android
java.lang.NoClassDefFoundError after integrating project to windows 7
Gson NoClassDefFoundError after ADT and SDK Tools update to v17
Have you tried any suggestions from these questions yet?
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

NullPointer exception at android.support.v4.app.FragmentManagerImpl.makeInactive

I'm seeing a weird exception in Android Support Library - the stack trace is below. Any ideas what could be causing this? I'm unable to reproduce the exception on any of my devices, but there seem to be quite a few visible in the Google Play DevConsole.
java.lang.NullPointerException
at android.support.v4.app.FragmentManagerImpl.makeInactive(FragmentManager.java:1133)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1044)
at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1171)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:582)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
try check stack fragments in time rotate screen for example in onResume.

Failed to register input channel - live wallpaper

I encountered similar problem as this.
The crash report is from Google Play and I can't reproduce it by myself. I tried to download Launcher Pro but that wasn't causing any troubles.
Here is the stack trace:
java.lang.RuntimeException: Failed to register input channel. Check logs for details.
at android.view.InputQueue.nativeRegisterInputChannel(Native Method)
at android.view.InputQueue.registerInputChannel(InputQueue.java:92)
at android.service.wallpaper.WallpaperService$Engine.updateSurface(WallpaperService.java:534)
at android.service.wallpaper.WallpaperService$Engine.attach(WallpaperService.java:670)
at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:898)
at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

Categories

Resources