The device has sdk with AP level 26, and the CTS test is also of level 26. But while running command > run cts-java facing error :
java.lang.RuntimeException: com.android.tradefed.targetprep.TargetSetupError: Failed to install CtsLibcoreTestCases.apk on 00002474. Reason: 'INSTALL_FAILED_OLDER_SDK: Failed parse during installPackageLI: /data/app/vmdl1133462583.tmp/base.apk (at Binary XML file line #0): Requires newer sdk version #27 (current version is #26)'
Investigation so far done :
Finding the apk version:
$ aapt dump badging ~/CTS/android-cts/testcases/CtsLibcoreTestCases.apk
package: name='android.libcore.cts' versionCode='26' versionName='8.0.0' platformBuildVersionName='8.0.0'
sdkVersion:'26'
targetSdkVersion:'26'
Finding device sdk version :
$ adb shell getprop ro.build.version.sdk
26
There is no conflict but still there is error arising. My hunch is the device or cts temp directory has stored previous apk data. I dont know how to remove it. Please suggest
have you resolve the issue?
I was experiencing the same and found the following undocumented behaviour, see bellow
Background
As I was testing previously devices based on Android 8.1 (SDK #27) I had corresponding CTS and VTS tests organised under a folder, e.g. TRADFED, then put under the same parent folder CTS for testing Android 8.0 (SDK #26) devices and was getting the same issue with not matching SDK version.
My structure looked something like this:
--TRADFED
|-- android-cts
|-- android-cts-media-1.4
|-- android-cts-verifier
`-- android-vts_81
Investigation
It turned out, that CTS were scanning the entire directory structure from its parent (TRAFED) for the test APKs and VTS contains same Cts*.apk under the testcases subfolder and it was rather trying to install those from VTS rather its own CTS location.
In conclusion
It looks like CTS are pretty selfish and aggressive and scans the entire parent folder for any suitable Cts*.apk apps regardless it sit in completely outside of CTS location.
Related
I am returning to work on an old app that I left 7 months ago. The build that is deployed on my android is not up to date with the version control rather I have made more changes to the code in the hope of adding some functionality when I abandoned. The result is that the code running on the emulator now is different than what is running on my device. Now I want to get back to not the latest version in repository, not the one on the emulator but the one that is deployed on my device. Is there a way to find that out?
You can use the badging options of Android Asset Packaging Tool (aapt).
First you need to extract the APK from your device:
adb shell pm path com.example
The output will be like package:/data/app/com.example-2.apk
Then pull the APK with this command:
adb pull /data/app/com.example-2.apk
After that use aapt:
<sdk_dir>/build-tools/23.0.2/aapt dump badging com.example-2.apk
The output will be something like this:
package: name='com.example' versionCode='1' versionName='1.0.0'
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
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.
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.
I am unable to start my android emulator in eclipse . I get hit with the following error message always
"Failed to start emulator: Cannot run program "/Users/anandmadhusoodanan/Desktop/Assignments/Spring-2012/Embedded_Systems_Programming/android-sdk-macosx//tools/emulator": error=1, Operation not permitted" where
"/Users/anandmadhusoodanan/Desktop/Assignments/Spring-2012/Embedded_Systems_Programming/android-sdk-macosx" is the path of my sdk.
I have tried re-installing the ADT plug-in, the sdk and even eclipse.
I am using Mac OS.
The # symbol indicates that there are extended attributes for the files in question. To verify the extended attributes applied to the files use:
ls -l#
You'll probably find (as I did) that there is a com.apple.quarantine attribute on the files which can be removed with:
xattr -dr com.apple.quarantine sdkFolder
Where sdkFolder should be replaced with the name of the folder you extracted the SDK to.
Check that you have execute permissions on the emulator
Try
$chmod 755 emulator
For Android 2.3, I use this command line to enter CTS consoleļ¼
java -Xmx512M -cp
%CTS_ROOT%\tools\ddmlib-prebuilt.jar;%CTS_ROOT%\tools\cts.jar;%CTS_ROOT%\tools\junit.jar;
%CTS_ROOT%\tools\hosttestlib.jar com.android.cts.TestHost
%CTS_ROOT%\repository/host_config.xml
Is there a similar way of running Android 4.0 CTS like this without cygwin-like thing?
For run Android 4.0+ CTS on Windows
here is my solution:(I assume all path(adb)/classpath(Java) is set correct)
1.download and unzip CTS file(for example,I put all unzipped files into D:\cts , the folder will look like D:\cts\android-cts)
http://source.android.com/compatibility/downloads.html
2.make cts_windows.bat file and put into tools folder.
(that is D:\cts\android-cts\tools\cts_windows.bat in my case)
edit cts_windows.bat file with code below (remember to use your own -DCTS_ROOT path):
java -cp ddmlib-prebuilt.jar;tradefed-prebuilt.jar;hosttestlib.jar;cts-tradefed.jar -DCTS_ROOT=D:\cts com.android.cts.tradefed.command.CtsConsole
execute cts_windows.bat file and it will into a shell like "cts-tf>"
then you can run cts using " run cts --plan CTS " command.
for more instructions, read manual at
http://source.android.com/compatibility/android-cts-manual-r4.pdf
For the 4.1 CTS Suite I performed different tasks that resolved my issue.
For windows users running Cygwin:
Modify JAR_PATH setup on line 81, replace the colon with a semi-colon.Also add quotes around the assignment. It should look like the command below:
Bad: JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
Good: JAR_PATH="${JAR_PATH};${JAR_DIR}/${JAR}"
Be sure to run the cts-tradefed script inside the same directory!
Line 73 assumes if CTS_ROOT is not defined then the user is in the same directory as cts-tradefed. But the instructions tell the person to run the script from the directory cts-android is in.
Good: ./cts-tradefed
Bad: ./android-cts/tools/tradefed
Am able to run CTS on Windows, The above Exception is resolved by passing the proper CTS root directory.
By default CTS refers android-cts as root directory, So we should maintain folder as "D:\Android\android-cts"
Pass -DCTS_ROOT=D:\Android
So " Caused by: java.io.FileNotFoundException: CTS install folder D:\cts\android-cts " will be resolved.
java -cp ddmlib-prebuilt.jar;tradefed-prebuilt.jar;hosttestlib.jar;cts-tradefed.jar
-DCTS_ROOT=D:\Android com.android.cts.tradefed.command.CtsConsole
With above script am able to RUN CTS on my user device.
Thanks.,
Ganesh Kumar Ramamoorthy
I wouldn't recommend to run CTS on Windows.
Until Android 4+, the use of workaround suggested here (use batch file) did worked but when I've tried it, there were many failures and many tests even not executed at all.
Also, according to Google CTS documentation, it should run on Linux or MAC only so how you can guarantee that failures are because of the device under test (real failure), or because you're running it in not supported environment?
Nevertheless, as of Android 6+, the use of batch file in Windows didn't worked for me, CTS will look for bash which exists only in Linux machine and will quit the execution before it starts.
When try to run in on Linux it runs beautifully.
I am trying to attach the ndk-gdb to my Android application.
I am using is Android-ndk-r6b and device is Android 2.3,Samsung Galaxy S II.
I followed all the steps in this example Click here for the example
And also I tried with one application, when I am trying to attach gdb with another application but the verbose showing that it is always getting attached to the first application itself
Found package name: <1st attached package name>
I tried to launch the ndk-gdb using this command for the first time:
ndk-gdb --start --force --verbose
I tried to attach to another application with the below command but not able to succeed:
ndk-gdb --launch=com.example.hellogdbserver.HelloGdbServer --force --verbose
I am always getting the below error with first application:
ERROR: Non-debuggable application installed on the target device.Please re-install the debuggable version!
This is complete shell log which i am getting
sh-4.1$ ndk-gdb --verbose --start --force
Android NDK installation path: /cygdrive/c/Android/android-ndk
Using default adb command: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.26
Using final ADB command: '/cygdrive/c/Android/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: /cygdrive/d/EclipseTestWorkspace/hello-gdbserver
Found package name: com.example.hellogdbserver
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.hellogdbserver/lib/gdbserver
Using gdb setup init: /cygdrive/d/EclipseTestWorkspace/hello-gdbserver/libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/c/Android/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: /cygdrive/d/EclipseTestWorkspace/hello-gdbserver/obj/local/armeabi
ERROR: Could not extract package's data directory. Are you sure that
your installed application is debuggable?
sh-4.1$
Please let me know how can I resolve the above error and also how to attach to new package.
My phone is not rooted. Hope this wont affect the gdb.
This was not helpful as well Link to similar problem. As my phone is new phone and dont have any app, other than the current developing app. (Only packages which come along with the Samsung phone are present. No app is downloaded from the market. )
Thanks & Regards,
SSuman185
Please go through the link Debugging native code in android app using the android ndk gdb
Please first ensure that you are building the debuggable version of the app. The AndroidManifest.xml file should include the android:debuggable="true" tag.
You can also check it by finding the APK file in the bin directory, unpacking it (it's just a renamed ZIP file) and ensuring that lib\armeabi folder contains the gdbserver file.
If both conditions above are met, try installing the package on the device manually:
<android-sdk>\platform-tools\adb.exe install -r <your-package-file.APK>
Please carefully observe the output of adb.exe. If it displays an error, it might explain your problem.
This problem will arise if you try to debug a library project.
ndk-gdb is unable to attach to a project that is not the "main" one.
You have to put your jni code into the starting application project.
make sure you have APP_OPTIM in jni/Application.mk set to debug
According to http://developer.samsung.com/forum/thread/ndk-debugging-with-gdb/77/178834 some Samsung phones are not native debuggable without rooting because run-as is broken
See run-as Package 'a.b.c' is unknown - Galaxy S4 Jellybean or Android 4.3 for my solution