???
众所周知,as是由idea改版而来,所说是专门为androider开发的,但是编译时会出现各种各样的问题,agp,gradle,kotlin版本整的人头昏脑胀,十分苦恼。不久前在b乎上看到有人用idea开发android,于是果断放弃as转用idea。
idea默认是不支持Android开发的,首先我们要先安装一些插件
Android
Android Design Tools
问题1,idea没有Attach Debugger to Android Process
调试 Attach Debugger to Android Process
在顶部工具栏的任意空白处 右键点击。
选择 Customize Toolbar... (自定义工具栏)。
在弹出的窗口中,展开 Main Toolbar -> Toolbar Right(或者 NavBar Toolbar,取决于你的 IDEA 版本)。
点击工具栏列表中的某个位置,然后点击上方的 "+" (Add Action) 按钮。
在搜索框输入 Attach Debugger to Android Process。
选中该项后点击 OK,然后点击右下角的 Apply。
问题2,缩进问题
android stduio 和idea 代码格式化样式不同,可以看到as 在最后结尾("/>")时有空格而idea没有,这样会导致和同事间有很多冲突
<activity
android:name=".ui.video_make.record.Activity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".ui.video_make.record.Activity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"/>
这是最直接的修复方式,告诉 IDEA 不要压缩 XML 的空格。
打开设置:File -> Settings (Windows/Linux) 或 IntelliJ IDEA -> Settings (macOS)。
导航至:Editor -> Code Style -> XML。
点击 Spaces 标签页。
确保勾选了 In empty tag (在空标签中)。
解释:这会强制在 这种自闭合标签的斜杠前保留一个空格。
检查 Keep white spaces inside CDATA 等其他选项,确保没有奇怪的压缩设置。