Hello I am developing an android application in which for a ListView I have to added an image to drawable folder but when I am adding it is giving the error.
This is the folders hierarchy of my project
This is the image I wanna add arrow.png
This is the error
[2013-04-03 20:57:37 - FileSharing] res/drawable/arrow.png: Invalid file name: must contain only [a-z0-9_.]
I have changes the file name 10 times according to the conventions but still the error is not going
Well i think you must not put the image file in drawable folder.
you must chose these folder for putting images for your application
If you didn't see these folder create these folder inside res .
Then clean and rebuild your project .Hope this would help you
Also Keep an eye one the name of images must contain only [a-z0-9_.]
I think the default choice is drawable-mdpi folder
Refer this
Clean your project and build again.
Sometimes eclipse behaves wierd.
Related
I am developing a splash screen on Android using Xamarin. I have a picture called "splash1.jpg" placed in my various drawable subfolders which contains the subfolder "splash". Thus, for example, I have a "resources/drawable-hdpi/splash/splash1.jpg" and a "resources/drawable-mdpi/splash/splash1.jpg".
In my layout for main.axml I have a line for the imageview source
android:src="#drawable/splash/splash1"
And the following line is autogenerated in my resources.cs file
public const int splash/splash1 = 2130837505;
There is an error with the slash in splash/slash1 const name which causes multiple errors on compilation.
How should I refer to my file in drawables when it is in a subdirectory in the drawable folders?
Thanks.
Android don't support subfolders inside /drawable folders.
Please remove your /splash folder and place the splash images inside /drawable folder directly.
get more information here.
I am trying to add a source image to an ImageView in Android Studio. I placed the image in the res/drawable folder. I have the same image placed in mdpi,hdpi,xhdpi,xxhdpi,and xxxhdpi.
However when I try to add the path to the image in xml it does not even show up. I have attached a screenshot of what I have.
Also I tried to clean and rebuild the project and still I cannot access the images in the drawable folder.
I should add that if I try and add the images to the mipmap folders. It works just fine and I can set the path of the images to mipmap.
You created the extra drawables folders inside of the main drawable folder instead of using the existing folders in the res/ directory. (See the mipmap folders?)
Also, don't need png extension in the XML, just the filename
In your XML remove file extension and replace . with _
android:src="#drawable/podcast_ac_new_2_9"
while adding images to drawable folder using image asset i come accross this
How to solve this issue?
there is not any problem its the new window to add image asset android studio designed.
choose the image for asset type and give the path. then the android studio will generate different size of your image asset in different mipmap folders.
its a lot easier than before. if you dont want to use mipmap folders just copy and paste your file into youre desired folder in android studio manually.
I have just started the Treehouse Android development course, I have also asked this question on their forums without any luck.
DATA
AndroidStudio v 1.2.2, the course is based on v0.86 I think
OS / DE: Manjaro Linux, KDE
I have copied the image files inside the drawable folder, each into their specific dpi folder.
I have created the ImageView for a mail_title.png, and added the src as the full path to the png. When I do that, the image loads into the preview screen, and I can work with it, but If I try to build the app it just says the value of src cannot be a string.
So then I tried to point to it as a resource. On many forums and the android documentation I only found that I should reference it through a "pointer" #drawable/main_title , when I downloaded the projectfiles from the course I saw thats how they did it too.
If I try to rebuild now it gives the following error:
Error:(14, 22) No resource found that matches the given name (at 'src' with value '#drawable/main_title').
Then I tried to create a resource inside strings.xml, I found some autocomplete function that pointed me in "the right direction", of course it did not work!, same error as before. I have tried using absolute paths as well without luck.
Right now It shows R as "cannot resolve symbol R" in the MAinActivity file. I figured out by reading online that this is due to my drawable not existing problem.
Then I created a refs.xml in values and added
main_title.png
I actually tried with and without the extension (png)
After that I clicked on the IDE suggestion to create a drawable folder and it just created a #drawable folder inside of layout....
Basically it says it cannot resolve directory #drawable from activity_main.xml
and also
Error:(3, 33) String types not allowed (at 'main_title' with value 'main_title.png'). on the refs.xml file (this happens whether I use the extension (png) or not.
The only solution I have found is to just copy one version fo the images to the main drawables folder, and deleting all of the subfolders, if I don't delte them then it also doesn't work...
So, as you can see I'm kinda lost... Any help would be appreciated. I'm a python backend developer and I'm pretty comfortable usiong Pycharm (IntelliJ for python), but somehow I feel Android Studio has me totally lost!
So, in case anyone wonders, I solved it following both Cris and Rob advices. I installed appcompat v7 and put my img resources (png,jpd, etc) directly inside my drawable folder. Then I created a folder for each dpi resolution inside the res folder, NOT inside the drawable folder.
I use eclipse but i think its pretty much the same, you should have you various drawable folders, then you have to include the R (res folder)
import com.example.project.R;
and then call them by reference
R.drawables.main_title
Note you dont need to specify which drawable folder , adroid does that for you.
Also if you are getting unresolved errors with R then you may need to have the appcompatv7 library inlcuded in your project.
I have a build fail due to the following error
[aapt] res/drawable-xhdpi/splash.png:0: error: Resource entry splash is already defined.
[aapt] res/drawable-xhdpi/splash.9.png:0: Originally defined here.
Any ideas? Thanks!
This error could also happen, if you use cordova and renamed an existing image (in my case there was only splash.9.png present, but the same error occurred.
In this case you need to clean the project, using
./platforms/android/cordova/clean
You cannot include something.png and something.9.png at the same time. Delete or rename one of them.
All of the above answers where wrong for me :D
The problem was, that ive had already compiled once with files named splash.png (actually: screen.png in my case).
After draw9patching and renaming them to .9.png (which you have to in order to make them work) I had to remove all files in ant-build to get rid of the error: the compiler seems to sort of correctly fail because he gets two different files with the same name by ignoring the different extension.
You have two files in resources splash.png and splash.9.png.You cannot include splash.png and splash.9.png at the same time.
Delete the file not being used and the compile you will be able to build successfully.
As you are using two image with same name, one is simple one and another is nine patch which cause error, delete one of which you are not using or you don't wanna use.
which is not in use then delete splash.png or /splash.9.png
rename the splash.png to something else. splash.9.png is valid if it is 9-patched. But you cannot keep both splash.png and splash.9.png.
Rename splash.9.png to splashnew.png .
Never use "." "_" etc other special characters for your resource images and files!
You can remove the dots and name it splash9.png
Ref:http://developer.android.com/tools/help/draw9patch.html
Note: A normal PNG file (.png) will be loaded with an empty one-pixel border added around the image, in which you can draw the stretchable patches and content area. A previously saved 9-patch file (.9.png) will be loaded as-is, with no drawing area added, because it already exists.
To me this was my solution
First perform this action
cordova clean
And you can now do this
cordova build android