How can I run samples on emulator?

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

How can I run samples on emulator?

Postby MDW » Mon Oct 13, 2008 10:45 am

Hi!

I'm going to learn developing for Android platfrom. I've already downloaded and installed Android SDK. Later I wrote HelloAndroid and it works but emulator behaves strange. If I can't run for example "Snake" from "samples" folder. Could someone help me?

I do these steps:

1. Create new project in Eclipse (3.4) with Snake-sources.

2. Everything is compiled ok.

3. Run HelloAndroid in emulator.

4. Emulator starting 30-50 seconds (it's long time, why?).

5. Now I see on the emulator screen (look at attached screenshot).

6. On console I see this log:
[2008-10-13 11:19:06 - Snake] ------------------------------
[2008-10-13 11:19:06 - Snake] Android Launch!
[2008-10-13 11:19:06 - Snake] adb is running normally.
[2008-10-13 11:19:06 - Snake] Launching: com.example.android.snake.Snake
[2008-10-13 11:19:06 - Snake] Automatic Target Mode: launching new emulator.
[2008-10-13 11:19:06 - Snake] Launching a new emulator.
[2008-10-13 11:19:08 - Snake] New emulator found: emulator-5554
[2008-10-13 11:19:08 - Snake] Waiting for HOME ('android.process.acore') to be launched...
[2008-10-13 11:19:29 - Snake] HOME is up on device 'emulator-5554'
[2008-10-13 11:19:29 - Snake] Uploading Snake.apk onto device 'emulator-5554'
[2008-10-13 11:19:29 - Snake] Installing Snake.apk...
[2008-10-13 11:19:39 - Snake] Success!
[2008-10-13 11:19:39 - Snake] Starting activity com.example.android.snake.Snake on device
[2008-10-13 11:19:42 - Snake] ActivityManager: Starting: Intent { comp={com.example.android.snake/com.example.android.snake.Snake} }

7. If I click MENU key, I get message "Sorry! Process com.android.phone is not responding." and I can click "Force close" or "Wait".

What should I do? What mistake I made? Why I can't run examples on emulator?

If I try run HelloAndroid, I have the same result. But if I click MENU key and later choose option "Wait" in message, I see text "Hello Android" on emulator screen. Is it typical behaviour of the emulator?

Could someone help me?
Attachments
emu.jpg
emu.jpg (33.4 KiB) Viewed 10484 times
MDW
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 13, 2008 9:18 am
Location: Poland

Top

Postby MrSnowflake » Mon Oct 13, 2008 12:21 pm

The emu just takes a long time to load. Remember it's an emulator, so preformance is probably slower than a real device.
There aren't any errors in the output, so just click 'Wait' (you'll see this error now and then when stating the emulator). And just wait for your app to come up.

MDW wrote:If I try run HelloAndroid, I have the same result. But if I click MENU key and later choose option "Wait" in message, I see text "Hello Android" on emulator screen. Is it typical behaviour of the emulator?
Uhm, ... the text "Hello Android" __IS__ the HelloAndroid activity running!
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby MDW » Mon Oct 13, 2008 12:25 pm

Thank you for the answer. You are very helpfuly. :)

MrSnowflake wrote:
MDW wrote:If I try run HelloAndroid, I have the same result. But if I click MENU key and later choose option "Wait" in message, I see text "Hello Android" on emulator screen. Is it typical behaviour of the emulator?
Uhm, ... the text "Hello Android" __IS__ the HelloAndroid activity running!


Of course it is. However when I try run one of examples (for example Snake), I don't see anything after click to "Wait". :( What should I do?
MDW
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 13, 2008 9:18 am
Location: Poland

Postby MrSnowflake » Mon Oct 13, 2008 12:27 pm

Is that the end of the log, you posted up there ^^?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby MDW » Mon Oct 13, 2008 12:35 pm

MrSnowflake wrote:Is that the end of the log, you posted up there ^^?


Yes, it is the end of the log.
MDW
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 13, 2008 9:18 am
Location: Poland

Postby MrSnowflake » Mon Oct 13, 2008 12:40 pm

Ow, I see now, it's the Eclipse log. You should look at the logcat: Open a command-line (cmd) and go to the android/tools directory. Then execute:
Code: Select all
adb logcat

If you can't see the error in there, post the result of logcat here (after you ran the app). We'll help you on from there.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Postby MDW » Tue Oct 14, 2008 7:51 am

I see LogCat in Eclipse but not always. :)

I've already ran ApiDemos. It works! :) Snake still can't run. However it is probably problem in sources of Snake. Look at the logs:

