Need step by step instructions how to automatically add files to the APK in Android Studio - Android Q&A, Help & Troubleshooting

I am trying to do this very trivial task, but I cannot find any complete instructions on how to do it.
So far, I gathered that
APK is just an archive that files can be added to using aapt add MyApp.apk file1 file2 ...
Or the files must be added to the assets folder
The APK must be less than 100mb to be allowed on the APP store
The files must be signed
The problem is that I am finding these one-line answers in Stack Overflow questions, and not in any official instructions from Android Studio developers, and they leave a lot of necessary steps out. Which I have to guess, like where to put the files, where are they getting stored on the device. If adding files to the assets folder, I need to know Which assets folder? app/build/intermediate? Do I need to add something to Gradle scripts? Are there any other steps?
This is a very basic thing that probably every android app needs to do, and I am baffled that there is not an option or support in the IDE to import and sign the files being used by the application.
So far I had to resort to manually uploading these files (YOLO ONNX models, label text files, test images, etc) to my phone and the emulator for testing.
I am looking for some clear and concise step by step instructions to how someone can add something like a text or image file to their APK, sign it, and make it deploy to the phone or emulator automatically when building, running, or debugging the app.
Can someone please help point me to such a resource?
Thank you,

dmitryengr said:
I am trying to do this very trivial task, but I cannot find any complete instructions on how to do it.
So far, I gathered that
APK is just an archive that files can be added to using aapt add MyApp.apk file1 file2 ...
Or the files must be added to the assets folder
The APK must be less than 100mb to be allowed on the APP store
The files must be signed
The problem is that I am finding these one-line answers in Stack Overflow questions, and not in any official instructions from Android Studio developers, and they leave a lot of necessary steps out. Which I have to guess, like where to put the files, where are they getting stored on the device. If adding files to the assets folder, I need to know Which assets folder? app/build/intermediate? Do I need to add something to Gradle scripts? Are there any other steps?
This is a very basic thing that probably every android app needs to do, and I am baffled that there is not an option or support in the IDE to import and sign the files being used by the application.
So far I had to resort to manually uploading these files (YOLO ONNX models, label text files, test images, etc) to my phone and the emulator for testing.
I am looking for some clear and concise step by step instructions to how someone can add something like a text or image file to their APK, sign it, and make it deploy to the phone or emulator automatically when building, running, or debugging the app.
Can someone please help point me to such a resource?
Thank you,
Click to expand...
Click to collapse
Hello and good afternoon, @dmitryengr
Welcome to XDA! I hope you'll always get the support you require.
However, prior to your next posting please read the guidances that are stuck on top of every forum like
Note: Questions go in Q&A Forum
If you are posting a Question Thread post it in the Q&A forum. Technical discussion of Android development and hacking. No noobs, please. Device-specific releases should go under the appropriate device forum...
forum.xda-developers.com
and the others. I've moved your thread to Android Q&A.
Thanks for your cooperation!
Regards
Oswald Boelcke
Senior Moderator

Related

[Q] Adding files to apk to install

Ok, I have read and read and am still stumped. Let me explain. I have a game decompiled and want to add a file to it that will copy itself to a certain location upon install. Here it is--
My goal is to take a copy of my profile.sav and insert it into the decompiled apk, possibly in the res/raw directory. When I install the .apk, I want the profile.sav to be moved to the /data/data/com.myapp.here/app_Documents/ directory. I am learning here and this is solely for the purpose of making my apps custom for me. To be able to install the app and have my settings already in place, negating the need for a backup/restore would be ideal for me. Besides, it just seems a really interesting thing to learn. Thank you in advance for all you help folks!
OH, also I read this post http://forum.xda-developers.com/showthread.php?t=601629 But, The last post by Gene Pool is provided with code. Problem is, I have no idea where to insert this code, or if it is even useful for what I am trying to do. Thanks Again!
I guess this wont be as simple a task as I had hoped.
Sent from my SAMSUNG-SGH-I727 using xda premium

modifying 2nd.zip package in root sdcardv4

