A friend of mine used my phone to test an application he was creating in android studio. Long story short, the app is still on my phone and i was trying to figure out how i could take the app FROM my phone and export it onto Android Studio so that i could fiddle with it myself. I already asked my friend how to do that and he said he couldn't find anything on it so i thought it would be wiser to instead bring the situation to you fine folks.
Extracting the APK (compiled application file) from the phone may be possible under some conditions, but importing it in to Android Studio is not.
The application exists on the phone in a compiled state, not as a Studio project.
There are tools to decompile Android applications, but if you were to decompile it all the way to the Java level, it may not compile back.
It is possible to make small tweaks if you decompile the application to smali, which is similar to assembly, but easier to read.
There are two ways to extract the APK from the phone:
If your phone is rooted, you can use an app like RootExplorere or you can use ADB running in root mode to pull the APK to the PC.
Use:
adb shell pm path app.package.name
to find out where the APK is stored, then use:
adb pull <path to apk>
to extract it to the PC.
If your phone is not rooted, but your friend did not disable backup of his app, you can create a backup and extract the APK from it.
Use this ADB command:
adb backup -apk -f backup.ab app.package.name
Then use this tool to unpack the backup file.
Once you have the APK, you can use ApkTool to decompile, analyze and tweak it.
There are many more advance decompilers out there for Android, but your mileage may very.
Related
As title says, I need to extract files from .rar file and save it on device storage. There are third party tools which supports this. But I was wondering is there any adb /appium /android utility command which provides this functionality ?
There's no way to do this without using a third party tool or app. See the Android Developer reference for ADB.
If use of third party tools is not out of the question for you (you refer to Appium, after all), and you just want to be able to extract the .rar file from the command line, you might try installing an app which can extract .rar files (there are many) and access the correct activity from the command line using the activity manager. You can view the activities available to you for a given APK using the Android Asset Packaging Tool and this command:
aapt dump xmltree <path to APK> AndroidManifest.xml
I would install busybox on your device. This will give you all the commands needed to allow for unzipping the files on your phone. Just disable auto update if you are worried about the application updating.
I have C Linux based application and now I want to port it to Android.
I figured out, that I can extract the toolchain from Android NDK and build my application, but how to make the APK such that I can install it on the android devices without the need of root access.
In Linux, I used to install it using a bash script which used to put my application related files in different folders like /opt, /etc (files shared with other applications) and /var . How can we handle this in Android. Is there a folder similar to /etc in Android where I can put files that other applications can read.
Thanks
-M
First of all, you are lucky if your project compiles "as is" with NDK standalone toolchain. Often, bionic is not enough, and people need to tweak the build environment (from libpthread to full-blown buildroot alternate toolchain with static C runtime).
As for the shared files location, on Android it's named "external storage". Your app and other app may require special permissions to write and read to this location. Directory /opt does not exist here. You don't have write access to /etc, but files like /etc/hosts are available for read.
Regarding the APK. You are right, this is the ultimate way to distribute and install apps on Android. But you can, even without root, to locally install and run a command-line executable. Usually it's done with Developers Options turned on, and enabled USB debugging. Now you can open an adb shell, install and run your program. The trick is that external storage (see above) is marked as 'non-executable'. Therefore, you must find another place for your binary. Usually, /data/local/tmp will be a good choice.
Instead of adb, you can use a terminal emulator on the device.
If you choose to build an APK, you will probably prefer to convert your app to shared library that will perform actions for Java via JNI. But it is also possible to package your command-line binary as part of the APK and use Java Runtime.exec().
As the question title states, can I install node.js on Android without root? I have a couple terminal emulator apps and at least one of them has BusyBox, git, and adp, among other things, though I am severely limited in what I can do with them. For example, I can not just git clone the node.js source code, as "No auth methods c[an] be used". I can download the node.js source code, but it seems to be under the "system_server" user as soon as it's downloaded, which I assume is the root user or very close. I am able to unpack it, but unable to run the configure executable in this directory, I assume because it is owned by root as soon as it is downloaded.
Am I trying the right approach here? I have heard about anode, but its wiki is empty and whatever instructions it has are confusing and do not say whether I need to be root. Everything else I have seen tells me I have to have a rooted Android to install node.js, but I hate to give up after so much effort.
Instead installing node.js on the android device, try jxcore.
You can download an android executable binary from its download page, and execute it from the terminal emulator. Remember to set up exec flags.
EDIT: jxcore seems no longer under development.
I downloaded the c4droid app for Android and am running commands through system();. I'm learning that somethings work while others don't. Most of the cool stuff don't work and this appears to be due to my user profile not being given the rights to execute such commands at the Linux OS level.
So tried another experiment. I got a special Gnu compiler for the arm processor and compiled a simple hello world app. Then I put on my phone and tried to execute it through the c4droid app like system("./myapp.bin"); . I got a permission denied message.
So I'm just trying to understand what I can do and what I can't do on my phone that paid good money for? Can I execute such a hello world app or not? Do I really need root access to execute an application I made? Is there a way to get my code to run by wrapping it in android/java code? Do I have to go through the Dalvikvm to get this to run?
I'm really looking for a way to do this without rooting it or downloading something like busybox and using su.
Many many different issues.
permission denied is one of the few error messages the primitive shell knows, and it's used for many other types of failures including not finding the requested command.
The toolbox suite is missing many typical unix commands. People sometimes install busybox as a more comprehensive supplement
Some of the things you may want to do will actually require permissions that the shell (or even more so, application user id) accounts do not have. Only on an emulator or engineering device does the adb shell run as root by default, though on a 'rooted' device you may be able to get to a root shell.
You do not need root access to run compiled code, however the code must have a suitable ABI, must have all it's library dependencies satisfied, and must be installed in a file with the executable flag, on a partition which is not mounted with non-executable flag. Some of the issues you face there are glibc (or other) vs Android's bionic libc. Executable scratch directories vary by android version, though the private storage area of an app is an option if the app sets the file to world readable and executable.
The usual (and only "recommended") means of running native code is to build it as a shared library linked against android's Bionic libc, and call into it from a dalvik/java app using JNI.
This will probably seem like a noob question but I have managed to intall phonegap with eclipse and to get the emulator and samples running. However, I am confused on how I would export this inorder to try it on my phone. Is it the .apk file in the /bin folder of the application? Or is there more? I mean like pictures and other files. I'm not used to eclipse. How do I get it on my phone and eventually the market(free only apps).
Thanks
Yes, it's the APK file that is the application. You should also be able to connect your device to your computer and run directly on it.
http://www.phonegap.com/start/#android