Android Studio: unexpected Reformat Code in XML layout [duplicate] - android

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

Android Studio 3.5 auto formatting/refactoring XML layouts changes order of views [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 3.5 Code Formatting changes the order of UI components in Layout hierarchy in XML Layout [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 `Reformat code` option rearranges the order of my views in the layout [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 3.5 refactor issue

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"

Eclipse not showing suggestions in Android XML

I have installed Eclipse Indigo and the auto-complete feature is working normally in the Java editor.. the problem is in the XML editor, when I press CTRL+Space, nothing of the suggestions comes out.
Why is this?
I had faced the same problem. I was trying to solve using
sample.xml layout file -> Right click on it -> Open With -> Android Layout Editor
But no luck. Then I was trying another way
Select Project (say Myproject) from Package Explorer
Right click on the Myproject
Select Properties from popup
Select Java Build Path from left panel
Select Source from right tab
Select Myproject/gen
Click on Remove button
Repeat step 6 and 7 for Myproject/src
Press on OK button
Click on Add Folder..
Add the Myproject/gen and Myproject/src
OK again OK
It solved the problem.
Find your XML file in Package Explorer and right click on it. Select Open With -> Android Layout Editor (or select appropriate option from other options available in sub menu). Bingo! Auto-complete/content assist should start working.

Categories

Resources