I have a Android Studio project with some test. The test have his own res/drawable folder with some images that are needed to run the test. My question is...
Those images are included when I make the apk or will be omitted?
By default they will be omitted as long as you put the resources in the correct folders, that is "src/test/res/drawable".
Remember that it's possible to customize source/test paths and even have more than one path for each of these, so beware of customizations in your build.gradle files!
Related
I have been confused for quite a long time.
before build tool v21.0.0, the packaged apk contains the drawable folder structure as below:
res/drawable-hdpi
res/drawable-ldpi
res/drawable-mdpi
res/drawable-hdpi
However, things changed since v21.0.0, the unzip folder structure comes with suffix:
res/drawable-hdpi-v4
res/drawable-ldpi-v4
res/drawable-mdpi-v4
res/drawable-hdpi-v4
My questions are:
Why added v4 suffix to the drawable folders by default? In current days, the apps are normally build on a much higher version of API. I don't feel like it is necessary to add the v4 qualifier.
Why since v21.0.0? I have gone through almost all the version of build tools and this only happens since v21.0.0.
Will there be another qualifiers like v6, v9 or etc in the future?
Thank you so much in advance.
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.
I have the following scenario: On my build tree I have, under res/ some drawables directories for higher definition devices that I don't always want to pack when I build my app for lower res devices. It seems that ant will put on the apk all that it finds under res.
Is there a way that I can selectively tell ant 'ignore my xhdpi resources' ?
The answer from #user1236327 consisting of using ant is just fine.
I'd like to suggest another approach using Android libraries.
Use several Android libraries, one per resolution.
So your projects could be structured the following way:
1: Android library for highres drawables
2: Android library for lowres drawables
3: Android library for main source code and default drawables
4: Android project for highres phones
Includes libraries 1 and 3
5: Android project for lowres phones
Includes libraries 2 and 3
Of course, note that it is generally recommended to have one single build containing all resolutions drawables.
I have almost the same problem except I copy different images into the res folder depending on which build I am doing. In my build.xml I just copy the images over from a separate directory into the resource out folder:
<target name="banner_copy">
<copy file="${my_source_banner_dir}/my_banner_file.png" tofile="${out.res.absolute.dir}/drawable-land-hdpi/my_banner_file.png" overwrite="true"></copy>
</target>
You can use the copy ant task to adjust what you need. You can just copy in the files when you are doing your high resolution builds into your hdpi or whatever res folder you are using for higher resolution images. One thing you will have to be aware of is to make sure there is a file in one of your res folders to make sure when you are developing eclipse can find the R.drawable. file and creates the generated ID in R.java. Otherwise it will complain.
I am trying to build a branded Android app, that will have different resource files (mainly drawables) for different customers. The Java code in the apps will be the same, but the different apps will have a different look--meaning different color schemes and different logos etc. I have been told, and my research suggests that Ant is the best way to achieve this.
Where should I change the Android 'build.xml' file? What sort of Ant task should I use to achieve this?
For debugging, I would like to just use Eclipse and build with the default resources. But for production releases, I would like to run Ant on build.xml to produce multiple APKs from different /res folders. I do not even need any code snippets (although that would be nice), just even some tips from people that have done this before or something similar.
I ended up writing a Python script to reorganize the Android project before each build. I recommend avoiding the use of Ant for stuff like this. My 100-200 lines of Python achieved the equivalent of about 1000+ extra lines of Ant that was required in addition to the default Android build.xml Ant script.
I have encountered a similar issue where I want to compile the same code base with some changes as well as changes in the resource files. The solution I am pursuing at the moment is creating a library with the shared code/resources and separate "regular" projects for each of the different APK releases. Unfortunately, I don't have a functional final solution to the problem yet, so all I can give is these vague hints.
Requirement Setup
1. Go to the URL :
http://ant.apache.org/bindownload.cgi
and download the apache ant and extract it in to the any folder like d:/ant .
2. I think you already having the Android SDK path is like(D:/Android SDK/)
Now go to the Enviroment variables and check whether path variable is there is there add these in path otherwise create a new varible with name path and put it there in vaue
D:/ant/bin;D:/Android SDK/tools
done
Go to command prompt and navigate it to the root directory of your project and run the command
android update project -p /
Note: / if you are in the root directory of project else you need to give the path of root directory like d:/myworkspace/mysampleproject
this will generate and build.xml file in your project.
now run the command for this it is necessary to be in root directory of your project
ant debug
this will generate an apk file in bin folder signed with default debug key.
I want to build two different APK's from my Android application. The differance between the two are images in the res/drawable directory. I know that it is possible to use a different set of resources during runtime depending on language settings, hardware or other, but how to do it compiletime? (is it possible to specify another directory then res/drawable?)
(currently, i'm copying/replacing all resources each time i want to build a new version)
Sound like you need to use Ant build tools.
Create in your project a custom folder that contains to different assets folders for each APK,
then, use ANT build with a proper configuration file that u need to create to build the project with the appropriate assets and files before it's beening compiled.
Good luck!
Update:
Here is a tutorial for using the Ant build tool with android:
Android Ant build tutorial
Perhaps you should use the assets? I find a link that talks about the resources and assets!: here
One possibility could be to use 2 different library project and put in these project your images / values. you would have to change the properties of the project each time you need to compile with another library project
It's a bit inconvenient but would work...
Hope it helps