I'm looking for a way to perform profiling (memory, cpu..) on my tested app (right now only Android profiling is needed).
Currently, I can only do this manually, by opening Android Studio and using its built-in profiling tools whenever I perform a test.
I was wondering if there was any way to integrate these tools into the Appium automation script, in order to scale-out the profiling to many devices and many test variations, and to save precious time.
Alternatively, if anyone knows of a similar tool that can be integrated into Appium I'd love to know about it.
For memory profiling, you can always pull down the "perflib" package in the Android Studio source. That is a more-or-less standalone package (with a couple of dependencies from within the sdktools parent package, which are standalone). The code in com.android.tools.perflib.heap is what you want, and that has all the methods to open an Android HPROF and process it.
As for other resources (CPU and whatnot), look at the viewers associated with them in Android Studio source (com.android.tools.idea.monitor), and look at the interactions with ClientData or adb commands used to fetch that data.
Related
I'm trying to profile an APK using Android Studio profiler in 3.0. Since I am not on Android 7.0 I have to explicitly turn on advanced profiling in the module config.
The issue is that once this is done, Android Studio is still saying "Advanced profiling is unavailable for the selected process".
The reason I explicitly have to turn this on, is because on API level < 26 Android Studio has to inject some logic into the compiled apk.
To show you advanced profiling data, Android Studio must inject
monitoring logic into your compiled app.
https://developer.android.com/studio/preview/features/android-profiler.html
Feedback I got from searching around is that I'm supposed to recompile / rebuild the APK after setting these Run / Debug settings. However I have not been able to find any clear official documentation on this.
But let's assume that it's the case, how would I do this since I don't have access to the source code (obviously).
You might be inclined to say that source code would be required to do this, but I'd like to hear why Android 8.0 is able to do this straight out of the box.
Standard profiling is working without any issue as well.
Would it be possible to inject the logic needed manually?
I have a go library that i want to run on android and use its methods in my android app. I could write the whole android app in go to make it easier to use this dependency. Is this possible? If so, how?
Download Termux (Linux Emulator) from google play store and open it.
Next, wait for it to perform an automatic download of its resources. After that operation, the run the following command:
pkg install golang
pkg install git
The got package is required when downloading golang packages.
Eventually, you can test it by running (go) command.
Golang support for mobile development has been steadily improving. Today it is even possible to build some simple all Go apps (depending on which features you need) as well as Go libraries. Please see https://github.com/golang/go/wiki/Mobile for more info.
UPDATE: In further improvement, libraries are being created to support even UI on mobile platforms. https://fyne.io provides rather robust set of features for mobile.
You can use a Go library from Java when developing for Android with gobind (see this example in the gomobile repository). The biggest issue with this is integration into the build system.
For Go 1.5 things are getting better, but you'll have to wait for that.
Disambiguation first: question is not about developing or compiling with openjdk code that would be run on dalvik in production. It is about using oracle runtime on android environment.
I'm using java for running small desktop utility application. I have no experience in Android and iOS development and I'm curious to which extent my classic java skills may be transferred to the mobile field.
I've googled couple of methods for running java application on iOS embedding runtime inside the application package. Android has its own partially incompatible and slow java virtual machine. It still is better than nothing, but I'm curious if it is possible to run application on genuine hotspot(openjdk) virtual machine. Android as well as iOS have the ability to run native code. May this ability be exploited to use third-party (non dalvik) jre on android?
I'm not interested on google play market so restrictions from it, if there are any, may not be taken into account.
Rooting is also possible since I'm going to write tools for myself. I would prefer methods that would be easy for installing. Like putting some package files and editing couple of options. And not build my own android distribution like CyanogenMod.
Without rooting the device, I don't think there is a way to do it.
Apparently, see http://openjdk.java.net/projects/mobile/android.html
The instructions are slightly out of date, I managed to do some hacking and get it to build though. Not sure if it runs yet
I have been working with standard android for some time. Recently I have been building android sdk for windows and find some interesting things in Android build env. There is a command called lunch which can be used to list all available targets to build. However, it does not list sdk and its variants,even though they are valid options.
Does anyone know why is that the case?
Also can I build any specific module in Android sdk without building the whole sdk. (It could be a great help as I dont wanna build the whole sdk, if I gonna do a small change in one component.)
Thanks
Under the hood, lunch uses make, so if some pieces of SDK do not change, they won't be rebuilt.
My speculation about your first question: rebuilding SDK was never considered a major task of lunch. It is most often used to port or mod the system and produce an installable system image, and receive the ADK as by-product. Later, people realized that often (with root access to the device) you can iterate over one component without need to reinstall the whole system image.
I have seen questions and topics in google referencing running JRE apps in the android environment, but I am actually thinking about the reverse.
I understand Android runs on a different runtime engine than the standard JRE.
Is it possible to build an app to run on android, but also build and run the same app in the JRE on a desktop?
I assume there would be restrictions on API usage, I was just thinking about the possibility to distribute a simple app that could be useful on both the device and the desktop.
I think the bigger problem here is going to be accessing the Android API and environment on your desktop. Do you have a plan for that?
If you have the Android environment running on your desktop then there shouldn't be any problem running your app there.
This answer offers an alternative suggestion.
Short answer: your desktop and Android app can share a large portion of code, but you aren't going to be able to run Android-specific code on the desktop.