I have an android app that gets an HTTP response from a webservice, which I process into an array of strings. I than try to display those strings in a ListView. they do not need to be clicked for any action, just displayed and be scroll-able.
When ran, Everything gets done ok, but when I try to scroll down beyond the amount of items that i have to show (because there are no more strings to display on list) I get a NullPointerException. Obviously I must be doing something wrong.
I don't quite get it. I've written a similar example as a test and it works just fine. the list in the example just scrolls and stops when there are no more items to show. The only difference I can think of is that on the original app the array gets created on a thread, and than the thread runs a runnable using a handler to display the list on the gui.
when the thread that fetches the strings and orders them to the array to display finishes, he runs this code using a handler:
scoreList = (ListView) findViewById(R.id.scorelist);
ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,scoreResult);
scoreList.setAdapter(myAdapter);
than the app crashes when trying to scroll lower than the bottom. this is the error from adb logcat:
D/AndroidRuntime( 864): Shutting down VM
W/dalvikvm( 864): threadid=1: thread exiting with uncaught exception (group=0x4
001d800)
E/AndroidRuntime( 864): FATAL EXCEPTION: main
E/AndroidRuntime( 864): java.lang.NullPointerException
E/AndroidRuntime( 864): at android.widget.ArrayAdapter.createViewFromRes
ource(ArrayAdapter.java:355)
E/AndroidRuntime( 864): at android.widget.ArrayAdapter.getView(ArrayAdap
ter.java:323)
E/AndroidRuntime( 864): at android.widget.AbsListView.obtainView(AbsList
View.java:1294)
E/AndroidRuntime( 864): at android.widget.ListView.makeAndAddView(ListVi
ew.java:1727)
E/AndroidRuntime( 864): at android.widget.ListView.fillDown(ListView.jav
a:652)
E/AndroidRuntime( 864): at android.widget.ListView.fillGap(ListView.java
:623)
E/AndroidRuntime( 864): at android.widget.AbsListView.trackMotionScroll(
AbsListView.java:2944)
E/AndroidRuntime( 864): at android.widget.AbsListView.onTouchEvent(AbsLi
stView.java:2065)
E/AndroidRuntime( 864): at android.widget.ListView.onTouchEvent(ListView
.java:3315)
E/AndroidRuntime( 864): at android.view.View.dispatchTouchEvent(View.jav
a:3766)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:897)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:936)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:936)
E/AndroidRuntime( 864): at android.view.ViewGroup.dispatchTouchEvent(Vie
wGroup.java:936)
E/AndroidRuntime( 864): at com.android.internal.policy.impl.PhoneWindow$
DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
E/AndroidRuntime( 864): at com.android.internal.policy.impl.PhoneWindow.
superDispatchTouchEvent(PhoneWindow.java:1107)
E/AndroidRuntime( 864): at android.app.Activity.dispatchTouchEvent(Activ
ity.java:2086)
E/AndroidRuntime( 864): at com.android.internal.policy.impl.PhoneWindow$
DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
E/AndroidRuntime( 864): at android.view.ViewRoot.handleMessage(ViewRoot.
java:1785)
E/AndroidRuntime( 864): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 864): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 864): at android.app.ActivityThread.main(ActivityThrea
d.java:4627)
E/AndroidRuntime( 864): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 864): at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime( 864): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 864): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:626)
E/AndroidRuntime( 864): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 59): Force finishing activity memo.ori.friend/.Highscores
W/ActivityManager( 59): Activity pause timeout for HistoryRecord{4503fed0 memo
.ori.friend/.Highscores}
W/WindowManager( 59): No window to dispatch pointer action 1
W/ActivityManager( 59): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 59): Activity idle timeout for HistoryRecord{45023af0 memo.
ori.friend/.MemoFriendActivity}
D/dalvikvm( 261): GC_EXPLICIT freed 45 objects / 2128 bytes in 108ms
W/ActivityManager( 59): Activity destroy timeout for HistoryRecord{4503fed0 me
mo.ori.friend/.Highscores}
D/SntpClient( 59): request time failed: java.net.SocketException: Address fami
ly not supported by protocol
I/Process ( 864): Sending signal. PID: 864 SIG: 9
I/ActivityManager( 59): Process memo.ori.friend (pid 864) has died.
I/WindowManager( 59): WIN DEATH: Window{45077ce0 memo.ori.friend/memo.ori.frie
nd.MemoFriendActivity paused=false}
I/WindowManager( 59): WIN DEATH: Window{4507cf60 memo.ori.friend/memo.ori.frie
nd.Highscores paused=false}
I/UsageStats( 59): Unexpected resume of com.android.launcher while already res
umed in memo.ori.friend
W/InputManagerService( 59): Got RemoteException sending setActive(false) notif
ication to pid 864 uid 10044
W/IInputConnectionWrapper( 126): showStatusIcon on inactive InputConnection
D/SntpClient( 59): request time failed: java.net.SocketException: Address fami
ly not supported by protocol
When ran, Everything gets done ok, but when I try to scroll down
beyond the amount of items that i have to show (because there are no
more strings to display on list) I get a NullPointerException.
Obviously I must be doing something wrong.
That exception comes from having null values in the list/array(scoreResult) that you pass to the ArrayAdapter. This is because the ArrayAdapter will call, by default,(in it's getView method which is responsible for building the list's rows) the toString method on each item from the data list if the type of that item isn't a CharSequence(you have String), to obtain a text representation of that item to show in the row.
So check the scoreResult list/array and make sure you don't have null values in it. I see you speak of an array, make sure the array is just as big as it needs for the data, if it's bigger than the data you'll have null values at its end.
request time failed: java.net.SocketException: Address fami
ly not supported by protocol
pls check what is there, somethig not good.
NullPointerException it is the beginner programmer sign: it doesn't verify the parameters and he write multiple statements in 1 line. In this case I would check the scoreResult to not be empty, but at least not null
Related
I'm building an app using the Ionic framework and AngularJS. It used to run fine, now it crashes as soon as it starts in both the emulator and an Android device. What is weird is that it runs fine in the Ionic View app (http://view.ionic.io/). The logcat says that the error is a NullPointerException.
What really worries me is that I didn't do any big changes, and another app started to fail as well. How can Ionic Cordova fail like that?
The complete logcat for the part of the crash says:
--------- beginning of crash
E/AndroidRuntime( 2227): FATAL EXCEPTION: main
E/AndroidRuntime( 2227): Process: com.ionicframework.notpush921844, PID: 2227
E/AndroidRuntime( 2227): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ionicframework.notpush921844/com.ionicframework.notpush921844.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
E/AndroidRuntime( 2227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
E/AndroidRuntime( 2227): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime( 2227): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime( 2227): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime( 2227): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2227): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 2227): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 2227): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2227): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 2227): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 2227): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime( 2227): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
E/AndroidRuntime( 2227): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
E/AndroidRuntime( 2227): at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:95)
E/AndroidRuntime( 2227): at org.apache.cordova.PluginManager.init(PluginManager.java:84)
E/AndroidRuntime( 2227): at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:116)
E/AndroidRuntime( 2227): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:138)
E/AndroidRuntime( 2227): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:209)
E/AndroidRuntime( 2227): at com.ionicframework.notpush921844.MainActivity.onCreate(MainActivity.java:32)
E/AndroidRuntime( 2227): at android.app.Activity.performCreate(Activity.java:5937)
E/AndroidRuntime( 2227): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime( 2227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime( 2227): ... 10 more
W/ActivityManager( 1219): Force finishing activity com.ionicframework.notpush921844/.MainActivity
I/WindowManager( 1219): Screenshot max retries 4 of Token{f511ccd ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}} appWin=Window{1adfb8c9 u0 Starting com.ionicframework.notpush921844} drawState=4
E/ActivityManager( 1219): Invalid thumbnail dimensions: 576x576
D/OpenGLRenderer( 1219): Render dirty regions requested: true
D/Atlas ( 1219): Validating map...
D/ ( 1219): HostConnection::get() New Host Connection established 0x9de19530, tid 2264
I/OpenGLRenderer( 1219): Initialized EGL, version 1.4
D/OpenGLRenderer( 1219): Enabling debug mode 0
W/EGL_emulation( 1219): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 1219): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9de3eb40, error=EGL_SUCCESS
W/ActivityManager( 1219): Activity pause timeout for ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}
W/EGL_emulation( 1475): eglSurfaceAttrib not implemented
W/OpenGLRenderer( 1475): Failed to set EGL_SWAP_BEHAVIOR on surface 0xb0a93b40, error=EGL_SUCCESS
W/OpenGLRenderer( 1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
W/OpenGLRenderer( 1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
W/OpenGLRenderer( 1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
I/iu.UploadsManager( 1746): End new media; added: 0, uploading: 0, time: 28 ms
V/ConfigFetchTask( 1746): ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1ViXdAKZc6rqCAOLFv7YJuwVLSY9_n4gaUyYMJPnZLeFSYFobS5FdRKHo-hnBvGnh1pycqXDTZLbzD-k5JtupkV7UW73Ugga_ju-VhYkvWRtl_Jn90jZhoDq_QYlbboOgPzzxDKH54r4FIa2bH3M1p-U8uzShc-PuRzDfha4UOokdUFujGIG2kLo5vTf6UKiU8mrJ_i-n_s1sm2CNkFb7o3Q7f_N1keqlCKSvXmpOQwTd0C7WGOOCYVnk7105hhiah5iLKl_0ZmwnXt9YnD2hVSUAQyDJPeLsFPksOqBpS6WQgtxBQ
I/GoogleURLConnFactory( 1746): Using platform SSLCertificateSocketFactory
W/ActivityThread( 1746): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
I/ActivityManager( 1219): Waited long enough for: ServiceRecord{39917cb u0 com.android.calendar/.alerts.InitAlarmsService}
I/ConfigFetchService( 1746): fetch service done; releasing wakelock
I/ConfigFetchService( 1746): stopping self
W/ActivityManager( 1219): Activity destroy timeout for ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}
I/CheckinService( 1746): Done disabling old GoogleServicesFramework version
I/ConfigService( 1598): onDestroy
D/TaskPersister( 1219): removeObsoleteFile: deleting file=61_task.xml
D/InitAlarmsService( 2008): Clearing and rescheduling alarms.
I/ActivityManager( 1219): Killing 1538:com.android.printspooler/u0a42 (adj 15): empty #17
W/libprocessgroup( 1219): failed to open /acct/uid_10042/pid_1538/cgroup.procs: No such file or directory
W/AudioTrack( 1219): AUDIO_OUTPUT_FLAG_FAST denied by client
I/Process ( 2227): Sending signal. PID: 2227 SIG: 9
I/ActivityManager( 1219): Process com.ionicframework.notpush921844 (pid 2227) has died
D/OpenGLRenderer( 1219): endAllStagingAnimators on 0xa2fe5880 (RippleDrawable) with handle 0x9deaf750
W/InputMethodManagerService( 1219): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#2a47c778 attribute=null, token = android.os.BinderProxy#344958d4
It turns out the problem was caused by adding Phonegap's PushPlugin. I just had to remove android platform with ionic platform rm android and then add it again with ionic platform add android. Works fine now in both emulator and device.
I've got some basic trigger.io code to open a modal dialog for oauth2 authentication:
var url_auth = "http://10.0.0.70/oauth2/authorize";
var oauth_client_id = "123";
var oauth_redirect_uri = "http://done.com/oauth2/complete";
forge.tabs.openWithOptions({
url: url_auth + "?response_type=token&client_id="+ oauth_client_id + "&redirect_url=" + oauth_redirect_uri,
pattern: oauth_redirect_uri + "*",
title: "Authorizing"
}, function(data) { ... });
When the user isn't authenticated, the server redirects to http://10.0.0.70/users to present a login form.
Running the code in an iOS6 simulator yields the correct result:
open modal dialog
server redirects to login form, presented within the dialog
user can authenticate
server redirects to oauth_redirect_uri which trigger catches and closes the dialog
When I run in an android simulator, the initial page is loaded, but then the app crashes.
I see the /oauth2/authorize url being processed on the server
all I see in the debug dialog is "subView load http://10.0.0.70:3000/users"
The more details around the error are (nothing after this in logs):
[DEBUG] Native call tabs.open with task.params: {"url":"http://10.0.0.70:3000/oauth2/authorize?response_type=token&client_id=123&redirect_url=http://www.diveboatbuddy.com/oauth2/complete","pattern":"^http://www.diveboatbuddy.com/oauth2/complete.*$","title":"Authorizing"}
[INFO] Displaying modal view.
[DEBUG] Returned: {"content":null,"callid":"0F7BA94D-08AD-439D-B44F-80BB22540CD4","status":"success"}
[DEBUG] Native call logging.log with task.params: {"message":"[FORGE] 'Successfully subscribed for push notifications'","level":20}
[INFO] [FORGE] 'Successfully subscribed for push notifications'
[DEBUG] Returned: {"content":null,"callid":"030EF36D-C17F-42E8-8F9E-0221A40153D1","status":"success"}
[INFO] subView load http://10.0.0.70:3000/users
So it looks like the server has redirected correctly, but the trigger.io app isn't rendering the new server page.
adb logcat output of the problem:
D/Forge ( 394): Returned: {"content":null,"callid":"03F62CF7-8B33-425C-ABD5-2BA64565B789","status":"success"}
D/dalvikvm( 394): GC_EXTERNAL_ALLOC freed 349 objects / 24336 bytes in 41ms
I/Forge ( 394): subView load http://10.0.0.70:3000/users
D/AndroidRuntime( 394): Shutting down VM
W/dalvikvm( 394): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 394): FATAL EXCEPTION: main
E/AndroidRuntime( 394): java.lang.NoSuchMethodError: android.webkit.WebView.removeJavascriptInterface
E/AndroidRuntime( 394): at io.trigger.forge.android.modules.tabs.ModalView$2$3.shouldOverrideUrlLoading(ModalView.java:310)
E/AndroidRuntime( 394): at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:216)
E/AndroidRuntime( 394): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:323)
E/AndroidRuntime( 394): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 394): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 394): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 394): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 394): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 394): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 394): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 394): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 59): Force finishing activity io.trigger.forge1979a236289211e2bbe612313d31f141/io.trigger.forge.android.core.ForgeActivity
I/ARMAssembler( 59): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x3446c0:0x34477c] in 5998000 ns
W/ActivityManager( 59): Activity pause timeout for HistoryRecord{43f928a8 io.trigger.forge1979a236289211e2bbe612313d31f141/io.trigger.forge.android.core.ForgeActivity}
I/Process ( 394): Sending signal. PID: 394 SIG: 9
I/ActivityManager( 59): Process io.trigger.forge1979a236289211e2bbe612313d31f141 (pid 394) has died.
W/ActivityManager( 59): Scheduling restart of crashed service io.trigger.forge1979a236289211e2bbe612313d31f141/com.parse.PushService in 5000ms
I/WindowManager( 59): WIN DEATH: Window{44002988 io.trigger.forge1979a236289211e2bbe612313d31f141/io.trigger.forge.android.core.ForgeActivity paused=false}
I/ActivityManager( 59): Start proc io.trigger.forge1979a236289211e2bbe612313d31f141 for service io.trigger.forge1979a236289211e2bbe612313d31f141/com.parse.PushService: pid=422 uid=10036 gids={1015, 3003}
Has anyone come across this issue. Is there a work around or a bug?
This was fixed in v1.4.34 of the Trigger.io platform: http://docs.trigger.io/en/v1.4/release-notes.html#v1-4-34.
D/AndroidRuntime(11752):
D/AndroidRuntime(11752): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(11752): CheckJNI is ON
D/dalvikvm(11752): creating instr width table
E/jdwp (11752): pipe failed
W/ProcessState(11752): Opening '/dev/binder' failed: Too many open files
D/AndroidRuntime(11752): Calling main entry com.android.commands.am.Am
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>> java.lang.NullPointerException
I/DMIC ( 1726): ---> java.lang.NullPointerException
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 31K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7507K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=7,camera
I/System.out( 1726): ***run in test i=8,cec
I/System.out( 1726): ***run in test i=9,edid
I/System.out( 1726): *****wifi state start=1
I/Mamarduke_Diag( 1726): Data is available now.
I/Mamarduke_Diag( 1726): exec result -->>>
I/System.out( 1726): *****wifi state end=1
D/dalvikvm( 1726): GC_EXPLICIT freed 36K, 41% free 7474K/12551K, external 1625K/2137K, paused 57ms
D/dalvikvm( 1726): GC_EXPLICIT freed 0K, 41% free 7474K/12551K, external 1625K/2137K, paused 58ms
I/System.out( 1726): ***run in test i=10,iris
I/System.out( 1726): *****wifi state start=1
I/ActivityManager( 1491): Starting: Intent { act=com.android.camera.irison flg=0x10000000 cmp=com.ianc.apd/.testcase.cameraex.ImageCamera } from pid 1726
I/System.out( 1726): onCreate
I/System.out( 1726): onResume
I/System.out( 1726): test irist on
I/System.out( 1726): excuteCmd/sys/bus/spi/devices/spi2.0/irisstate
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Consumer closed input channel or an error occurred. events=0x8
E/InputDispatcher( 1491): channel '40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera (server)' ~ Channel is unrecoverably broken and will be disposed!
D/AndroidRuntime( 1726): Shutting down VM
W/dalvikvm( 1726): threadid=1: thread exiting with uncaught exception (group=0x40015560)
I/WindowManager( 1491): WINDOW DIED Window{40643898 com.ianc.apd/com.ianc.apd.testcase.cameraex.ImageCamera paused=false}
E/AndroidRuntime( 1726): FATAL EXCEPTION: main
E/AndroidRuntime( 1726): java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
E/AndroidRuntime( 1726): at android.view.InputChannel.nativeReadFromParcel(Native Method)
E/AndroidRuntime( 1726): at android.view.InputChannel.readFromParcel(InputChannel.java:138)
E/AndroidRuntime( 1726): at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:409)
E/AndroidRuntime( 1726): at android.view.ViewRoot.setView(ViewRoot.java:498)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime( 1726): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime( 1726): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2170)
E/AndroidRuntime( 1726): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
E/AndroidRuntime( 1726): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1726): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1726): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1726): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 1726): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1726): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 1726): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 1726): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 1491): Force finishing activity com.ianc.apd/.testcase.cameraex.ImageCamera
W/ActivityManager( 1491): Activity pause timeout for HistoryRecord{4069a248 com.ianc.apd/.testcase.cameraex.ImageCamera}
Why do Consumer closed input channel or an error occurred. events=0x8 happen after many times running? That is too say, my program can run at first, but after many times, the exception happen.
I read this: Input transport and input dispatcher error on 2.3, but I have no idea how to solve it!! Who can help me?
I run my program in real device. The android version is 2.3
Update 1:
I found the root cause of Could not read input channel file descriptors from parcel.
It is E/jdwp (11752): pipe failed.
Why do create pipe failed? Because the pipe is out of the max in the system. that is to say, we create a lot of pipe or file descriptors in the system. And then we found the reason and try to modify it: My friend change the code like that in his Activity: `Original source code:
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
...
HandlerThread ht = new HandlerThread("CameraHolder");
ht.start();
mHandler = new MyHandler(ht.getLooper());
change to
private class MyHandler extends Handler {
MyHandler(Looper looper) {
super(looper);
}
#Override
public void handleMessage(Message msg) {
switch(msg.what) {
case RELEASE_CAMERA:
synchronized (CameraHolder.this) {
// In 'CameraHolder.open', the 'RELEASE_CAMERA' message
// will be removed if it is found in the queue. However,
// there is a chance that this message has been handled
// before being removed. So, we need to add a check
// here:
if (CameraHolder.this.mUsers == 0) releaseCamera();
}
break;
}
}
}
mHandler = new MyHandler();
Those file descriptors will reduce obviously. Why? how to explain this case? And I add mHandler.removemessage this function to onPause in my Activity. And Those file descriptors also reduce obviously. why? who can explain this case for me? I am trying to understand this.
Benni05 found a solution here, by setting android:configChanges="orientation" property for activity #AndroidManifest. It work for me(where i get an error with api lvl.11 installed devices). Good luck!
it is most probably because of having a wrong xml resource file. for me i put colors in strings.xml and got this errors. then i created colors.xml and now it works.
I had created a class with some stuff I commonly use, like toasts or dialogs. I named this class MyUtils. I had the following lines of code inside MyUtils. Where subYesNoDialogResult is a private variable of type boolean.
public void subYesNoDialog(Context appctx,String title,String mymessage) {
AlertDialog.Builder builder = new AlertDialog.Builder(appctx);
builder.setMessage(mymessage)
.setTitle(title)
.setCancelable(false)
.setPositiveButton(android.R.string.yes,
new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id) {
subYesNoDialogResult = true;
}
})
.setNegativeButton(android.R.string.no,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
subYesNoDialogResult = false;
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
I had another class which is used help the main activity class for certain purpose. I call this class MyDbHelper. I tried to call the above function to show up a Yes/No dialog. This is specifically to get the user's input to make a decision before doing some process inside MyDbHelper class. But I get NullPointerException on doing this. Here is my logcat out put.
I/ActivityManager( 67): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.xxx.geolog/.GeologActivity }
D/AndroidRuntime( 676): Shutting down VM
D/dalvikvm( 676): Debugger has detached; object registry had 1 entries
I/ActivityManager( 67): Start proc com.xxx.geolog for activity com.xxx.geolog/.GeologActivity: pid=683 uid=10040 gids={}
I/AndroidRuntime( 676): NOTE: attach of thread 'Binder Thread #3' failed
D/dalvikvm( 33): GC_EXPLICIT freed 244 objects / 9464 bytes in 704ms
D/dalvikvm( 33): GC_EXPLICIT freed 2 objects / 64 bytes in 350ms
D/dalvikvm( 33): GC_EXPLICIT freed 2 objects / 48 bytes in 536ms
W/GpsLocationProvider( 67): Duplicate add listener for uid 10040
W/WindowManager( 67): Attempted to add window with non-application token WindowToken{44f7d2a0 token=null}. Aborting.
D/AndroidRuntime( 683): Shutting down VM
W/dalvikvm( 683): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 683): FATAL EXCEPTION: main
E/AndroidRuntime( 683): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
E/AndroidRuntime( 683): at android.view.ViewRoot.setView(ViewRoot.java:509)
E/AndroidRuntime( 683): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime( 683): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime( 683): at android.app.Dialog.show(Dialog.java:241)
E/AndroidRuntime( 683): at com.xxx.geolog.SubLocationListener.onProviderDisabled(SubLocationListener.java:33)
E/AndroidRuntime( 683): at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:204)
E/AndroidRuntime( 683): at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:124)
E/AndroidRuntime( 683): at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:140)
E/AndroidRuntime( 683): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 683): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 683): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 683): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 683): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 683): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 683): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 67): Force finishing activity com.xxx.geolog/.GeologActivity
W/ActivityManager( 67): Activity pause timeout for HistoryRecord{45030820 com.xxx.geolog/.GeologActivity}
How can I fix this? Did I do something wrong?
Are you trying to use the application context to show a dialog?
If so try to use an activity context instead to see if it makes a difference.
Actually there is another point. I get the app context, as mibollma said, which is actually an activity context which is the one and only activity in this application which provides the GUI. I get it, and apply type cast to Activity and explicitly set an owner activity. The point here is that, every dialog requires an owner. If they are used inside an Activity class, then the parent activity will become the implicit owner. And if they are used outside an Activity class, you need
dialog_instance.setOwnerActivity(Activity owner);
So in my case, this one line just above alert.show() fixed the issue!
alert.setOwnerActivity((Activity)appctx);
Thanks for your support
Seems like you are not passing the argument Context appctxto the method.
I am creating an application that checks the installation of a package and then launches the market-place with its id.
When I try to launch market place with id of an application say com.mybrowser.android by throwing an intent android.intent.action.VIEW with url: market://details?id=com.mybrowser.android, the market place application does launches but crashes after launch.
Note: the application com.mybrowser.android doesn't exists in the market-place.
MyApplication is my application.
$ adb logcat
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=myapp.testapp/.MyApplication }
I/ActivityManager( 1030): Start proc myapp.testapp for activity myapp.testapp/.MyApplication: pid=3858 uid=10047 gids={1015, 3003}
I/MyApplication( 3858): [ Activity CREATED ]
I/MyApplication( 3858): [ Activity STARTED ]
I/MyApplication( 3858): onResume
D/dalvikvm( 1109): GC freed 6571 objects / 423480 bytes in 73ms
I/MyApplication( 3858): Pressed OK button
I/MyApplication( 3858): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.mybrowser.android
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.mybrowser.android flg=0x10000000 cmp=com.android.ven
ding/.AssetInfoActivity }
I/MyApplication( 3858): onPause
I/ActivityManager( 1030): Start proc com.android.vending for activity com.android.vending/.AssetInfoActivity: pid=3865 uid=10023 gids={3003}
I/ActivityThread( 3865): Publishing provider com.android.vending.SuggestionsProvider: com.android.vending.SuggestionsProvider
D/dalvikvm( 1030): GREF has increased to 701
I/vending ( 3865): com.android.vending.api.RadioHttpClient$1.handleMessage(): Handle DATA_STATE_CHANGED event: NetworkInfo: type: WIFI[], state: CONNECTED/CO
NNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
I/ActivityManager( 1030): Displayed activity com.android.vending/.AssetInfoActivity: 609 ms (total 7678 ms)
D/dalvikvm( 1030): GC freed 10458 objects / 676440 bytes in 128ms
I/MyApplication( 3858): [ Activity STOPPED ]
D/dalvikvm( 3865): GC freed 3538 objects / 254008 bytes in 84ms
W/dalvikvm( 3865): threadid=19: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 3865): at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime( 3865): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 3865): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 3865): at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime( 3865): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3865): at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:845)
E/AndroidRuntime( 3865): at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:831)
E/AndroidRuntime( 3865): at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime( 3865): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime( 3865): ... 4 more
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
I/dalvikvm( 3865): threadid=7: reacting to signal 3
I/dalvikvm( 3865): Wrote stack trace to '/data/anr/traces.txt'
I/DumpStateReceiver( 1030): Added state dump to 1 crashes
D/AndroidRuntime( 3865): Shutting down VM
W/dalvikvm( 3865): threadid=3: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.NullPointerException
E/AndroidRuntime( 3865): at com.android.vending.controller.AssetInfoActivityController.getIdDeferToLocal(AssetInfoActivityController.java:637)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity.displayAssetInfo(AssetInfoActivity.java:556)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity.access$800(AssetInfoActivity.java:74)
E/AndroidRuntime( 3865): at com.android.vending.AssetInfoActivity$LoadAssetInfoAction$1.run(AssetInfoActivity.java:917)
E/AndroidRuntime( 3865): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3865): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3865): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3865): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 3865): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3865): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 3865): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 3865): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 3865): at dalvik.system.NativeStart.main(Native Method)
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
W/ActivityManager( 1030): Process com.android.vending has crashed too many times: killing!
D/ActivityManager( 1030): Force finishing activity com.android.vending/.AssetInfoActivity
I/dalvikvm( 3865): threadid=7: reacting to signal 3
D/ActivityManager( 1030): Force removing process ProcessRecord{44e48548 3865:com.android.vending/10023} (com.android.vending/10023)
However, when I try to launch the market place for a package that exists in the market place say com.opera.mini.android, everything works. Log for this case:
D/dalvikvm( 966): GC freed 2781 objects / 195056 bytes in 99ms
I/MyApplication( 1165): Pressed OK button
I/MyApplication( 1165): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.opera.mini.android
I/ActivityManager( 78): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.opera.mini.android flg=0x10000000 cmp=com.android.vending/.AssetInfoActivity }
I/AndroidRuntime( 1165): AndroidRuntime onExit calling exit(0)
I/WindowManager( 78): WIN DEATH: Window{44c72308 myapp.testapp/myapp.testapp.MyApplication paused=true}
I/ActivityManager( 78): Process myapp.testapp (pid 1165) has died.
I/WindowManager( 78): WIN DEATH: Window{44c72958 myapp.testapp/myapp.testapp.MyApplication paused=false}
D/dalvikvm( 78): GC freed 31778 objects / 1796368 bytes in 142ms
I/ActivityManager( 78): Displayed activity com.android.vending/.AssetInfoActivity: 214 ms (total 22866 ms)
W/KeyCharacterMap( 978): No keyboard for id 65540
W/KeyCharacterMap( 978): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
V/RenderScript_jni( 966): surfaceCreated
V/RenderScript_jni( 966): surfaceChanged
V/RenderScript( 966): setSurface 480 762 0x573430
D/ViewFlipper( 966): updateRunning() mVisible=true, mStarted=true, mUserPresent=true, mRunning=true
D/dalvikvm( 978): GC freed 10065 objects / 624440 bytes in 95ms
Any ideas?
I am having similar problem when trying to open a detail page in Market app using "market://details?id=pname:org.rabold.android.puzzleblox" URL from an application.
I can create a shortcut using AnyCut like this:
action: android.intent.action.VIEW
data: market://details?id=pname:org.rabold.android.puzzleblox
type:
then it works fine.
However, if I create an Android application with a button to launch Market with the same Uri as above, then I get an error in Market app like this: "Attention: A server error has occurred. Retry, or cancel and return to the previous screen."
The code of my button's listener looks like this:
okButton = (Button) findViewById(R.id.okButton);
okButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=pname:org.rabold.android.puzzleblox"));
//Uri.parse("market://search?q=pname:org.rabold.android.puzzleblox"));
startActivity(intent);
}
});
Note in the above code, if I use 'search' instead of 'details' then it works. I'd like to use 'details' instead of 'search' because I know that my app will be available on Market when it's done. Thanks.
Update!:
Do not use "pname:"
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
Works perfectly.
per:
http://developer.android.com/distribute/googleplay/promote/linking.html#android-app
☮ ♥ ☺
thnx Daniel, I can confirm that your solution is working fine on device.
#TPham: please try with correct url (append id only),
passing correct id also working fine, see example below;
static final String APP_MARKET_URL = "market://details?id=com.wareninja.android.fotolicke";
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse(APP_MARKET_URL));
startActivity(intent);
instead of launching with the exact ID, you can try doing it by searching by the package.
Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse("market://search?q=pname:com.package.package2.package3"));
startActivity(intent);