I have a number of files in a project that I don't want to include in the compiled apk.
For source files, right-click -> Build Path -> Exclude does the trick.
How about for excluding other files, for example certain ones in the assets folder? If my understanding is correct, all of these are included in the apk by default.
Also, if I create a custom folder in my project structure (e.g. inside the assets onee) it will show in the package explorer. Would its contents be added to the apk?
Apparently, folders named _pre_production are not added to the APK.
I cannot take credit for this. Here is where I found the answer:
Ignoring files from Android APK
I'm duplicating the answer here in case someone comes by.
Related
In our Unity project we have a lot of jar files in Assets/Plugins/Android. I understand when Unity compiles for Android, any .jar or .aar files in that directory will make it into the compiled apk.
However, our app's Unity project has many folders next to the Assets folder, and in one of those is a hand full of jar files, such as android-support-V4.jar and google-play-services.jar. These are not in Assets/Plugins/Android, but some of the .jars in that directory depend on what's in the directory outside the Assets folder.
How can I tell if these .jars outside the Assets folder are making it into the compiled apk? I know it's a broad question, and part of it is idiosyncratic to how my company's project is set up, but basically I'm wondering if there are common or known ways to get .jars outside of the Assets folder into the apk Unity makes.
You can use a tool such as Classyshark to analyze the contents of your apk. Classyshark is developed by Google for these kinds of inspections. You can see what packages and what classes are in your apk, no matter how these were packaged.
I just started android development but when in eclipse I check there is no extra files in res folder but when I export it and open the res folder in APK I get a lot of extra folders and files in them starting with abc_ and many translations folder created by itself I tried removing it with apktool but it can't compile
anybody can help me to remove these extra abc_ files so that I can create clean apk file
here is pic
http://oi62.tinypic.com/k9ct3b.jpg
Why it won't compile anymore? Because these files are needed by all kinds of Application elements, the abc_ files are for example used in XML View elements. You should not delete them. I also recommend that when you are new to Android to switch to Android Studio as this is now the official IDE.
Actually I want to know that if in my application's libs folder, any library file(e.g .jar file) is present, then after installing(running) that application, will library file present in .apk file?
According to my understanding, library FILE should present in generated .apk file. If I am wrong then please correct me.
If my question is below standard, then extremely sorry for that. Any help will be well appreciated
With recent versions of the Android tools, .jar files in the libs folder are automatically included in the build. (See Dealing with dependencies in Android projects.) So, yes, the library is included in the compiled bytecode (not as a separate file).
If you use ProGuard in a release build, then it will attempt to strip out any code which is not actually used. So, it may be that some parts of the library are included in the final .apk, and some parts are removed.
the answer is yes. The apk is just a zipped version of your compiled project. If you open it with winrar for example, youll see that everithing is in there ;)
You can try it and see yourself but you can not directly see the .jar file under libs folder in the apk generated. Library class files are all together are compiled into a single .dex file. If you decompile that dex file, you can reach the java codes.
I have a lot of unused images in my android app. Those images are placed in separate folder in project root directory. They are not being used anywhere in a project, but I need to keep them.
My concern is that will these unused images be included in the apk file? Since there are a lot of them and increase the size of apk file.
Files stored in the root directory (including custom subdirectories) are not included in the APK. It is very common practice to have your own files needed for the project in the project root. For example, a source license file, a to-do list, a directory with high-resolution images that you create distributed images out of, etc.
Android uses these subdirectories with special meaning:
src/
res/
assets/
libs/
gen/
bin/
Using a subdirectory name other than those, Android will ignore your files.
Confirm by your self: create the apk and change the extension to zip and extract that.
You can use an apk optimizer like progaurd and more for same.
addon to #Darshan-JosiahBarber s excellent answer
With android-studio-0.5.8, gradle-1.11 and android-tools.0.9.+ you can also have a folder
resources
for files to be copied relative to the root of the android apk.
Example:
project file res/some/dir/file.txt will be copied to apk /res/some/dir/file.txt
project file assets/some/dir/file.txt will be copied to apk /assets/some/dir/file.txt
project file resources/some/dir/file.txt will be copied to apk /some/dir/file.txt
This folder resources is necessary if you want to include *.properties files used by crossplatform libs like ical4j.
I'm pretty new to eclipse and Android and I'm trying to add some files to the assets folder, but certain files and directories are not being included in the .apk file.
I have set-up the following structure in the solution:
/assets
/textures
/test.png
/splash.png
/xml
/testData.xml
I don't know if there is a specific way to get eclipse to re-build/compile the project and add the new assets to the assets folder in the .apk, but the /xml subfolder (and its contents) are not in the apk. Subsequently I get FilenotFoundExceptions thrown when I deploy the app. The textures are all included.
How can I force a recompile and rebuild of the apk and is there anywhere to manually check which files are included in the project (like an assets manifest file)?
As far as I know there are no restrictions placed on hierarchy or file formats for within the assets folder. Also, when I dragged the files from the desktop to the solution explorer, I selected 'copy files to project'.
Thanks
It appears one cannot use upper-case letters in the naming of files within the assets folder. Contrary to my example above, I was actually using camel-backed file names within the folders. After changing the file names to lower-case, the apk was automatically re-built with the assets the next time I deployed