Frage

I've managed to build two examples provided by kivy on Ubuntu 12.04 64-bit and to run those on my Nexus 4 device following basically these instructions given on the python-for-android websites using this command:

./build.py --package org.test.touchtracer --name touchtracer --version 1.0 --dir /home/bernhard/Development/kivy/examples/demo/touchtracer debug

For further development and the necessary debugging, I'd like to test my compiled python programs on the Android emulator, because copying the app to the device is a bit cumbersome & takes quite long time to transfer, I think (please correct me if you think this is not true - I have no experience yet).

So, I've created an AVD with the Android SDK Manager [19.0.2] running Android 4.4.2 on an emulated Nexus 4 device. When I start the emulator a new window appears showing 'android' in a shiny font, but nothing else happens, seems like a frozen (emulated) device (i.e. I can't interact with the emulator). The AVD Manager lists this AVD located in my ~/.android/avd as "A valid Android Virtual Device". I've tried both Intel Atom (x86) and ARM armeabiv7a as CPU, but nothing. Since I couldn't find good instructions on how to copy & test my python apps on the emulator, I've tried the following naively changed the debug option from above to installd

./build.py --package org.test.touchtracer --name touchtracer --version 1.0 --dir /home/bernhard/Development/kivy/examples/demo/touchtracer installd

But mostly I get this:

install:
    [echo] Installing /home/bernhard/Development/python-for-android/dist/default/bin/touchtracer-1.0-debug.apk onto default emulator or device...
    [exec] error: device not found
    [exec] - waiting for device -
    [exec] rm failed for /data/local/tmp/touchtracer-1.0-debug.apk, No such file or directory

BUILD FAILED
    /home/bernhard/Development/android-sdk-linux/tools/ant/build.xml:1364: The following error occurred while executing this line:
    /home/bernhard/Development/android-sdk-linux/tools/ant/build.xml:1378: exec returned: 1

Total time: 51 seconds
Traceback (most recent call last):
  File "./build.py", line 412, in <module>
    make_package(args)

 File "./build.py", line 336, in make_package
   subprocess.check_call([ANT, arg])
 File "/usr/lib/python2.7/subprocess.py", line 511, in check_call
   raise CalledProcessError(retcode, cmd)
 subprocess.CalledProcessError: Command '['ant', 'installd']' returned non-zero exit status 1

This is confusing because the emulator is running. Once I got something more promising, which still did not change the emulator output:

install:
     [echo] Installing /home/bernhard/Development/python-for-android/dist/default/bin/touchtracer-1.0-debug.apk onto default emulator or device...
     [exec] 979 KB/s (6559511 bytes in 6.542s)
     [exec] WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
     [exec] Error: Could not access the Package Manager.  Is the system running?

installd:

BUILD SUCCESSFUL

or:

install:
     [echo] Installing /home/bernhard/Development/python-for-android/dist/default/bin/touchtracer-1.0-debug.apk onto default emulator or device...
     [exec] 988 KB/s (6559511 bytes in 6.482s)
     [exec] WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
     [exec]     pkg: /data/local/tmp/touchtracer-1.0-debug.apk
     [exec] - waiting for device -
     [exec] rm failed for /data/local/tmp/touchtracer-1.0-debug.apk, No such file or directory

I'm sorry to be so imprecise with the different outputs, I don't understand the reasons for the differences myself. I think it can have to with the fact that the real device was connected just before one trial, or that I've deleted all touchtracer* files in my python-for-android/dist/default/bin folder. So, finally my questions:

1) Am I using the build command correctly to install the compiled code on the emulator?

2) Why is the emulator only showing a shiny 'android' lettering without any possibility to interact?

3) Do you know any good links / tutorials on how to use an Android emulator on Ubuntu?

Many thanks in advance! Best regards, Bernhard

War es hilfreich?

Lösung

It sounds like your Android emulator is not running properly. The first run of a new AVD or is excruciatingly slow, especially on an older computer. It can literally take 10-20 minutes to get to the Android desktop if your CPU is slow.

One thing you need to make sure of is that your AVD has "Use host GPU" selected in its options. Kivy will not run on the Android emulator without that option. However it sounds to me like you never get to the point of your AVD booting completely.

Andere Tipps

I'm not clear on what your problem actually is.

Are you saying that without the emulator, your apk does build fine? I ask because the existence of the emulator shouldn't really make a difference to anything. You can test this by stopping the emulator, using the build command, and manually copying the apk to your device.

(It does look like your build sometimes completes successfully. Even if it can't copy to a device, it will be in the bin directory.)

You can upload the apk to the phone in multiple ways (even just emailing it), but the easiest way is to use the adb tool from the android sdk - plug your phone into the computer, turn on its developer mode, and run adb install /path/to/apk. This should only take a few seconds.

because copying the app to the device is a bit cumbersome & takes quite long time to transfer, I think (please correct me if you think this is not true

My above paragraph also addresses this. It's very simple and easy to install with adb, I do it all the time when developing for android. Actually, it's probably competitive with using the emulator, since both ways are ultimately typing the same command and transferring to a device (real or emulated).

I also recommend using the buildozer tool, which is a nice wrapper around the android build process with a more convenient interface. It's also capable of downloading appropriate android dependencies on its own, and interfacing with adb.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top