Emulator problem

William Hunter

Active Member
Licensed User
Longtime User
I am having a problem with the emulator. I can compile an app and it will install to the emulator, but will only partially run. The app hangs as soon as it starts to run, and I will get a Forced Shutdown message. This is not isolated to a project in the works. This even happens with a completed project that I have in service and know to be sound. Using Debug doesn't help, as nothing registers in Debug.

When the emulator is running it seems to slow down my system quite a bit. Such things as starting Internet Explorer are affected. I initially thought it might be Zone Alarm FW or Avast AV that was causing the problem, but shutting them down does not correct the problem.

The emulator seems to be the culprit. I am running Windows7. Has anyone else experienced this problem, and found the solution?

Any help would be greatly appreciated. :sign0085:

I have finally been able to record the filtered log, an have added it below. Both the current project in the works and the completed project used for testing use the AHPreferenceManager, but I should point out that projects NOT using this library are affected as well. However, in their case I could get no recorded logging.
B4X:
LogCat connected to: emulator-5554
** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


** Activity (main) Pause, UserClosed = false **


java.lang.RuntimeException: Unable to start activity ComponentInfo{mail.purge/anywheresoftware.b4a.objects.preferenceactivity}: java.lang.NullPointerException


   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
   at android.app.ActivityThread.access$2300(ActivityThread.java:125)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:123)
   at android.app.ActivityThread.main(ActivityThread.java:4627)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
   at anywheresoftware.b4a.objects.preferenceactivity$PreferenceCategoryWrapper.createPreference(preferenceactivity.java:452)


   at anywheresoftware.b4a.objects.preferenceactivity$PreferenceScreenWrapper.createPreference(preferenceactivity.java:224)
   at anywheresoftware.b4a.objects.preferenceactivity.onCreate(preferenceactivity.java:65)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
   ... 11 more
 
Last edited:

Kevin

Well-Known Member
Licensed User
Longtime User
It sounds as though your apps work fine on a real device. Here are some things to try but one thing of note is that running apps on an emulator are not really a good representation of "real world" performance.

Usually I just get 'app has stopped responding' errors when running on an emulator and the reason for that is because they are very very slow (and yes, they can slow down your entire system because they are using a lot of your computer's processor and memory in order to run the AVD).

Because you are getting a Null Pointer Exception, it could still be related to being run on an AVD. One possible reason is that it is killing off other processes or old activities in order to free up resources. If this is the case, you may need to add some code to check that processes are still around before trying to use them. I don't know what your code is like in reference to your error but to give you an example I would sometimes have crashes in my app if the tried changing a label in another activity but the activity was no longer in memory at all. This of course resulted in a NPE error. This would happen on AVDs but only occasionally on my real device. I found a way to force it to happen by browsing the internet while my app was "paused" then returning to it. Because Android had killed part of my app in order to make room for the browser app, the result was a NPE when I would try to do certain things in my app after returning to it.

So you may need to check to see if the activity or variables that you are trying to use with the PreferenceActivity are still around before trying to use it. One way to do that in regards to activities is to use the new CallSubDelayed command although I don't know if that is applicable to PreferenceActivity because I don't use that in my apps.

Other things to try:

  • Make sure you have set your AVD up with a decent amount of "RAM"
  • Try running your app on a less demanding AVD, such as one with a smaller screen resolution and size configuration and lower SDK (i.e. Android 2.3 rather than 4.0)
Good luck!

NPE errors were my biggest nemesis while learning to work with B4A and Android. Eventually things settled in and I learned how to avoid them and code my apps better. Again though, this could just be an AVD issue. Running my app on an AVD on my main PC may work fine, where as running my app on that same AVD on my notebook may be very slow if it ever starts at all.
 
Last edited:
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
Make sure you have set your AVD up with a decent amount of "RAM"
Thank you for your reply. Your suggestion that it might be a resource problem seems to be correct. I was having a coding problem and was looking for info on the B4A sight. After finding what info I had needed, I left the Internet connection open while I continued to work. That’s when the problems started, and things fell apart. You live and you learn.

When you refer to a decent amount of RAM, are you referring to heap size?

Regards
 
Upvote 0

PFlores81

Active Member
Licensed User
Longtime User
This is the exact reason I refuse to use the emulator. If you can spare some cash, pickup a used android device from Craigslist or a prepaid one and use that for development. I myself have done this and it works out great. Make sure its a phone you can fix or reflash if need be if you change something you weren't meaning to.

HTC = Hate The Consumer
 
Upvote 0
Top