Android drawable resources getting created in a debug folder? - android

I'm building an Android app using Android Studio & Kotlin. Historically, when I've added new image drawbles:
they were saved to the following folder: \app\src\main\res
However, recently (potentially after an Android Studio update?) new image drawables now wind up here: \app\src\debug\res. I haven't intentionally meant for that to happen. Now my drawables are split between the two locations. What caused this change? How do I switch it back?

You need to select the right "Res Directory", "main" when adding the drawable:

Related

Meteor run android-device failing: How to correctly define launchScreens

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.

Adding new image to Xamarin Android changes all other images

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.

No resource found that matches #drawable/test err android studio

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!

Android Studio - Set custom fonts with asset manager in fragment

I'm rewriting a project of mine to incorporate fragments for use on tablets. I also decided to start using Android Studio with the conversion. Pretty straight forward but I've run into an issue on the pretty simple task of setting a custom font.
I started with these:
Custom fonts in android and
List of files in assets folder and its subfolders and this Set custom font for Android fragments
In Eclipse my class extended Activity and I did the following in the OnCreate with no problems.(Having a directory and file "assets/FUT_R.ttf")
TextView tv=(TextView)findViewById(R.id.someTextView);
Typeface font = Typeface.createFromAsset(getAssets(), "FUT_R.ttf");
tv.setTypeface(font);
now trying to convert this Activity to an ActionBarActivity (fragment with V7 support library) and I've changed the above code to this. (where view is the inflated layout with one Framelayout for phones)
TextView tv=(TextView) view.findViewById(R.id.someTextView);
Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "FUT_R.ttf");
tv.setTypeface(font);
and it crashes at run time with the lovely java.lang.RuntimeException: native typeface cannot be madeeven though i created and 'assets' directory on my new project with FUT_R.ttf in its root.
To confirm the asset manager I tried this code:
String[] f = null;
try {
f = getActivity().getAssets().list("");
}
catch (IOException e){
e.printStackTrace();
}
for(String f1:f){
Log.i("names",f1);
}
And got the following output:
07-26 07:40:40.134 2114-2114/com.myapp I/names: images
07-26 07:40:40.134 2114-2114/com.myapp I/names: sounds
07-26 07:40:40.134 2114-2114/com.myapp I/names: webkit
I'm confused because no where in my 'assets' directory or project do I have these files and/or directories. Obviously the error is the system can't find my font file. WHAT AM I DOING WRONG? Any direction would be greatly appreciated, I've wasted far too much time on this stupid problem.
Thanks!
I finally stumbled upon this: Load a simple text file in Android Studio
which points out the assets folder in Android Studio has apparently been changed. Instead of its normal location in the root app folder (same level as libs, src, ect) it needs to be created under yourapp/src/main/assets. Hopefully this helps someone else. I wasted a lot of time on it!

Why am I not able to create android xml file?

I am creating a new project, target of this project is "GALAXY tab addon". I am creating a new xml file in layout folder an I am getting following screen which was not the case when I was developing for 2.2 or so. Where do I go next, it says the options are "optional" so I skipped them and clicked finish- No Response, I also tried selecting some options and still the file is not creating. What am i missing here?
IDE used is Eclipse.
You dont need to go till this window.you can finish creating xml file before this window like the below image.
Just click on finish button here and your xml file will be created.

Categories

Resources