I have developed an android application, which uses image files and strings from the res folder. Is it possible for me to distribute the app in a manner that enables the users to modify the strings and images stored in the res folder, without accessing the code from the java classes.
Can I distribute these separately, so that a user can modify the value of the strings and replace the images (not add new or delete existing) and rebuild the apk, without being able to read the Java code?
Thanks.
Ani
I think your best bet would be to build a web interface where users can upload the images and strings they want into a form, you can generate the resources on the server, package it up and sign it, then give them back a download link.
The whole process could be automated as long as you have Java and headless aapt installed on the server.
http://developer.android.com/guide/developing/building/index.html#detailed-build
Related
Goal: To embed info from HTTP headers into an APK package, on-the-fly, during download.
Situation: There is an APK package the company website, available for public downloads. A user comes to the download page, and the server grabs the referring URL, and landing page URL. What we need is, for the URLs to be included inside the package, so that when the app is installed and user creates an account using the app, the URL info is available to the app and appened to the newly created account details (for purposes of traffic analysis and marketing attribution).
An APK is fundamentally an archive.
I think that you should be able to unzip, edit and zip it again without changing its signature, as you can see from this detailed guide
In order to put a unique code inside your app, you could use the assets folder creating a txt or json file containing that code.
Then, you can retrieve the unique code inside your app by reading the assets folder programmatically.
To change the apk, you would need to change the code and recompile it. It’s not possible to modify the content of a compiled apk.
As I only need resources (xml & images) from an Android app (.apk), I would like to save some processing time on using apktool. Is there any parameter that would allow me to disable generation of the smali files and other stuff?
There are several online tools available for this, Try this link and deccompile your apk then you can get your extracted resources along with source code.
I want to decouple data from code on my Android application, and I am not sure of the best way to do that.
For instance - with the Linux Mahjongg game you can add new tiles to the game by dropping a specially formatted file into a specific directory. The Mahjongg game checks that directory when it starts up.
I want to do the same thing with my Android app - I want to be able to install the app, and then have separate installs for different data files. It's the data file installs that have me hung up. I do not want to have to set up my own server and write my own download code.
You can ship the data with the installer app, then use Input/Output Streams to copy the data from the assets or raw dirs.
Check this out:
Ship an application with a database
The answer has an implementation of in/outputstream. You don't need to use a db, just copy the file to ext storage.
One important detail: if you put the file in assets, it will be shipped compressed, and the phone/tab will try to uncompress the file in its entirety in memory. One (hocky) way to avoid that is to name the file .mp3. Assets in .mp3 format are not compressed. (Hey! I said it was hocky!)
The installer app can either uninstall itself by using ACTION_DELETE in an intent (see http://android.amberfog.com/?p=98 for details) or just show a msg to the user that it's safe to delete the data app.
HTH,
llappall
by dropping a specially formatted file into a specific directory
You can do that on external storage. Create a directory, and check it when your app starts up for new files. Tell the user they have to stick the magic files in the magic directory for it to work.
My application will have some customisation for each company that uses it. Up until now, I have been loading images and strings from resource files. The idea is that the default resources will be distributed with the application and company specific resources will be loaded from our server after they click on a link from an email to launch the initialisation intent. Does anyone know how to replace resource files? I would really like to keep using resource files to avoid rewriting a lot of code/XML.
I would distribute the application from our own server, rather than through the app store, so that we could have one version per company, but unfortunately this will give quite nasty security warnings that would concern our customers.
Does anyone know how to replace
resource files?
It is not possible, except by deploying an updated APK. APKs are digitally signed and cannot be modified at runtime.
No it is not possible, but here is what you can do instead... Copy your images etc in the Assets folder.. From the assets folder , copy them at runtime in the Application dir.. ie data/data/yourapppackage/yourresourcefolder
Use the images etc from the runtime folder.. Ie In code say,.. imageView.setBackgroundDrawable(data/data/apppackagename/download/themename/resourcename)...
Now when you download your resources from a runtime path , keep an XML file with key names and path for the image as key value pairs.. Have approprite Enums for that in code and store the image paths in HashMap at runtime..
How can I instruct Eclipse to copy a file from my Android solution to an emulator, as part of Run/Debug? I have a small database, stored in Assets, that needs to accompany the application. Thus far I have simply copied the file myself using DDMS but would prefer to have it automatically included. The project properties allow me to specify some aspects of the build, e.g. the build order and which libraries should be included, but I don't see anything about simply copying a file.
Is the file in your "res/assets" folder not available using the AssetManager class during testing versus during testing or when installed via a signed apk?
I use a large file that I store in "res/raw" in one of my games, I am able to access this file during testing with eclipse without a problem just using the normal calls to context.getResources().openRawResource()
Deploying databases with your application it a reoccurring topic over in the android-developers Google group here is a post with a few thoughts on the matter.
Good luck.