I have apk file that will be distributed between a lot of users. The file is same for all but I need to specify ID for each one that will be used in code (ideally it should be done automatically by php script). For now I tried to put ID to text file in Assets and then open apk as archive in Windows, update value in text file then save (update archive). As result my application cannot be installed anymore.
Why it doesn't work? Or may be there another way to set ID for each apk without recreating package in development environment?
There is no way to do that, you must compile and sign your app on every change.
Android do a hash for your apk, if you change a bit the content, this hash do not coincide and will not be a valid apk (not able to install).
You can do somewhat script to automatize the change of a file and compile/sign after your apk.
Related
Note that this question does not concern Google Playstore - I am downloading and installing this apk package from my own website.
I have an existing apk file that I can install and open on my Android phone.
Now I want to use the functionality of that old app in a new and similar app, but one that uses a different app name and logos.
I no longer have the old app source code, and I didn't create it in the first place (I subcontracted the app development to a coder who is no longer available).
So I opened the apk file using apktool and located the png image files that are used. I edited these and saved them in the same location and using the same filenames.
Then I edited the strings.xml file to change the app name text to the new file name.
Then I rebuilt the app, re-signed it using uber-apk-signer and uploaded to my website with a file name that is different from the old apk file.
When I download this new apk file to my Android phone, it prompts that it will replace the old app, even though I have changed the app name and apk filename. When I install this new app, indeed it does overwrite the old app, and I can successfully open the new app with the new logo.
My question is: What parameter/file do I need to edit in the decompiled original apk so that the new apk doesn't overwrite the original app when I install it on my Android phone? I want to be able to install both these apps, because they have similar characteristics, but will be used in different industry sectors (one is for the educational sector and one for the agricultural sector - both are simple charity apps to be used in the country of Myanmar (Burma).
The original apk is at www.teachersimon.org/simon.apk and the new app is at www.teachersimon.org/farmersimon.apk
Thanks!
For this too work, you need to change the package name e.g com.example.appname and the applicationId stored in the app's build.gradle file. Good luck!
There is such problem:
1) I have to use my our distribution service to give new builds of app to testers (no way to use HockeyApp or etc.)
2) I want to give unique APK file to each tester. But it is not possible for me to compile ~3000 APK files for every new build of application.
So I want to add some kind of ID to APK file without recompiling it.
(I need it to identify, if some user will share this APK file somewhere in web without my permission)
Example:
User downloads .apk file from my site => uploads it to some forum/website => I see, that somebody has shared my app in web => I download apk from that forum/website => I identify, who shared it (via unique ID of apk)
That is not going to be easy because all files of your APK are covered by the signature, so anything you add will have to be somewhere else.
You could try modifying the zip comments of the APK (if you can find a library that allows you to do that -- maybe "apkzlib"), I'm not sure if this part is covered by the signature.
Alternatively, you could try adding a file to the APK that is not referenced in the zip central directory (a "ghost file" in a way, it wouldn't exist for most zip tools), maybe the signature doesn't cover those either, but I haven't verified. This solution also requires good knowledge of the zip format to implement it.
Note as well that if this can be done without touching the signature, it can also be removed without touching the signature... so if one of your tester finds out about this, they could remove it. But I guess it wouldn't be trivial to do, so that might be sufficient anyway.
There are two constraints:
Unsigned apks can not be installed.
an apk signature signes every bit of the apk, therefore the wole apk must be signed.
Luckily signing an apk takes only some seconds and should be feasible for 3k apks.
So you can write a script that writes the id to a file within the akp (which is basically a .zip file) and sign it afterwards. See Can I re-sign an .apk with a different certificate than what it came with?
See https://developer.android.com/studio/publish/app-signing#sign-manually on how to sign from command line.
I am writing an application where inside application wanted to identify from which URL-Source apk is download. Is there any way to get it.
Basically I wanted to know how many times apk is install from given URL.
Any suggestion here!!
I am writing an application where I need to find download URL of apk. Is there any way to get it.
No, because there is no download URL. APKs are installed from local files. How the APK got to be a local file (downloaded from a URL, received in an email attachment, copied over to external storage via USB cable, etc.) is not something that you can determine.
Basically I wanted to know how many times apk is install from given URL.
You are certainly welcome to use product flavors in Android Studio/Gradle for Android to create custom APKs based on distribution channel, where those APKs have a custom value baked into them (e.g., buildConfigField mapping to a BuildConfig field).
I am trying to change the display name of an Android file (the name shown on the screen once the app is installed). I only have the apk file*.
When I unzip the apk file, it's partially binarized. I know that to change the display name, I have to change the AndroidManifest.xml file, but that file is partially in binary.
If I unzip an application, change something (or nothing!), zip it back up, sign and zipalign it, the application does not work anymore. It doesn't install, but crashes while trying, claiming Parse Error - There was a problem while parsing the package.
If I unzip the application using ApkTool, change something (or nothing) and rezip it using the apktool b apkFolder -o changedApk.apk, then sign and zipalign it, the app does install, my changes seem to be present, but the app crashes the moment it opens up. The stacktrace seems to indicate that the following is the problem:
F/monodroid(12679): No assemblies found in '(null)' or '/storage/emulated/0/Android/data/Geocortex.App/files/.__override__'. Assuming this is part of Fast Deployment. Exiting...
If I rezip the application using the apktool b apkFolder (thus to place the changes in the original apk file), sign and zipalign, the application installs and works, but none of my changes are present. The last modified date on the apk actually doesn't even change, so it seems like the tool does nothing.
ApkTool seems to have been successfully used in the past by many others to do the same thing as me, but now I am wondering if perhaps it wasn't updated to the Android L version.
I also noticed that the original unchanged apk is about 3 mb bigger than the output from both the apktool and the regular rezip. As another side note, I am using the original key, keychain, password to resign the app.
Does anyone know how to do this, or why the application might be crashing? Does the apktool work for Android 5.0+? Any insight is greatly appreciated!
*Details about the source of the apk and my authorization (as requested by Chris in his comment): This particular application belongs to the company I work for (so yes, I do have the entire source code and could change the AndroidManifest.xml file there). However, this application is distributed to our limited clients manually. This application does not exist in the app store and every version is manually changed to suit a certain client's desires (e.g. specific app names or icons that match their company). In order to alleviate some of the developer's work load, I am creating a Windows Program that can do all these changes automatically and the work for our team would be as easy as having to type in a new name in a textbox. At the end of the project, I plan on having a Windows tool that can take the current version of our application (in its apk format), change the app name or display icons which were inputted in simple text fields, and output signed and zipaligned application that can be easily sent to our customers.
is it possible to create .apk file by copying an already existing .apk file and modifying its assets folder? I have some information in a file in assets folder containing server ip and port to which the user is to connect. Users are from different regions and have to connect through different servers. can anyone tell me how to implement this?
I've added a comment with my recommended solution to this problem. However, here's an answer to your question:
Of course you can unpack the APK, swap out the assets and then create a new APK from that. However, you will need to sign the APK again with the correct key.
If you are building the apps yourself, you can just build multiple APKs, each containing a different asset file. However, you would have to distribute these APKs by hand (ie: they can't be uploaded to Google Play) because they would each have the same package name and you cannot have multiple apps in the app store with the same package name.