Android Studio 3.5 Reformat Code in XML files issues [duplicate] - android-studio

I've just updated to Android Studio 3.5 and now when I try to refactor the file AndroidManifest.xml, all my app permissions are moved to the bottom of the file.
Has anyone else faced this issue? Is there any solution for this?
Before refactor:
After refactor:
It is applicable to my all project files.
Why it matters:

You just need to set xml layout for Android applications from the settings.
Follow this steps:
1. Go to Android Studio > Preferences. For Windows, go to File > Settings.
2. Search for xml in search bar.
3. Under code style section, select xml tab.
4. In the top right corner, click on set from... and under predefined style, select Android
5. Click on Apply and try to refactor.

Reset the appropriate Android code style as follows.
For Windows Only
Step1: Click on the file menu.
Step2: Navigate to Setting.
Step3: Find Editor in the Left Panel**.
Step4: Find Code Style in the Sub Menu of Editor.
Step5: Click on XML in the Sub Menu of Code Style.
Step6: Click on Set from in Top right corner of Right panel.
Step7: Select Predefined Style.
Step8: Select Android.
Step9: Click OK.
For macOS Only
Step1: Click on the Android Studio menu.
Step2: Navigate to Preferences.
Step3: Find Editor in the Left Panel**.
Step4: Find Code Style in the Sub Menu of Editor.
Step5: Click on XML in the Sub Menu of Code Style.
Step6: Click on Set from in Top right corner of Right panel.
Step7: Select Predefined Style.
Step8: Select Android.
Step9: Click OK.

It seems the default scheme leaves out the "attribute" property in the arrangement rules. Adding them back in works like a charm for me.
The correction can be made in: Preferences > Editor > Code Style > XML

Just adding more details .
This is a known issue with android studio from Android Studio 3.5 Canary 8 . It should get fixed in next version as this turned out to affect large number of developers .
You can see status of the bug here
Also the solution is
Broken XML code style
When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:
Open the Settings window by clicking File > Settings (on macOS, Android Studio > Preferences).
In the left panel, click Editor > Code Style > XML.
Near the top-right corner of the right panel, select Set from > Predefined Style > Android
Click OK.
Which is found here -> Known issues with Android Studio and Android Gradle Plugin
Edit: This is now fixed in Android studio version 3.5.2

ctrl + alt + s
Search XML
I wanted to do the same steps as the first answer, but I just needed to change the default scheme to project.
I hope that you also solve it this way . Sorry for my English !

If you have a custom code style defined, you have to specify a type for each rule: tag or attribute.
It seems like after the update, if you do not specify a type, the rules will be applied to both. Not sure if it is a bug, but that's how i fixed.
This does not work on 3.5
After adding the attribute type to each rule, it worked

Please follow these steps for Windows version of "Android Studio 3.5"
1: Click on the File in the Menu.
2: Go to Settings.
.
3: Click on Editor.
4: Click on Code Style
5: Click on XML.
6: Click on "Set from..." in top-right corner.
7: Select Predefined Style.
8: Select Android.
9: Click OK.

3.5.0 known issue
When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:
Open the Settings window by clicking File > Settings (on macOS,
Android Studio > Preferences).
In the left panel, click Editor > Code Style > XML.
Near the top-right corner of the right panel, select Set from >
Predefined Style > Android.
Click OK.

For anyone searching this for Android Studio 4+ :
File -> Setting -> Editor -> Code Style -> XML -> Arrangement ->
Set Force rearrange to "Never"
Set from to "Android"

Related

Make XML Split view default in Android Studio 3.6+?

In Android Studio 3.6 and above, an XML file always opens in the "Code" view by default. How do I make it open in "Split" view by default?
UPDATED
Now for Android Studio "Arctic Fox" - Preferences -> Editor -> Design Tools. Nice!
In Android Studio 3.6 if you open Preference->Editor->Layout editor you can see for this case only check/uncheck "Prefer XML editor" for show modes "Code" or "Design" view without "Split", very strange... Waiting for possibility check mode "Split"
UPDATED
Now Android Studio 4.0 has "Split" option. Nice!
Here's what worked for me, hope it works for you too.
Close all tabs in your editors.
Open one xml file and click on the split view button at the top-right section of the tab.
Close the tab again.
Android Studio then remembered my selection for all other tabs opened from then on.
Using the keyboard shortcuts (Ctrl + Shift + Left/Right Arrow if you are on a Mac, or Alt + Shift + Left/Right Arrow otherwise):
Code: provides the functionality of an XML text editor.
Design: consists of a view containing the design editor (e.g. navigation graph, layout) that can be used to edit the file graphically.
Split: displays both Code and Design side-by-side, so you can preview your design while editing the text.