Code: Select all
D/AndroidRuntime(  154): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  154): CheckJNI is ON
D/dalvikvm(   50): GC freed 4723 objects / 247296 bytes in 519ms
D/AndroidRuntime(  154): --- registering native functions ---
D/SystemClock(   85): Setting time of day to sec=1223899091
W/SystemClock(   85): Unable to set rtc to 1223899091: Invalid argument
D/PhoneApp(   85): [CallNotifier] onMwiChanged(): false
D/PhoneApp(   85): [CallNotifier] onCfiChanged(): false
I/ActivityManager(   50): Starting activity: Intent { flags=0x10000000 comp={com
.example.android.snake/com.example.android.snake.Snake} }
D/AndroidRuntime(  154): Shutting down VM
D/dalvikvm(  154): DestroyJavaVM waiting for non-daemon threads to exit
I/dalvikvm(  154): DestroyJavaVM shutting VM down
D/dalvikvm(  154): HeapWorker thread shutting down
D/dalvikvm(  154): HeapWorker thread has shut down
D/jdwp    (  154): JDWP shutting down net...
D/dalvikvm(  154): VM cleaning up
D/dalvikvm(  154): LinearAlloc 0x0 used 539340 of 4194304 (12%)
I/jdwp    (  114): received file descriptor 24 from ADB
I/jdwp    (  124): received file descriptor 26 from ADB
I/ActivityManager(   50): Start proc com.example.android.snake for activity com.
example.android.snake/.Snake: pid=162 uid=10019 gids={}
I/jdwp    (  162): received file descriptor 10 from ADB
D/dalvikvm(   50): GC freed 2481 objects / 176696 bytes in 248ms
I/ActivityManager(   50): Start proc com.android.alarmclock for broadcast com.an
droid.alarmclock/.AlarmInitReceiver: pid=168 uid=10000 gids={}
I/jdwp    (  168): received file descriptor 13 from ADB
I/ActivityManager(   50): Displayed activity com.example.android.snake/.Snake: 1
963 ms
D/PhoneApp(   85): [CallNotifier] onMwiChanged(): false
D/PhoneApp(   85): [CallNotifier] onCfiChanged(): false
I/ActivityManager(   50): processNextBroadcast: waiting for ProcessRecord{434ad3
e8 168:com.android.alarmclock/10000}
W/StkAppInstaller(   85): Could not change STK app state
I/ActivityThread(  168): Publishing provider com.android.alarmclock: com.android
.alarmclock.AlarmProvider
D/TelephonyProvider(   85): Setting numeric '310260' to be the current operator
D/MobileDataStateTracker(   50): CONNECTED event did not supply interface name.
D/MobileDataStateTracker(   50): DNS server addresses are not known.
E/NetworkStateTracker(   50): Can't set tcp buffer sizes:java.io.FileNotFoundExc
eption: /sys/kernel/ipv4/tcp_rmem_min
D/GpsLocationProvider(   50): updateNetworkState available
D/GpsLocationProvider(   50): NetworkThread out of wake loop
D/GpsLocationProvider(   50): Requesting time from NTP server pool.ntp.org
I/CheckinService(   50): Checkin triggered: Intent { action=android.server.check
in.CHECKIN flags=0x4 (has extras) }
I/CheckinService(   50): Checkin disabled by system property
D/SntpClient(   50): round trip: 69 ms
D/SntpClient(   50): clock offset: 21479 ms
D/GpsLocationProvider(   50): calling native_inject_time: 1223899117634 referenc
e: 42175 certainty: 34
D/GpsLocationProvider(   50): NetworkThread wait for 14400000ms
I/ActivityManager(   50): Start proc android.process.media for broadcast com.and
roid.providers.downloads/.DownloadReceiver: pid=176 uid=10003 gids={1006, 3003,
2001}
I/jdwp    (  176): received file descriptor 20 from ADB
I/ActivityThread(  176): Publishing provider downloads: com.android.providers.do
wnloads.DownloadProvider
I/ActivityThread(  176): Publishing provider drm: com.android.providers.drm.DrmP
rovider
D/dalvikvm(   50): GC freed 2334 objects / 99072 bytes in 219ms
I/ActivityThread(  176): Publishing provider media: com.android.providers.media.
MediaProvider
V/MediaProvider(  176): Attached volume: internal
D/MediaScannerService(  176): start scanning volume internal
I/ActivityManager(   50): Stopping service: com.android.providers.downloads/.Dow
nloadService
D/AndroidRuntime(  162): Shutting down VM
W/dalvikvm(  162): threadid=3: thread exiting with uncaught exception (group=0x4
0010e28)
E/AndroidRuntime(  162): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime(  162): java.lang.IndexOutOfBoundsException: Invalid location 0
, size is 0
E/AndroidRuntime(  162):        at java.util.ArrayList.get(ArrayList.java:350)
E/AndroidRuntime(  162):        at com.example.android.snake.SnakeView.updateSna
ke(SnakeView.java:449)
E/AndroidRuntime(  162):        at com.example.android.snake.SnakeView.update(Sn
akeView.java:404)
E/AndroidRuntime(  162):        at com.example.android.snake.SnakeView.setMode(S
nakeView.java:336)
E/AndroidRuntime(  162):        at com.example.android.snake.SnakeView.onKeyDown
(SnakeView.java:279)
E/AndroidRuntime(  162):        at android.view.KeyEvent.dispatch(KeyEvent.java:
718)
E/AndroidRuntime(  162):        at android.view.View.dispatchKeyEvent(View.java:
3153)
E/AndroidRuntime(  162):        at android.view.ViewGroup.dispatchKeyEvent(ViewG
roup.java:734)
E/AndroidRuntime(  162):        at android.view.ViewGroup.dispatchKeyEvent(ViewG
roup.java:734)
E/AndroidRuntime(  162):        at android.view.ViewGroup.dispatchKeyEvent(ViewG
roup.java:734)
E/AndroidRuntime(  162):        at com.android.internal.policy.impl.PhoneWindow$
DecorView.superDispatchKeyEvent(PhoneWindow.java:1557)
E/AndroidRuntime(  162):        at com.android.internal.policy.impl.PhoneWindow.
superDispatchKeyEvent(PhoneWindow.java:1080)
E/AndroidRuntime(  162):        at android.app.Activity.dispatchKeyEvent(Activit
y.java:1856)
E/AndroidRuntime(  162):        at com.android.internal.policy.impl.PhoneWindow$
DecorView.dispatchKeyEvent(PhoneWindow.java:1528)
E/AndroidRuntime(  162):        at android.view.ViewRoot.deliverKeyEvent(ViewRoo
t.java:1616)
E/AndroidRuntime(  162):        at android.view.ViewRoot.handleMessage(ViewRoot.
java:1114)
E/AndroidRuntime(  162):        at android.os.Handler.dispatchMessage(Handler.ja
va:88)
E/AndroidRuntime(  162):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  162):        at android.app.ActivityThread.main(ActivityThrea
d.java:3742)
E/AndroidRuntime(  162):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(  162):        at java.lang.reflect.Method.invoke(Method.java:5
15)
E/AndroidRuntime(  162):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:739)
E/AndroidRuntime(  162):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:497)
E/AndroidRuntime(  162):        at dalvik.system.NativeStart.main(Native Method)

