Android Instrumentation with a common file - android

I am new to Instrumentation in android. So please help me to achieve this - I have an android apk with classes and methods in it. I need to monitor the time execution of all methods and classes in it using a kind of script file or some file(I mean to say for any apk this script/common file should hold good with some editing of the file like changing methods and classes name instead of editing it in every apk). Is there a way I could achieve this. Any kind of support would help me :)

Did this using AspectJ for Android and it is working :)

Related

android app particular java file used

How can i know which java file is used at the current time at that current interface. I know we can do this with a logcat when we know the source code , we can make everything log.i and stuff. but what happens when we don't know the source code or while assessing a black box android app
If you don't have access to the files how you supposed to know which file you are getting?
The best way to achieve what you want is to use a decompiler in your APK and do a debug.
http://www.decompileandroid.com/

Merge all Android project classes in one file with the Android Studio

I have maybe strange question, but would be appreciate if someone helps.
I need to merge all the code from classes ( which are part of the packages ) in one text or class file for Android project in Android Studio.
So I have for example such a structure
And I need to merge the code from NewAlbumDialog, MenuAdapter, MenuItem etc classes in one big file.
Maybe somebody know how can I do it with the Android Studio.
Would be appreciate your help.
I don't think there is a tool for this. Just use a text editor.
However be aware that a Java file is not valid as soon as it includes more than one public class - see Multiple classes in single file

Is it possible to download activities online and load them into tabs in Android?

Is it possible to download other people's examples, and load their code into tabs?
I don't know its your answer, what you are looking for it, (And As I understand your question)
Simple strategic logic. What about the code compilation, code build-up and make a .dex code for it?
Android .apk file is build up using .dex files and only executable, If you are adding new code then you have to compile those classes once again and make a new .apk file, I don't think any device provides such platforms for it. And if you want to do this on .apk file on your machine then you have to make some reverse engineering process and add newly download code into it, tehn again build up process for application.
No, all the activities must be declare in your Manifest
No you cannot load Activityes dynamically as they need to be declared in Manifest.
What you can do is to have WebView in your Activity and load their contents hosted some where, but this will be a Web Application rather a native Android application.

Modifying BOOTCLASSPATH in Android Building

This question is related to this other one. I have recompiled Android framework and generated a new image. I need to add some classes to the original framework and did it by adding new jars that go into /system/framework. I modified BOOTCLASSPATH to take into account these new jars.
Building the image and flashing to the device does not work. Some optimizations must be run prior to that, but I do not know how that process is.
What building steps should I execute before generating the image or what other alternatives do I have so the extended framework classes are accesible from applications?
I also changed the bootclasspath by changing one of the .mk files, adding my jar to a line that looks like this:
PRODUCT_BOOT_JARS += myjar
Then you just have to make the build and flash to the device just like what you said.
Sometimes it might not be enough and you'd have to erase this file:
./obj/ETC/init.environ.rc_intermediates/init.environ.rc
and then make again.
Hope that helps.

How to distribute the android reusable code in a package?

I have developed some reusable android component which is basically a class . This class has some resource dependencies e.g. some png drawables, some xml layouts etc. So this class referenced the auto-generated R file.I would like to distribute this code in a single package like jar file to other developers for use in their applications.
I have read that the only possible solution is to distribute code together with all my resources, which others have to copy to their "res" folder (source).
So I created a jar file having the class file (say MyClass which is in the package com.xyz.android.app) and resources and tried to use this in my new application.
So I added the jar file to my new applications build path using add external jars option in eclipse and copied all the resources to my new application's res folder. (The activity class say MainActivity of my new application is in com.abc.myapplication package, just for the case if it may helpful)
But when I run this new application there is java.lang.ClassCastException in the MyClass class. I tried to debug the application and then I found that in the MyClass class, there is "R cannot be resolved" problem.
Then I changed MainActivity's package to com.xyz.android.app (which is not the way, other developers will be happy to do), But again the same problem.
But When I just copy the source java file such that both MainActivity.java and MyClass.java are in com.xyz.android.app package then application runs fine.
So if I need to distribute such that other users need not to bother these package naming things,
how can I accomplish this? Please help !!
Edit
In android.jar, there are also some resources. How are they referenced in a project? How are they used in android classes? There is also android.R file?
Is it not possible to do the same thing i.e. to make jar file like android.jar for my reusable code?
As Nic Strong noted, there is nothing much built into the project to manage this, and current indications are that the upcoming changes to the SDK tools may only help a bit.
I am organizing some other tools to help deal with this problem. I hope to have developer documentation published in a few days.
This is not so easy to do at the moment. The problem is the project using your jar does not know to look in there for drawables etc.
The good news is it should soon be possible (hopefully with SDK 2.2 which is rumoured to be released at IO next week). See this blog post http://mobilebytes.wordpress.com/2010/04/27/android-tools-version6-coming/
I've been playing with Mark Murphy's ParcelHelper class at http://github.com/commonsguy/cwac-parcel. In a nutshell, it's a collection of methods that let you access the components of 'R' by name without needing to import 'R' into your code.
If I understand your question right, this is exactly what you want. You may still need to copy some resources, such as styleables, into your project.

Categories

Resources