XML file code format issue in Android Studio [duplicate]

I've just updated to Android Studio 3.5 and now when I try to refactor the file AndroidManifest.xml, all my app permissions are moved to the bottom of the file.
Has anyone else faced this issue? Is there any solution for this?
Before refactor:
After refactor:
It is applicable to my all project files.
Why it matters:
You just need to set xml layout for Android applications from the settings.
Follow this steps:
1. Go to Android Studio > Preferences. For Windows, go to File > Settings.
2. Search for xml in search bar.
3. Under code style section, select xml tab.
4. In the top right corner, click on set from... and under predefined style, select Android
5. Click on Apply and try to refactor.
Reset the appropriate Android code style as follows.
For Windows Only
Step1: Click on the file menu.
Step2: Navigate to Setting.
Step3: Find Editor in the Left Panel**.
Step4: Find Code Style in the Sub Menu of Editor.
Step5: Click on XML in the Sub Menu of Code Style.
Step6: Click on Set from in Top right corner of Right panel.
Step7: Select Predefined Style.
Step8: Select Android.
Step9: Click OK.
For macOS Only
Step1: Click on the Android Studio menu.
Step2: Navigate to Preferences.
Step3: Find Editor in the Left Panel**.
Step4: Find Code Style in the Sub Menu of Editor.
Step5: Click on XML in the Sub Menu of Code Style.
Step6: Click on Set from in Top right corner of Right panel.
Step7: Select Predefined Style.
Step8: Select Android.
Step9: Click OK.
It seems the default scheme leaves out the "attribute" property in the arrangement rules. Adding them back in works like a charm for me.
The correction can be made in: Preferences > Editor > Code Style > XML
Just adding more details .
This is a known issue with android studio from Android Studio 3.5 Canary 8 . It should get fixed in next version as this turned out to affect large number of developers .
You can see status of the bug here
Also the solution is
Broken XML code style
When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:
Open the Settings window by clicking File > Settings (on macOS, Android Studio > Preferences).
In the left panel, click Editor > Code Style > XML.
Near the top-right corner of the right panel, select Set from > Predefined Style > Android
Click OK.
Which is found here -> Known issues with Android Studio and Android Gradle Plugin
Edit: This is now fixed in Android studio version 3.5.2
ctrl + alt + s
Search XML
I wanted to do the same steps as the first answer, but I just needed to change the default scheme to project.
I hope that you also solve it this way . Sorry for my English !
If you have a custom code style defined, you have to specify a type for each rule: tag or attribute.
It seems like after the update, if you do not specify a type, the rules will be applied to both. Not sure if it is a bug, but that's how i fixed.
This does not work on 3.5
After adding the attribute type to each rule, it worked
Please follow these steps for Windows version of "Android Studio 3.5"
1: Click on the File in the Menu.
2: Go to Settings.
.
3: Click on Editor.
4: Click on Code Style
5: Click on XML.
6: Click on "Set from..." in top-right corner.
7: Select Predefined Style.
8: Select Android.
9: Click OK.
3.5.0 known issue
When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:
Open the Settings window by clicking File > Settings (on macOS,
Android Studio > Preferences).
In the left panel, click Editor > Code Style > XML.
Near the top-right corner of the right panel, select Set from >
Predefined Style > Android.
Click OK.
For anyone searching this for Android Studio 4+ :
File -> Setting -> Editor -> Code Style -> XML -> Arrangement ->
Set Force rearrange to "Never"
Set from to "Android"

Android Studio XML tags sorting [duplicate]