D/dalvikvm(   50): GREF has increased to 201
I/Process (   50): Sending signal. PID: 162 SIG: 3
I/dalvikvm(  162): threadid=7: reacting to signal 3
I/dalvikvm(  162): Wrote stack trace to '/data/anr/traces.txt'
I/ActivityManager(   50): Stopping service: com.android.providers.downloads/.Dow
nloadService
D/MediaScanner(  176):  prescan time: 1156ms
D/MediaScanner(  176):     scan time: 290ms
D/MediaScanner(  176): postscan time: 1ms
D/MediaScanner(  176):    total time: 1447ms
I/ActivityManager(   50): Stopping service: com.android.mms/.transaction.Transac
tionService
D/MediaScannerService(  176): done scanning volume internal
I/ActivityManager(   50): Stopping service: com.android.providers.media/.MediaSc
annerService
I/ActivityManager(   50): Stopping service: com.android.mms/.transaction.SmsRece
iverService
I/ARMAssembler(   50): generated scanline__00000077:03515104_00000000_00000000 [
27 ipp] (41 ins) at [0x1fcc10:0x1fccb4] in 3033819 ns
D/dalvikvm(   85): GC freed 3587 objects / 187240 bytes in 437ms
D/dalvikvm(   90): GC freed 3137 objects / 170232 bytes in 77ms
D/dalvikvm(  114): GC freed 2343 objects / 129864 bytes in 91ms


Thank you for help. Other samples work well so I can learn.
MDW
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 13, 2008 9:18 am
Location: Poland

Postby MrSnowflake » Tue Oct 14, 2008 7:56 am

E/AndroidRuntime( 162): java.lang.IndexOutOfBoundsException: Invalid location 0
, size is 0
E/AndroidRuntime( 162): at java.util.ArrayList.get(ArrayList.java:350)
E/AndroidRuntime( 162): at com.example.android.snake.SnakeView.updateSna
ke(SnakeView.java:449)
There you have it. Somewhere you try to access arrayList.get(0) in your code (lin 449 of SnakeView.java) but the array has length 0 so, arrayList.get(0) doesn't exist!
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby MDW » Tue Oct 14, 2008 9:09 am

MrSnowflake wrote:E/AndroidRuntime( 162): java.lang.IndexOutOfBoundsException: Invalid location 0
, size is 0
E/AndroidRuntime( 162): at java.util.ArrayList.get(ArrayList.java:350)
E/AndroidRuntime( 162): at com.example.android.snake.SnakeView.updateSna
ke(SnakeView.java:449)
There you have it. Somewhere you try to access arrayList.get(0) in your code (lin 449 of SnakeView.java) but the array has length 0 so, arrayList.get(0) doesn't exist!


You are right. However it isn't my code. It is example from Android samples folder. :) Thank you for help.
MDW
Freshman
Freshman
 
Posts: 5
Joined: Mon Oct 13, 2008 9:18 am
Location: Poland

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 11 guests