I unzipped the 2nd_Albert_APP_update.zip and found the structure
\system\app and list of *.apk files.
question 1:
can I remove an apk file from 2nd_Albert_APP_update.zip in \system\app like twitter.apk without breaking the install process?
question 2:
Can I just add my own demo.apk files by simply copying them and saving the same archive and location mentioned above?
rp201 said:
I unzipped the 2nd_Albert_APP_update.zip and found the structure
\system\app and list of *.apk files.
question 1:
can I remove an apk file from 2nd_Albert_APP_update.zip in \system\app like twitter.apk without breaking the install process?
question 2:
Can I just add my own demo.apk files by simply copying them and saving the same archive and location mentioned above?
Click to expand...
Click to collapse
First of all wrong section. Second off if verification signatures are off, then you might* be able to assuming he used the package command, you might be able too.
Loglud said:
First of all wrong section. Second off if verification signatures are off, then you might* be able to assuming he used the package command, you might be able too.
Click to expand...
Click to collapse
sorry for wrong section, I was stuck between sections where to post.
I figured a metafile edit or package signing tool might be needed I did not want a simple yes response. I guess I will hijack my own post and change it a more dev type question.
Any rough steps you can give me to do this myself that I can then do searches on?
figure I'll have to
download android sdk.
examine metafile xy.z
look for section [] and edit
place apks in structure
buildpacktool.exe to look for.
any help would be greatly appreciated
thanks
rp201 said:
sorry for wrong section, I was stuck between sections where to post.
I figured a metafile edit or package signing tool might be needed I did not want a simple yes response. I guess I will hijack my own post and change it a more dev type question.
Any rough steps you can give me to do this myself that I can then do searches on?
figure I'll have to
download android sdk.
examine metafile xy.z
look for section [] and edit
place apks in structure
buildpacktool.exe to look for.
any help would be greatly appreciated
thanks
Click to expand...
Click to collapse
um sure. So first of the great thing is you really shouldn't have to do much. The basic premiss of this is that it uses a update.zip to flash via CWM, which means you shouldnt have to sign the package. Basic premiss, is I would first try unziping deleting and putting packages into ./system/app/ rezipping and then trying to flash that. That should be good enough to make your own. Second off if you really want to, you can look at the meta-data/.../update-script. There are some good guides on how to script this file.
http://forum.xda-developers.com/showthread.php?t=994940

[Q] Making / editing custom ROM's using Linux

I'm looking for a little bit of help with understanding something.
My ideal place to get to is to eventually provide the community here with custom roms and mods which everyone can enjoy on their devices, just like what all the greats devs do here day in day out.... but before I get there, I'm on a path of discovery. At the minute, I want to take a XDA dev's already pre worked ROM, go in to it and change a few things up.... edit the apps, maybe play with a few apks, change the ringtones etc, and then resign the ROM and flash it to my device.
I've been reading some great tutorials such as http://forum.xda-developers.com/showthread.php?t=1801690 and http://forum.xda-developers.com/showthread.php?t=1843506 which I am finding very helpful, however....
They seem to be geared towards someone working on a windows machine. I dont want to do it in Windows, I want to do it in Linux... I dont wish to use "CygWin" and I would rather do it manually than use a kitchen - I could easily follow these guides in Windows and achieve my stated aim of a slightly modified custom ROM, however, the overall goal here is to acquire knowledge, and enjoy the process as it goes along.
Now, my current understanding under Linux (Mint 13) is that I can download a recovery flashable Zip, go in to it, and just change up some of the files as I desire.... but then I get confused when it comes to repackaging the ROM prior to flashing it to my device. How would I go about doing this?
As a side note, when it seems that all development for these devices is done under Linux / Mac... why do all the newb guides steer you to Windows?
Are you asking how to rezip or how to recompile?
If you're asking about zipping up the folder, go here:
http://forum.xda-developers.com/showthread.php?t=1499885
If you're asking about recompiling, it should state how to do so on the page you got the apktool from.
Hi, thanks for your reply. I guess for now what I am asking is how to get the ROM back to a flashable zip file.
The I believe is that you need to have the ROM signed. The windows tutorials point you to a batch file script that does the signing and creates you an "update.zip" file. What id the alternative to this under linux?
Also, in the post you just provided a link to, someone says that you must also edit an update script to reflect the changes you made, such as any apks removed or added etc, where would I find this?
You need signapk.jar which I believe is included in the android sdk if not just Google and you can find it, once you have that you need a key to sign with, again Google for a testkey.
Then in your terminal you would run:
Code:
java -jar signapk.jar certificate.pem key.pk8 your-update.zip your-signed-update.zip
Sent from my PACman GT-I9100 using xda premium
Excellent, thank you very much.. will play with this later

Help a beginner with android kitchen

Hi! First of all i hope this is the right place to post. Otherwise point me in the right direction.
Now to my case.
Since the original kitchen thread is closed i hope i will have mercy to post my question here.
When I go through the different steps in terminal on my mac i get this messages:
Issue 1:
"Warning: No cache.img.ext4 found. You can unpack this file separatelyby running the plugin script in the kitchen's Advanced menu options.If your device doesn't use a CSC, then just ignore this message."
When i extract the zip file the kitchen makes, it says i should put its systems file in the system folder. But in there, there is already a folder named app, should i replace it or just add the csc zip contents to it? A little confused here.
Issue 2:
"1 issue(s) found. *Please review the update-script to ensure it is correct.Number of symlink conflicts resolved: 1NOTE: This device (m3) requires an updater-script"
"This script will convert your update-script into an updater-scriptand will also add the update-binary file.This option will also be given when you build your ROM, so it isnot necessary to convert your update-script now. *The kitchen is NOTcompatible with updater-scripts, so only a few options can be used*afterwards if you have an updater-script.Ensure you have an update-script under META-INF/com/google/androidof your working folder."
Just so i don't get it wrong. My Galaxy S3 I9305 requires me to change this to updateR? What about the update-binary? Stay as it is?
Thank you very much for any help. Really want to learn this. And i have googled this a lot so you guys are my last option on this matter.
Sent from my GT-I9305 using XDA Premium 4 mobile app