I've just updated to Android Studio 3.5 and now when I try to refactor the file AndroidManifest.xml, all my app permissions are moved to the bottom of the file.
Has anyone else faced this issue? Is there any solution for this?
Before refactor:
After refactor:
It is applicable to my all project files.
Why it matters:
You just need to set xml layout for Android applications from the settings.
Follow this steps:
1. Go to Android Studio > Preferences. For Windows, go to File > Settings.
2. Search for xml in search bar.
3. Under code style section, select xml tab.
4. In the top right corner, click on set from... and under predefined style, select Android
5. Click on Apply and try to refactor.
Reset the appropriate Android code style as follows.
For Windows Only
Step1: Click on the file menu.
Step2: Navigate to Setting.
Step3: Find Editor in the Left Panel**.
Step4: Find Code Style in the Sub Menu of Editor.
Step5: Click on XML in the Sub Menu of Code Style.
Step6: Click on Set from in Top right corner of Right panel.
Step7: Select Predefined Style.
Step8: Select Android.
Step9: Click OK.
For macOS Only
Step1: Click on the Android Studio menu.
Step2: Navigate to Preferences.
Step3: Find Editor in the Left Panel**.
Step4: Find Code Style in the Sub Menu of Editor.
Step5: Click on XML in the Sub Menu of Code Style.
Step6: Click on Set from in Top right corner of Right panel.
Step7: Select Predefined Style.
Step8: Select Android.
Step9: Click OK.
It seems the default scheme leaves out the "attribute" property in the arrangement rules. Adding them back in works like a charm for me.
The correction can be made in: Preferences > Editor > Code Style > XML
Just adding more details .
This is a known issue with android studio from Android Studio 3.5 Canary 8 . It should get fixed in next version as this turned out to affect large number of developers .
You can see status of the bug here
Also the solution is
Broken XML code style
When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:
Open the Settings window by clicking File > Settings (on macOS, Android Studio > Preferences).
In the left panel, click Editor > Code Style > XML.
Near the top-right corner of the right panel, select Set from > Predefined Style > Android
Click OK.
Which is found here -> Known issues with Android Studio and Android Gradle Plugin
Edit: This is now fixed in Android studio version 3.5.2
ctrl + alt + s
Search XML
I wanted to do the same steps as the first answer, but I just needed to change the default scheme to project.
I hope that you also solve it this way . Sorry for my English !
If you have a custom code style defined, you have to specify a type for each rule: tag or attribute.
It seems like after the update, if you do not specify a type, the rules will be applied to both. Not sure if it is a bug, but that's how i fixed.
This does not work on 3.5
After adding the attribute type to each rule, it worked
Please follow these steps for Windows version of "Android Studio 3.5"
1: Click on the File in the Menu.
2: Go to Settings.
.
3: Click on Editor.
4: Click on Code Style
5: Click on XML.
6: Click on "Set from..." in top-right corner.
7: Select Predefined Style.
8: Select Android.
9: Click OK.
3.5.0 known issue
When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:
Open the Settings window by clicking File > Settings (on macOS,
Android Studio > Preferences).
In the left panel, click Editor > Code Style > XML.
Near the top-right corner of the right panel, select Set from >
Predefined Style > Android.
Click OK.
For anyone searching this for Android Studio 4+ :
File -> Setting -> Editor -> Code Style -> XML -> Arrangement ->
Set Force rearrange to "Never"
Set from to "Android"

Android Studio upper menu

After updating to High Sierra beta, my upper menu bar disappears. I can't find a way to bring it back.
Here is how it's looking after the update:
You have to install the Java 6 Runtime https://support.apple.com/kb/DL1572
Also duplicate of Menu bar not showing in Android Studio
Right click on the main tool bar, and choose Customize Menus and Toolbars,
expand the main menu and select item then click "add after" button then select an icon for the item, add all items in main menu separately.
The easiest way is to downgrade Android studio.
You can show the upper menu by right clicking on the main tool bar, and choosing Customize Menus and Toolbars, then choose restore all defaults. I hope this answer is helpful.
Edit vmoptions with cmd + shift + a and add this line :
-Dapple.laf.useScreenMenuBar=false
Restart the application.

Adding ReSharper options to context menu in Visual Studio

In Visual Studio 2005, my coworker can right click a tab and he has an option "Find in Solution Explorer". I know this is from ReSharper and I'm running ReSharper 5.1 - how do I enable this extra context menu? I also know about the Shift+Alt+L shortcut for the same command but want to add the context menu.
This is what I see when I right click on a tab. The picture below is when I right clicked on a .cs file.
EDIT: Typo in the title.
Tools > Customize... > Toolbars tab > tick Context Menus. Find Other Context Menus > Easy MDI Document Window. Commands tab > ReSharper > ReSharper_LocateInSolutionExplorerAction. Drag it into the menu. Click Close.

Resources