简书链接:绝对原创全球首发再无分店直击纯手动AndroidStudio项目工程无法运行修复完美解决各种项目不能运行损失严重问题
文章字数:1182,阅读全文大约需要4分钟
转载或抄袭请注明出处:
还在逃避问题?还是选择新创建项目重新拷贝拖动文件夹????醒醒吧!看了我这个文章,你再也不用纠结各种clear build为何不能解决问题了 ?明明正常却没有运行模块选项了,

作为强迫症患者的我以前遇到这个问题 ,这次比较头疼,各种大招都试过了,还是解决不了,于是我焕然大悟的来一个
大排查,经过分析找到了原因。

硬是要搞定这个问

根目录iml文件结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="qq_qqrobot" external.linked.project.path="$MODULE_DIR$"
external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
1
2
3
4
5
6
7
8
9
10
11
12
13
而这个iml文件那么应该叫```qq_qqrobot.iml```
如何解决iml不生成,

### 错误状况
![image.png](https://upload-images.jianshu.io/upload_images/2815884-8eb78fc9217bb3d3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
错误状况如上图所示,惨不忍睹,但是```settigns.gradle```没有任何错误


另外也没有任何模块可以选择如下图所示

![image.png](https://upload-images.jianshu.io/upload_images/2815884-8654ca3d02d10124.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

```settigns.gradle```文件内容如下:

//include ‘:robot_sdk’,
include ‘:plugincheckmember’
include ‘childgit:app’
include ‘childgit:customcrashlibrary’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

正常的项目是这样的图标有一个绿色的点
![image.png](https://upload-images.jianshu.io/upload_images/2815884-fa268a8c3d78df91.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

另外gradle视图是灰色的

![image.png](https://upload-images.jianshu.io/upload_images/2815884-863bdc4140fd2fb7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

### 那么如何解决这个问题呢?

重启android studio?重启电脑? reBuild project make Project?? clear Project?? Make Project app? Sysc Project and File System? Invalidate Cache /Restart
gradlew build ?? gradlew xxxx? 以前setting.gradle配置正确可以回来,如今然并卵的,并不能让子目录的```iml```重新回来.


最后对比没有什么发现,那么就是idea文件夹了。
打开正常的项目```t\.idea\gradle.xml```
1
在```options```节点添加就可以修复啦 修改之后是
1
2
3


打开```module.xml```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


修改之后结果关闭项目重新打开
![image.png](https://upload-images.jianshu.io/upload_images/2815884-6380dd1349a74982.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![image.png](https://upload-images.jianshu.io/upload_images/2815884-303888e6008a4d75.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


![image.png](https://upload-images.jianshu.io/upload_images/2815884-2b7ca44e91164ac3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
```Android Studio报错“Error running ***: Please select Android SDK```的问题已经遇到过。
光选择项目设置sdk是没用的,实际上已经设置了,解决方法就是修改buildTool版本,我这里降级版本就ok,之前我用的3.1正式版,gradle后面降级了,但是sdk没降级。

ok,纯手修复成功! 觉得6的点个赞!再看看我其他的踩坑文章
再附上成功的图

![image.png](https://upload-images.jianshu.io/upload_images/2815884-59b992bc15e2f13a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![image.png](https://upload-images.jianshu.io/upload_images/2815884-61a14472e0890496.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


再看看gralde视图任何灰色了。

![image.png](https://upload-images.jianshu.io/upload_images/2815884-2e90d276e2fa9196.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

如果还是没有选项,打开```.idea/workspace.xml```
搜索``` <component name="RunManager">```在下面插入如下代码

``` 或者点击运行-编辑配置 ![image.png](https://upload-images.jianshu.io/upload_images/2815884-90fc2edb8d63ccbf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

image.png

如果第三步依然没有选择, 不存在的,除非你这根本就没有添加application模块。
ok。教程完美,我以后再也不苦逼的clear project 了,

最后打一个广告,欢迎广大开发者开发情迁QQ机器人插件哈/!

支持如下api,安卓程序员绝对容易开发
image.png