how to create layout folder depending on api version? - android-studio

i want to Create different layout depending api version as follows. Since the default folder layout is already available,when i create new layout as below screenshot it doesnt apppear in android studio folder list under res. but i right click on res and open with explorer those folder does shows. can any one please help me how to create those layout folder.
/res/layout/layout.xml (Default)
/res/layout-v14/layout.xml (Api 19)
/res/layout-v17/layout.xml (API 21)

I think the reason for not seeing the folders is due to the current viewing option you have selected in Android Studio. (please refer to the image below)
When Android is selected the folders are more compact, meaning it will focus on showing a single resource/folder regardless of qualifiers and I think that's what you experience. Switching to Project would solve it however.
This viewing option does have some great benefits by the way, for example I really love how gradle scripts are grouped together and it even shows the Global gradle.properties file (at least on MacOS) which it doesn't in Project view.

Related

Is there a way to hide empty sourceSets in Android Studio

I'm writing a Kotlin Multiplatform project in Android Studio. As a result, I have multiple sourceSets configured in the project but some of them are empty. Removing them from the Gradle build is not possible as they are required for building the project. Is there a way to hide them from being displayed by the IDE?
(Android Studio Dolphin | 2021.3.1 Patch 1)
There is no built-in way to hide empty source sets, but you can create a custom annotation to do this.
Here is the Example. I Hope It would help you.
#Target(AnnotationTarget.CLASS)
#Retention(AnnotationRetention.SOURCE)
annotation class HideEmptySourceSet
For more details about annotations check this link:
https://kotlinlang.org/docs/annotations.html
Click the dropdown at the top labeled "Android" and select the "Project" view instead. This will display only the directories that are actually present on the filesystem rather than showing every source set that's configured.
Unfortunately there is no such option built-in in Android Studio environment.
It's also possible to use a different view (e.g. Project) or define bookmarks and favourites to navigate around quickly.
I would advise to try out the favourites, as setting up will take about 3 minutes and will make it way more comfortable to use.

File Android.png does not exist in Android Studio when create image asset

When I try to create action icon in Image Asset of Android Studio I saw the error log: Android.png does not exist and I can not create action icon. Anyone can help me?
screenshot
This issue can be resolved by:
Select Launcher Icons, definitely, there will be the previous linked file which was removed from the system. Just go there and choose some other file and the issue will be resolved automatically.
In my case it was an image wizard issue. Image asset wizard caches path to ic_launcher icon and can't find it.
To resolve it you need repick ic_launcher image file for background layer and/or/maybe foreground layer.
Also you can use such command line tool like ack to find all strings 'burma_launcher.png' and manually edit finded files
recommend that you use the material design style for action bar and tab icons, even if you support older Android versions. Use appcompat and other support libraries to deliver your material design UI to older platform versions.
As an alternative to Image Asset Studio, you can use Vector Asset Studio to create action bar and tab icons. Vector drawables are appropriate for simple icons and can reduce the size of your APK.

can't find layout and classes in Android Studio

I'm a noob in Android studio and Java, I do have a solid c# background, but I can't seem to fix this problem:
Some of my partners asked to add a button to a previous android build created by someone else, so I downloaded Android studio and imported the project, but I can't seem to find anything in there. We can't contact the creater of the project to ask in what he developed the app.
As you can see, there's no layout in the project.
And this is what the project folder looks like:
Where Can I edit layouts? Am I in the wrong IDE?
Thanks
If you want to change the Layout, you can do Two things:
OPTION 1
1. Simply click into your Xml file and select the "Text" option at the bottom on your screen
2.Change to layout
OPTION 2
1.Just drag another layout in Design and put your items in it, delete your old layout PS. you can have layouts in other layouts
Now, Thats just for the Layouts, to see classes just do...
after double clicking that, itl bring up a new tab.
PS This is somewhat a Duplicate, try to search up your question first instead of making a new question
link to duplicate: Android Studio - How to change layout

Android Studio project folders not showing

I am unable to see the folders that are physically existing, this is the case.
But in actual fact I have other folders as welll
So what can I do?
Above your the file directory view in Android Studio is a drop down which currently is most likely set to Android. Change it to Project and you should be able to see all your files.
I tried the all the approaches mentioned above but can't fix rather than fix it by a hardcore approach -
Step 1. Close your Android studio.
Step 2. Delete .gradle and .idea folder from your project directory.
Step 3. Open your project and you will see the files again.
go to View menu then click tool window then after click on project
view->toolwindow->project
it worked for me
for me doing the following works:
from menu go to: View--->tool windows ---> Project
then click the little gears icon (settings) you will see an option to change the empty middle packages. it looks like this:
disable "Hide Empty Middle Packages" under the Project View settings dropdown and then it should make everything show up.
If anyone ever does what I did maybe this will help:
Android Studio does not like it when module names begin with a number. I was learning from some tutorials and named the first module "1-name" and the next one "2-name". Setup was fine and it ran, but only the "Gradle" Scripts entry would show in the navigation window in "Android" mode.

Visual Studio 2012 not recognizing all pending changes?

I'm working in TFS with my team for project and the problem occurs when I'm trying to make new modeling project for my classes, it doesn't show up in pending changes.
So here is how I go:
First I enter my folder where I keep my classes. I've tried from there many combinations: I've tried first right-clicking on my folder and putting "check-out for edit" and then continued to * (see later); next I've tried clicking on .csproj of my classes so I activate my project when I'll be adding modeling project and then moved to *; last I tried to activate whole solution of our whole projects which is connecting them and then to moved to *.
None of it worked. (I was always having last version)
here is what I did next for all the possibilities:
I went to Architecture -> New diagram (named diagram and left create new project) -> Create (then windows shows up for creating new project in which folder and I always select my folder where I keep my classes).
After when that was done, I went to check to "pending changes" in Team Explorer, because there should be some available since I created already Modeling project. But there was none. Since I couldn't do it like that, the last solution how I made it was by right-clicking to Source-control Explorer on my project and going to Add items to folder and selected my project which was created locally where I wanted it to be created.
But, this last solution was giving me errors while trying to open my modeling project after. I know I should activate first modeling project, so I clicked to .modelproj and while clicking to it, it was giving me this "notice" or rather "warning":
The solution you have opened is under source control but not currently configured for integrated source control in Visual Studio. Would you like to bind this solution to source control now?
--
What am I doing wrong? Why solutions are not integrated by default while creating my project (my friends are doing it automatically, they don't need to right-click in Source Control Explorer to add item to be able to see pending changes)?
I hope I made myself understandable.
It looks like your solution binding is broken. Either click yes on the question to bind your solution to source control, this is information that must be stored in the solution file and while Visual Studio does see that the folder is mapped to source control, it also sees that your solution isn't (did you check the add solution to source control checkbox when you created it?)
Optionally try opening file -> Source Control -> (optionally) Advanced -> Manage Source Control. You can select project in your solution individually and then click the bind button on the toolbar to bind them to sourcecontrol manually.
I had a similar issue and, in my case, the solution was to right click on my project and choose Source Control->Go online. Apparently I must have somehow been switched to the offline mode.
I have successfully checked in files from source control explorer instead of solution explorer in this case. Then after that it has worked again
VIEW > Other Windows > Source Control Explorer
Other way to do it:
File--> Source Control --> Advance --> Change Source Control.
In the window displayed select all the projects you want to bind to the TFS
I had the same issue and solve it by clicking:
File -> Source Control -> Advanced -> Refresh Status
In VS2013+, you can check if your solution is online. In my case, due to VSO service outage, my solutions went offline. I had to open the solution, File > Source Control > Go Online.

Resources