[Q&A] [Guide] How-to Automate Your ROM Build Process Using Jenkins - Setup Nightlies

[Q&A] [Guide] How-to Automate Your ROM Build Process Using Jenkins - Setup Nightlies
Q&A for [Guide] How-to Automate Your ROM Build Process Using Jenkins - Setup Nightlies
Some developers prefer that questions remain separate from their main development thread to help keep things organized. Placing your question within this thread will increase its chances of being answered by a member of the community or by the developer.
Before posting, please use the forum search and read through the discussion thread for [Guide] How-to Automate Your ROM Build Process Using Jenkins - Setup Nightlies. If you can't find an answer, post it here, being sure to give as much information as possible (firmware version, steps to reproduce, logcat if available) so that you can get help.
Thanks for understanding and for helping to keep XDA neat and tidy!
Good to know.. Learning the first steps..
Qa bot bah
thanks
thanks, it is very helpful
Changing output zip image file name
Hi,
I was wondering how to change the file name of the final os zip image (automatically after the build process finishes)? Am planning to upload the zip to some server (using some script), but I need to know the file name ahead.
Any help is appreciated.
Thanks
sirackh said:
Hi,
I was wondering how to change the file name of the final os zip image (automatically after the build process finishes)? Am planning to upload the zip to some server (using some script), but I need to know the file name ahead.
Any help is appreciated.
Thanks
Click to expand...
Click to collapse
This is already part of the guide.
http://forum.xda-developers.com/showthread.php?p=46123166
AndroidSlave said:
This is already part of the guide.
http://forum.xda-developers.com/showthread.php?p=46123166
Click to expand...
Click to collapse
Thank you, I have read that part. But I was wondering if I could change the file name BEFORE the build even starts. I can use the mv command to rename or move after the it finishes.
Simply, I want to set a parameter before the build starts (if any) saying I want the final zip file name to be cm-my-build.zip
Thanks
sirackh said:
Thank you, I have read that part. But I was wondering if I could change the file name BEFORE the build even starts. I can use the mv command to rename or move after the it finishes.
Simply, I want to set a parameter before the build starts (if any) saying I want the final zip file name to be cm-my-build.zip
Thanks
Click to expand...
Click to collapse
Anything can be done with scripting, but I don't think Jenkins itself could do that. You would have to modify the build script (I.e., the CM build script, not Jenkins) at the point where the zip itself gets created.
Way too much of a haste for way to little benefit.
Is there a reason why you don't want to just use mv afterwards as part of your build script? The '*' variable makes it so it can always find the right file.
I can do it with the mv command. But am building multiple times a day, so I want to identify these builds individually. Right now if am building all I get is this <cm-11-20150603-UNOFFICIAL-flo.zip> every time. I can't tell if it was generated right now or earlier in the day.
One trick I can use is to delete the zip file once I moved it to my own target directory. So every time there will be a unique zip file in the $OUT directory.
sirackh said:
I can do it with the mv command. But am building multiple times a day, so I want to identify these builds individually. Right now if am building all I get is this every time. I can't tell if it was generated right now or earlier in the day.
One trick I can use is to delete the zip file once I moved it to my own target directory. So every time there will be a unique zip file in the $OUT directory.
Click to expand...
Click to collapse
You should add the time parameter to the filename when you use mv to rename it. Then it will have a timestamp too, and you can know what is newest
You could also write a script using an 'if' command
I will. Thanks.
sirackh said:
I will. Thanks.
Click to expand...
Click to collapse
You can also set it to auto upload to the server via ftp etc, then immediately delete if that operation is successful, or move to another folder that you store the uploaded files in , in case an upload gets borked
callphone said:
If you are worrying about your children, and are always thinking of a medium, that will help you p keean eye on them, then mobile tracker/phone track is just the answer you are looking for. Prevent your life of lies and troubles. This tracker can also be used as a online backup tool, monitor spy app as well as anti thieves. If somebody stole the phone of your child you can track everything on the phone, with or without an internet connection.
MXSPY.COM
Click to expand...
Click to collapse
Don't post this here

Categories

Resources