I've tried all solutions. Finally decided to post this question.
The situation is as follows:
My drawable has test.png image which I use in my project.
In eclipse it works perfectly but in Android Studio it doesn't work.
Also I'm not getting any compiler error.
I am getting only this type of error almost 54 times when cradle build. As this image is set of as background to 54 screens. :(
What could be the problem?
You should remove the extension part.
For example if your image is called mimg.png in your
resource files you should access it via #drawable/mimg.
Edit
If in eclipse is fine, then create the project new and add file by file. I also had this issues and after some tries ai gave up and created new and after added file by file.
As an alternative please check if you add it in other drawables folders.
That's it.
You need to reference your drawable without the extension: Like this:
android:src="#drawable/test"
Remove the image extension from your xml file and try that please!
Related
I tried executing the following line to load gif image, programatically.
gifInputStream = context.getResources().openRawResource(R.drawable.image);
But, studio used to indicate an error near "R.drawable.image".
I found a solution, or rather hack around to my issue. I just added "+" symbol. So, the line looks like this now...
gifInputStream = context.getResources().openRawResource(+R.drawable.image);
AndroidStudio doesn't show any error now.
it required raw file not drawable.
Please create res/raw/ directory and move your file in the raw directory.
after then:-
context.getResources().openRawResource(R.raw.yourfilename)
Trying to change the default splash screen on my meteor app. Running meteor run android-device produces a long error message (see relevant section below).
From what I gather, it seems the three nine patch files are being referenced twice...but I have no idea how to de-reference them.
The app worked before I added the following to my mobile-config.js and added the actual image files. Commenting out the three android lines does not help. Deleting the nine patch files will also not help.
App.launchScreens({
'android_xhdpi_portrait':'splash/xhdpi.9.png',
'android_hdpi_portrait':'splash/hdpi.9.png',
'android_mdpi_portrait':'splash/mdpi.9.png',
'ipad_portrait_2x':'splash/ipad_portrait_2x.png',
'ipad_portrait':'splash/ipad_portrait.png',
'iphone_2x':'splash/iphone_2x.png',
'iphone5':'splash/iphone5.png',
'iphone6':'splash/iphone6.png',
'iphone6p_portrait':'splash/iphone6p_portrait.png'
});
I'm quite sure the images only exist in the directory once. I know the path is correct because the ios splash images work perfectly.
Here is the relevant piece of console output:
res/drawable-port-mdpi-v4/screen.png:0: error: Resource entry screen is
already defined.
res/drawable-port-mdpi-v4/screen.9.png:0: Originally defined
here.
res/drawable-port-hdpi-v4/screen.png:0: error: Resource entry screen is
already defined.
res/drawable-port-hdpi-v4/screen.9.png:0: Originally defined
here.
res/drawable-port-xhdpi-v4/screen.png:0: error: Resource entry screen is
already defined.
res/drawable-port-xhdpi-v4/screen.9.png:0: Originally defined here.
The meteor docs state:
For Android, launch screen images should be special "Nine-patch" image files that specify how they should be stretched.
The Android docs state (in relation to nine patch files):
It must be saved with the extension .9.png...
I used the nine patch generator here (googlecode.com) that automatically takes a .png and outputs .9.png files.
However, using the .9.png file extension was the issue here. For some reason, the cordova/meteor build process did not handle files already in .9.png format.
Final answer: If using a .9.png generator, rename the files to just .png before adding them to your meteor project.
I'm new to Xamarin and I'm facing strange issue that whenever i try to add new image to Resources/drawable folder of Android and referring it to shared code,all other images are getting change and starts referring random images.
Steps which I'm following :
Add a new Image to Resources/drawable folder.
Change Build Action to "AndroidResources".
And referring the new image in Source attribute.
thanks in advance.
Looks like your Android resource generated file was not re-generated or broken. Try Clean-Build Android project. If that doesn't help, delete bin and obj folders and try building again.
I have added an image to my Android project which I want to use in the UI. I have added the file my-image.png to the drawable directory (to all 4 drawable directories created with the project), and added the ImageView to the layout:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#+id/textView"
android:layout_marginBottom="63dp"
android:src="#drawable/my-image" />
The problem is that I get the following error:
Rendering Problems
Failed to convert #drawable/my-image into a drawable
This is the capture:
Additionaly, if I try to compile the project, I get the following error:
Gradle: Execution failed for task ':MyProject:processDebugResources'.
Why do I get these errors and how can I solve it? Am I missing something? I've just started Android development.
Gradle: Execution failed for task ':MyProject:processDebugResources'.
because you have naming convention error in Resources
file name: must contain only [a-z0-9_.]
Rename file name to my_image
Rename this drawable #drawable/my-image to #drawable/my_image
Try using underscore and small characters in file name, for example
my_image.png
Try To use only abc...xyz and 0123...9, dont use -, instead use _(underscore).
Use my_name instead of my-name, because Hyphens(-) have a special meaning in coding, so it cant be use literally with strings.
If the naming convention is correct try:
Open up resources dialog and see if image png preview is displayed.
Select image in design view > Go to properties > Click the ellipsis button > Drawable > Search for your png image and click on it.
If the preview is not displayed cancel out of resources, and try resaving the image again in png format.
This example uses photoshop CS2. Open image in photoshop and select Files > Save For Web > Click Save. (Do not use File > Save As)
It worked for me you should not include special characters only alphabets
I am using redlaser api in my app. I am getting "Resource not found" exception in the anim folder. But I am not using any of the animation file in the acitivity where I am using the redlaser. Its showing the error in the first file of anim folder, If I delete that file, then its showing the error in the next file (which is first now).
I have attached the exception as screen shot here
You can see that the error is there in the api, showing the error in the following line
com.ebay.redlasersdk.scanner.BarcodeScanActivity.initBeepSound(BarcodeScanActivity.java:353)
In the getBeepResource() method that you have implemented in your activity, fully qualify the name of the resource by adding the package name of your R.java file. For example, in the RLSample project the getBeepResource() method is implemented in the RedLaserSDK.java file. In that method replace the line returning the resource with this line:
return com.ebay.rlsample.R.raw.beep;
This will fix the issue. Do the same in your app code as well (changing the package name to match your app).