Each and every android application is bundled as an apk file. When an apk file is installed different entites (files) of the application are stored in different parts of the system. For example i have found that real player stores its files in the following places of the android file system
/data/data/com.real.RealPlayer
/data/app/com.real.RealPlayer-1.apk
/data/dalvik-cache/data#app#com.real.RealPlayer-1.apk#classes.dex
/data/system/packages.list
/data/system/packages.xml
/data/data/com.sec.android.app.twlauncher/databases/launcher.db
How can i do this for every installed application on my phone/emulator?? Is it the right way to parse apk file and find the places where all the parts of the app are stored?? Any ideas?
On normal non-rooted phones an application can see only its own files, due to security restrictions.
Related
I just built an app for Android using Unity3D. The app weighs 200mb. During testing I used to build a single apk which always worked. Now that I uploaded it on PlayStore, I had to use Unity's built in split feature which creates an apk and an obb file.
My problem is that now the app isn't working. It seems like the obb file isn't being loaded properly and the app doesn't find the files.
I have some assets in StreamingAssets folder which are loaded dynamically and the app doesn't seem to be able to find these along with the other scenes.
What I did to try to fix this with no success:
Added READ_EXTERNAL_STORAGE permissions
Added WRITE_EXTERNAL_STORAGE permissions
Added a plugin to force permissions dialog Unity Android Permissions
Set to false unityplayer.SkipPermissionsDialog in the android manifest
Added GooglePlayObbDownloader in my project but it seems to crash the app because of the missing License. (I can't retrieve the license)
What am I doing wrong?
I had a working app, then I enabled Split Application Binary in Player Settings > Publishing Settings and it stopped working. Disabling the feature, the app works but can't upload it on Google Play as it has a 100MB file limit.
You mentioned using UniWebView. The documentation recommends placing your web files in the Assets/Plugins/Android/assets/ folder.
If you are using "Split Application Binary" for Android build (obb files), you should not put your local HTML files under StreamingAssets folder. Instead, you need to put them to Assets/Plugins/Android/assets/ and then you can use the same way as you did for normal streaming assets resource to load it from the new location.
https://docs.uniwebview.com/guide/loading-local-files.html#using-split-application-binary.
Unfortunately this will simply move the files from the .obb to the .apk file, which might push you over the 100mb limit again.
APK Files aren't recognizable files like executable files; they won’t run on a double click. That's why we need a player/emulator like Bluestacks/Andy/Droid to play them.
So what should I do to extract all the info about an APK without installing it and running it on a device?
You can get some limited information about an APK by extracting it. An APK is essentially a zip file containing manifest, resources, assets and classes which together make up the application. Change the .apk' extension to.zip` and extract it using built-in Windows tools. Note that most contents won't be human-readable.
APK-Info
APK-Info is a Windows tool to get detailed info about an apk file.
Allows you to view:
application icon
package name
name (in all languages)
version
build number
the minimum, maximum, and target version of the SDK (Android)
supported density (DPI) and screen size
architecture (ABI)
supported textures
permissions
features
signature
OpenGL ES version
whether app supports Android TV, Wear OS, and/or Android Auto
locales
a variety of hashes (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512)
and a lot of other information
Using
You can open the APK file in APK-Info using one of the following methods:
Start APK-Info, and then select the APK file in the dialog.
Open the APK file by clicking on the open button in the dialog.
Drag the APK file to APK-Info.exe or its shortcut.
Drag the APK file into the running APK-Info window.
Open the APK file by double-clicking, after installing APK-Info, as a program for opening APK files (via explorer or attached .cmd file).
https://github.com/Enyby/APK-Info
I'm trying to modify the Androidmanifest.xml for the browser on my device so that I can execute an app by loading a URI in the browser.
I've been running around the file system in ADB SHELL all day, but can't seem to find it. Plus there is no FIND, nor LOCATE command on the system.
You can theoretically find the Androidmanifest.xml file in the APK.
Every APK contains the compiled source code of the application. There is no useable decompiler for APKs at the moment so it is not possible to change the content of one.
In addition to the compiled code and the other resources of the application, an APK also contains a signature from the developer, which will become invalid when the content is changed to verify the source of an APK. An Android system won't install an APK with an invalid signature, so even if you could change the content of the APK, you still couldn't use it.
The conclusion: You cannot do what you are trying to do.
Android Studio on Windows 10/11, it’s in: app/src/main.
I read that during .apk installation process a new user is created and with this new user rights, the Applications directory(.apk is extracted here) in the internal storage is created (in /data/app , not very sure). I can't find any Application directory in /data/app , even /system/app also contain .apk not Application directories . Can someone explain where I can find Application directories ??
Also what are the things happens during installation process (I am interested in knowing if some specific files are copied to specific location).
You read wrong :) APKs are not extracted on the file system, just decompressed in memory. So you will only find APK files in /data/app, /system/app, etc. The whole process is version dependent (for example Jelly Bean adds forward locking/encryption). You need to read the Android source to get the actual details. Start with PackageManagerService.java.
This is a very interesting thing. I have an APK file, com.company.app.apk. When installed to an emulator by using Eclipse, by using the following code to get the apk's file name:
String fileName = activity.getPackageManager().getApplicationInfo(
activity.getPackageName(), PackageManager.GET_META_DATA).publicSourceDir;
I get a pathname like this com.company.app-1.apk. The file size is the same as the apk file I built.
Now when I publish this app to Market, and install it to a real device (Android 2.3), the same code returned a pathname like this: com.company.app-2.zip. Note that the file extension has changed to .zip and, most importantly, the file size is significantly smaller than the original size.
Now if I transfer these two files to my PC and use WinZip to open them, I found one really interesting thing:
The one installed on emulator by Eclipse has exactly the same stuff as I expected. Namely: the code ('com' folder), the resource ('res' folder), the signature ('META-INF' folder), the assets ('assets' folder), and the manifest file (AndroidManifest.xml). However, the one installed on a real device by Market has only two parts: the resource, and the manifest file.
Question: I think when installed from Market, the .apk file is split into two (or more) files. One file is pointed to by ApplicationInfo.publicSourceDir, which contains only the resource. How can I get the pathname to the other file(s)?
ADDED: I have two versions of the same app, one is paid using Google's Vendor Licensing Service, the other is free. The above mentioned phenomenon happens only to the paid version. Why?
Correction: When I said the 'com' folder exists in the installed apk file in the first case, I should be more clear. The code per se, the *.java files, are not in the 'com' folder. As a matter of fact, the 'com' folder contains only a few garbage files that were inadvertently left there during the build process. If not for those garbage files, I don't think the 'com' folder would be there in the first place.
I think you are not right. The market works in the following way: you choose an application and push a button to install it. After that market sends the intent to gtalk service to install the application. This service downloads apk file that you've uploaded to the market and when finishes it installs this apk. Just during the installation can some changes happen. It seems to me that from the application during the installation classes.dex file is extracted and from this file optimized dex (.odex) is produced and put in the separate directory. That's why you see the difference in the files.
Ok, here is what I've found out, in case this helps someone out there:
When Market installs the free version of my app, the apk file is installed to /data/app/com.company.app.apk, the file content is exactly the same as I built it, same file size, same everything.
For the paid version that uses Market Vendor Licensing, the apk file itself is installed to /data/app-private/com.company.app.apk. This is the same file as I released. However, the resources are extracted and installed to another file /data/app/com.company.app.zip, note the file extension. This zip file contains only resources, so it's significantly smaller. But the .apk file in /data/app-private has everything, so the file size is the same as I built it.
ApplicationInfo.publicSourceDir always points to the file in /data/app, so it's /data/app/com.company.app.zip in the paid version's case, and /data/app/com.company.app.apk for the free version. For the paid version, I obtained the pathname from publicSourceDir, then replace.app with app-private, and replace .zip with .apk to get the original file.
If I install the apk directly to an emulator, then there is only one file and is always installed under /data/app.