I am new to android, as my study project I made an application. Which is syncing data from webservice and fetching in my application.
Everything working fine.
But in this scenario
Launch the application
Check for internet connection
Get content from server
Fetch data in application
5. When we turn off Mobile Data / WiFi , then press any button in application suddenly application crashes.
There is any way to handle this issue ?
Thanks in advance
Error message
08-14 21:28:57.670: E/AndroidRuntime(7466): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.tvc/com.myapp.tvc.SingleActivity}: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.access$600(ActivityThread.java:140)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.os.Looper.loop(Looper.java:137)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.main(ActivityThread.java:4895)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): at java.lang.reflect.Method.invoke(Method.java:511)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
08-14 21:28:57.670: E/AndroidRuntime(7466): at dalvik.system.NativeStart.main(Native Method)
08-14 21:28:57.670: E/AndroidRuntime(7466): Caused by: java.lang.NullPointerException
08-14 21:28:57.670: E/AndroidRuntime(7466): at com.myapp.tvc.SingleActivity.onCreate(SingleActivity.java:76)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Activity.performCreate(Activity.java:5163)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
08-14 21:28:57.670: E/AndroidRuntime(7466): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
08-14 21:28:57.670: E/AndroidRuntime(7466): ... 11 more
whatever is at line 76 of SingleActivity is null, since you did not provide code the best we can say is find out what and why is null at that line
My most common error is something is nulll. Maybe the handler is defined inline and your using a variable that is null
Based on what you're describing and without seeing your code it sounds like you're just trying to connect to the internet when no internet connection exists. To fix this problem you can create a network checker/listener that can check network availability before you try to do anything that requires an internet connection. If no connection is available you just don't run the task that gets stuff from the server. A more involved set up could be designed using a BroadcastReceiver (e.g. so you know when connectivity becomes available again) but try this for now and see if that's your issue.
Related
I get a project from other developer to fix minor issues in app, when I'm running my app on device I'm getting an error:
15142-15142/com.etripconcept E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.crashlytics.android.answers.Answers
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:224)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:207)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:202)
at com.etripconcept.SplashScreenActivity.onCreate(SplashScreenActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5163)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
I'm new in Android development, so it may be stupid question, but Google doesn't say anything about it. I use Android Studio 1.2.2 on Win 8.1
I tried to build the Cocos2D-x testCpp sample project (Cocos2D-x 2.2.2) on my Android device using the command line interface as described in the Readme.md file:
$ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/
$ export NDK_ROOT=/path/to/ndk
$ ./build_native.sh
$ ant debug install
If the last command results in sdk.dir missing error then do:
$ android list target
$ android update project -p . -t (id from step 6)
$ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6)
I can install the app on my device (Galaxy S4) but the application crashes immediately after the launch telling me the application was stopped.
Any idea what I can do to fix that problem?
I am not sure how to use logcat within the CLI, so I startet the sample application using eclipse (the error here is the same: application crashes after launch) and post the logcat info shown by eclipse:
03-19 10:49:22.785: W/dalvikvm(6591): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/cocos2dx/hellocpp/HelloCpp;
03-19 10:49:22.785: W/dalvikvm(6591): Class init failed in newInstance call (Lorg/cocos2dx/hellocpp/HelloCpp;)
03-19 10:49:22.785: D/AndroidRuntime(6591): Shutting down VM
03-19 10:49:22.785: W/dalvikvm(6591): threadid=1: thread exiting with uncaught exception (group=0x4195f898)
03-19 10:49:22.785: E/AndroidRuntime(6591): FATAL EXCEPTION: main
03-19 10:49:22.785: E/AndroidRuntime(6591): java.lang.UnsatisfiedLinkError: Couldn't load hellocpp from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.cocos2dx.hellocpp-1.apk,libraryPath=/data/app-lib/org.cocos2dx.hellocpp-1]: findLibrary returned null
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Runtime.loadLibrary(Runtime.java:355)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.System.loadLibrary(System.java:525)
03-19 10:49:22.785: E/AndroidRuntime(6591): at org.cocos2dx.hellocpp.HelloCpp.(HelloCpp.java:37)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Class.newInstanceImpl(Native Method)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.Class.newInstance(Class.java:1130)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.os.Looper.loop(Looper.java:137)
03-19 10:49:22.785: E/AndroidRuntime(6591): at android.app.ActivityThread.main(ActivityThread.java:5419)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 10:49:22.785: E/AndroidRuntime(6591): at java.lang.reflect.Method.invoke(Method.java:525)
03-19 10:49:22.785: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
03-19 10:49:22.785: E/AndroidRuntime(6591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
03-19 10:49:22.785: E/AndroidRuntime(6591): at dalvik.system.NativeStart.main(Native Method)
seems that your building is not successful according to the log. no hellocpp.so is generated. so it crashes when you call the method
loadLibrary();
you can check this under youPath/proj.android/libs/armeabi , see if there's a libxxx.so file.
Every time this has happened to me it has always been because I forgot to run ./build_native.sh in the "proj.android" folder of the project in question. #Lorin actually noted the symptom that reminded me. A reason that a libxxx.so file would be missing is the ./build_native.sh script has yet to be run
When you run eclipse to build it is happening in the background. When you compile from command line you need to remember to to have run the script at least once (and every time (if) you ever make a change to the cocos2dx framework itself.) I frequently forget to do that for EVERY project thereafter.
I recently published my app to the android play store.
I see a whole lot of error logs from one device in particular. It's a Sony Experia S.
I contacted the owner of the device, and he says he has the latest version of android ( don't know the exact version ).
I heard from a colluege developer that there are more known issieus with sony devices and android.
This app in particular works with fragments... Don't know if this is the problem but... Maybe the sony's don't know how to cope with them.
Does anyone have an idea what this problem could be.
Error logs looks like:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.KVODeventerActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.TabControllerHome}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
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:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.TabControllerHome}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:1808)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:682)
at android.widget.TabHost.setCurrentTab(TabHost.java:346)
at android.widget.TabHost.addTab(TabHost.java:236)
at com.crosscommunications.kvodeventer.KVODeventerActivity.onCreate(KVODeventerActivity.java:27)
at android.app.Activity.performCreate(Activity.java:4470)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
... 11 more
Caused by: java.lang.NullPointerException
at com.crosscommunications.kvodeventer.KVOHome.onCreateView(KVOHome.java:52)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:505)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1136)
at android.app.Activity.performStart(Activity.java:4480)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1940)
... 21 more
Thnx
Just put a null check to your code:
KVOHome Acvitivity, line 52.
at com.crosscommunications.kvodeventer.KVOHome.onCreateView(KVOHome.java:52)
Most probably, Sony sends a null value to your code.
.I have simple map applicaiton.First simply my map is working.then i allow to develop my application i got Force close.When i run my application i got following error:
08-14 20:57:26.855: E/AndroidRuntime(207): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapss/com.example.mapss.MainActivity}: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Handler.dispatchMessage(Handler.java:99)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Looper.loop(Looper.java:123)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.main(ActivityThread.java:4203)
08-14 20:57:26.855: E/AndroidRuntime(207): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 20:57:26.855: E/AndroidRuntime(207): at java.lang.reflect.Method.invoke(Method.java:521)
08-14 20:57:26.855: E/AndroidRuntime(207): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
08-14 20:57:26.855: E/AndroidRuntime(207): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
08-14 20:57:26.855: E/AndroidRuntime(207): at dalvik.system.NativeStart.main(Native Method)
08-14 20:57:26.855: E/AndroidRuntime(207): Caused by: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Parcel.readException(Parcel.java:1218)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.os.Parcel.readException(Parcel.java:1206)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.location.ILocationManager$Stub$Proxy.getLastKnownLocation(ILocationManager.java:776)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.location.LocationManager.getLastKnownLocation(LocationManager.java:945)
08-14 20:57:26.855: E/AndroidRuntime(207): at com.example.mapss.MainActivity.onCreate(MainActivity.java:36)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-14 20:57:26.855: E/AndroidRuntime(207): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
08-14 20:57:26.855: E/AndroidRuntime(207): ... 11 more
add this line to your AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
When using Maps or other types of services, you need to make sure that you add appropriate permissions to your manifest, in this case:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
You will need to add permissions when you use things like the internet and calling.
hi to all im having this problem.... can any one tell me what is causing the problem please....????
08-14 16:50:12.797: ERROR/Cursor(4453): Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com.paad.whereami/databases/adrite, table = books, query = SELECT _id, bookno, timeFrom, timeTo, lnk, booklink, dTime, Cbook, Cid, Cdate FROM booksdb
08-14 16:50:12.797: ERROR/Cursor(4453): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
08-14 16:50:12.797: ERROR/Cursor(4453): at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:210)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)
08-14 16:50:12.797: ERROR/Cursor(4453): at com.meme.whatami.elhgsdatabase.getAllInfo(elhgsdatabase.java:157)
08-14 16:50:12.797: ERROR/Cursor(4453): at com.meme.whatami.WhatAmI$7.run(WhatAmI.java:1331)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.os.Handler.handleCallback(Handler.java:587)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.os.Handler.dispatchMessage(Handler.java:92)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.os.Looper.loop(Looper.java:123)
08-14 16:50:12.797: ERROR/Cursor(4453): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-14 16:50:12.797: ERROR/Cursor(4453): at java.lang.reflect.Method.invokeNative(Native Method)
08-14 16:50:12.797: ERROR/Cursor(4453): at java.lang.reflect.Method.invoke(Method.java:521)
08-14 16:50:12.797: ERROR/Cursor(4453): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-14 16:50:12.797: ERROR/Cursor(4453): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-14 16:50:12.797: ERROR/Cursor(4453): at dalvik.system.NativeStart.main(Native Method)
After your call to "query" in com.meme.whatami.elhgsdatabase.getAllInfo(elhgsdatabase.java:157) call:
cursor.close();