I'm running Android Studio 0.5.8 and using the "Debug App" functionality to send my work in progress to my phone to test. I've done this dozens, maybe hundreds of times. I'm concerned that Android Studio may not be overwriting the old apk files. It appears that my useable space keeps dropping.
Where does Android Studio save apks when installing debug runs?
Is it a destructive or cumulative process? Do I need to clean out the folder manually?
Within your module directory should be a folder called build, then another directory called APK. The APK should be in there. Perhaps check the file size and compare it to your "drop in space"
On your device Chris Stratton's comment is correct, it will overwrite the old APK when installing.
Check Settings->Apps and select your app. The see what readings it gives you for Data and cache.
It is stored in /data/local/tmp. It should overwrite the old apks stored there.
Related
Eager to retire our app's aging OBB Expansion Pack system and replace it with the shiny new Play Asset Delivery (PAD, formerly known as Dynamic Asset Delivery), I've been following the documentation. But I'm stumped as to what to do next. How do I get to a place where I can hit Debug and find the assets ready to go, like in the old days when my OBB was waiting in the phone at /storage/emulated/0/Android/obb/?
TLDR: My answer is below, but I would love it if there was a way to achieve speedy debugging with an install-time asset pack. The current workflow described in my answer requires 1) a wait of about 5-10 minutes to build the bundle, 2) build an APKS blob, then 3) install it from the splits.
Below is a record of my journey to understanding how to work with a ready-upon-install asset pack. I'm hoping that my account of my efforts will land some search hits from other confused developers and light their way.
HOW IT ALL STARTED
My goal: to achieve a situation as seamless as back when I would punch the Debug button in Android Studio, knowing the expansion back was snugly installed in the appropriate directory, to serve pictures and sounds to our app. Here I hoped to hit Debug and similarly find the pictures and sounds ready to use, but instead right at home in my Asset Manager.
In the tradition of the Expansion Pack docs, the PAD docs made --local-testing sound like a breeze. But then the trouble began.
So I first set up the very alpha v0.15 bundletool in hopes of experiencing "quick, iterative cycles" that would avoid having to upload to Play Store during development. So far so good! I used the --local-testing flag to generate a collection of APKs.
The confusion set in when I connected my device and ran the "bundletool install-apk" command. Bundletool says little, and didn't have much in the way of a -help screen. But it spat out these files:
ADB >> OK
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-xxhdpi.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-master_2.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-de.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-fr.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-nb.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-sv.apk"
Pushed "/sdcard/Android/data/com.myapp/files/local_testing/base-arm64_v8a_2.apk"
I thought one of them might be the name of my asset pack, "my_asset_pack.apk" or something like that. But none was.
So I was curious as to which of these files contains the assets I broke out into the asset pack separate from my base app assets. I recognized the localization strings ("de", "fr", etc.). But what about my non-localized media? (Could they be in base-master_2.apk?)
Was there more I needed to do to make these assets show up? So far my ready-upon-install assets didn't seem to be available from the Asset Manager on boot, so I must be missing a step.
EDIT: Updated to reflect name change from DAD to PAD.
I don't know how it is in Android Studio but in Intellij IDEA you need to change "Deploy" option from "Default APK" to "APK from app bundle" in edit configuration window. With this option changed I was able to debug my app using app bundle without problems.
OK, so the big picture is that our command line is going to do the work that the Play Store would normally perform when receiving our bundle, churning it through the mill and publishing it in APK format. The bundle spits out a blob of split .APKs which are then, in turn, used to perform installation on our device.
INSTALLING YOUR DEBUG BUILD WITH ON INSTALL ASSET PACK
In AS, go to "Generate Signed Bundle -> Android App Bundle."
Build a debug build with your credentials.
With Bundletool 1.0 or higher:
bundletool build-apks --bundle=./app-debug.aab --output=./my_app.apks --ks <path to my keystore.jks> --ks-key-alias=<keystorealias> --local-testing
Use our .apks blob for app installation:
bundletool install-apks --apks=./my_app.apks
Tap your newly installed app
Run -> Attach Debugger To Android Process.
Enjoy the presence of your assets right there in your AssetManager.
But have we achieved "quick, iterative cycles?" Eh, sort of. Takes maybe 10 silent minutes to build that blob on my Dell XPS under WSL. Maybe it's time to take out the checkbook for that 64-core Ryzen Threadripper.
DEBUGGING YOUR FRESHLY-INSTALLED DEBUG BUILD WITH ASSET PACK
Here's what works for me. Before building the bundle, I temporarily copy all the asset pack assets from </my_asset_pack_dir> into the normal base assets directory, /app/src/main/assets/. That way I can verify that the app can reach them through AssetManager. Then these temporary files could be ignored during build, or deleted by a script.
This way the assets can be tested without the 10 minute wait for .AAB -> .APKS -> split install.
Why my .apk in bin folder are disappearing when I close my emulator and cleaning project and it appear again when emulator is open? I don't know when is the safe to copy the .apk file.
When I close emulator (NOT CLEAN PROJECT) and the .apk is there?
When my app is running to my emulator and copying the .apk file?
The (export) unsigned Application package and save in different location?
The (import) unsigned Application " " " " " "
Sometimes I installed apk file without problem in my Phone somtime NOT.
While it's true that the proper purposes for a debug .apk are limited (app stores won't accept it, user data is completely unsecured, and it will expire inside a year), that is indeed a valid apk you can use for some temporary testing purposes.
Two things govern the existence of that file:
A "clean" operation should remove all build objects, including of course the .apk
The android tools are usually configured so that the automatic build process does not include generation of a debug .apk, and that instead only happens (by default) when you go to deploy on a device/emulator.
Therefore, you can grab the temporary debug .apk out of the bin folder any time between having deployed and having cleaned, regardless if your emulator or device is still running/connected or not.
Examining the timestamp on the .apk file as you try these various operations would be a way you can confirm this for yourself.
Are you using Eclipse?
There are a few important settings:
a. Window > Preferences > Android > Build > "Skip packaging and dexing until export or launch" - if this is selected, APK is only generated when the application is launched onto a device/emulator.
b. Project > Build Automatically - The project will automatically be built after changes in the code
c. (only if b is not selected) Project > Clean... > "Start build automatically" - When you do a clean, a build is also done.
After every clean, the APK will disappear.
If setting (a) is checked, any time your project is cleaned or rebuilt (after a manual/automatic build) the APK may be removed. The APK is generated when you launch the application onto the emulator/device.
If you want to create an APK without launching, uncheck (a).
In summary, if you want to store your APK do the following:
Clean/Build the project
Stop making modifications to the code (if build
automatically is checked) and do not clean/build anymore
Make Eclipse generate the APK by launching application on emulator/device
(You can skip this step if setting (a) is unchecked)
Save the APK
Continue working
It really depends on what you want the .apk for. If you want to distribute it via the Google Play store or on a server you'll want to export a signed application. If it's for personal use just run it on your phone using your phone as a debug device.
I renamed the project successfully but now there seems to be having two .apk files. Do I have to keep the old .apk? . Currently my new .apk file has no errors. Will it corrupt later?. Or if I remove it will my project be still fine forever? I have a long term usage idea for this project so what is best to do.
But keeping the old name.apk is like keeping garbage I need a clean project... What can I do? And how this affects when I need to sell application in Android market.
Delete the old .apk file, it only because you rename your project, so it generates a different file.
Google Play (Android Market) will see it as a new app if you change the package name.
If you haven't already uploaded the original version, yes, you can just delete your local .apk.
delete bin and gen folder to clean up with old built data.it will be built again automatically if you have checked true in front of Build automatically option in Project tab.
I compiled and ran a project on my phone through eclipse which is still install there currently. While doing some directory cleaning I accidentally deleted the source code so the only remaining version of the code is in the apk installed on my phone. Is there anyway to export the app back to my computer?? It isn't signed or anything either.
Thanks!
You can set up to be able to copy files on/off your phone via the USB connection - heres where you can look to find it:
Does Android keep the .apk files? if so where?
Then after you get the .apk off look at these questions for decompiling:
Is it possible to decompile an Android .apk file?
decompiling DEX into Java sourcecode
You CAN pull the APK off of the phone, but it's going to be Java Bytecode, not your source code (regardless of whether or not it's signed). You would have to reverse-engineer the classes to retrieve your code. If it's not a VERY large app, I'd say your time would best be spent simply re-creating it.
I have signed the application using Eclipse's Export Wizard. When I published this, users started complaining that the application is behaving incorrectly. (Basically, the APK did not have necessary images & audio and hence showing incorrect behaviour).
Some information on Application and Signing which I have tried.
I have a lite version and paid version. Both are signed with same keypair. The lite version is working perfectly and full version is giving error.
I have tried to export the signed packages again and tried to install directly in device (instead of uploading to market). Same behaviour (i.e Lite apps works correctly and full version not proper)
Both Full Version and Lite Version uses shared Library (Code base is identical. Differences as follows.
Full Version has 5 times the resources of lite version. The lite version apk is ~2.6MB and full version is ~10.4MB. In Full Version I have 170 images (mostly png's of 5-10 KB) and ~55mp3 files. In Lite Version I have 45 images and 15 mp3s
Full Version has LVL (License Verification) implemented and Lite Version doesnot. Once LVL is passed, the code simply calls the Library Class
If I use Eclipse to build and deploy full version to phone (or emulator), it works correctly. (I guess this build and deploy will use debug key for signing)
I have error handling within the code to show code to show a dummypic (a question mark) if resource is missing. All my images are replaced with that question mark. Just to add.. This dummypic is in the Library and all other resources(images) are in Full Version.
I have checked the resources by renaming the signed apk file to .zip (thanks to NickT for suggesting this approach). All resource files (audio and images) are present in the zip file.
Any help is appreciated. The application is already in market and hence would like to minimise adverse impact.
Removed LVL. Still same error
Tried commenting the LVL code and directly calling the intent. Still same error.
By commenting the LVL, the code base for Lite and Full Version is identical. Only the resouce count is different. The full version has all the resources of Lite Version + ~5times the resource.
Update
This is how I temporarily fixed it.
I removed the library project and moved all classes and resources to the Implementation Project (Full Version). Now it is working.
As said, this is a temp fix only. I still need to know how I can fix this with library. Else I will have to create a lot of duplication of code.
My bet would be that it has to do with permissions.
The app that is being installed first, will have read-write permissions to that folder, the other will not.
Try using a ContentProvider to make your images accesible for both apps!
The sign shouldn't affect your code. I think the problem must be in the source code of Paid version.
Do you test in emulator? from eclipse? You can test the signed apk in emulator too through "adb install application-signed.apk".
I think you should uninstall and then re-install app, it happens sometimes, when your phone already has the application and you install it again with different resources and files without uninstalling(but overriding), it gives odd behavior,
try uninstall and then re-install should work for you.
I am not sure but i think no two apps of the same package name can co exist in a single device. try installing the apps in two different devices.
Two suggestions:
1) Do you have proguard enabled? If yes, try disabling it and test. If it works, you might need to update your proguard.cfg (probably with some -keep public class)
2) Delete your R.java manually and recompile your full version only!
I encountered this problem with Android projects using other Android Library projects. It looks like the AAPT (or an eclipse ADT part) sometimes fails when creating the R-file ids (So the resources are present, but the id's are not correct).
What quickly fixed the issue for me: Close the "master" project and reopen it having the Build Automatically option set or make a clean&rebuild on this project. The next exported APK shouldn't have the resources-not-found issue.
Maybe you let a debug flag into the Manifest file ?