冲刺7
今天十分幸福,遇到了好多问题,喜极而泣。
问题一:Gradle error:cannot invoke method buildToolVersion on null object
解决方案:Move yourbuildToolsVersionstatement to the next line。targetSdkVersion按本或者buildToolsVersion不要写成一排就行了。
问题二:Gradle 没弹出 Sync Now 出来(这个差点让我疯了,本来好好的一打开少了个选项???很慌)
解决方案:有时候改了项目,或者添加了东西,需要执行 Gradle 的 Sync Now,否则运行不起来,但是并没有弹出 Sync Now,此时只需要在 *.gradle 文件上,随便改个东西,再复原,就会在编辑器顶端显示黄色的工具条,上面有一个 Sync Now。
问题三:Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by using the command line flag -Dcom.android.build.gradle.overridePathCheck=true, or adding the line com.android.build.gradle.overridePathCheck=true' to gradle.properties file in the project directory.
解决方案:其实很简单,就是让专业点,项目导入的路径不要存在中文。
问题四:无法找到org.apache.http.legacy
解决方案:解决办法如下:
打开sdk的目录,找到如下路径
\sdk\platforms\android-23\optional
在该路径中添加缺少的jar包:org.apache.http.legacy.jar
ps:该jar包可在网上下载
在23版的部分版本中可能也会出现缺少json文件的情况,需要添加一个名为optional.json
json文件中写入如下代码:
[
{
"name": "org.apache.http.legacy",
"jar": "org.apache.http.legacy.jar",
"manifest": false
}
]
做完这些之后,需要添加jar包至libs文件夹下,同时将jar包导入项目,具体操作如下:
1.右键项目,点击Open Moudle Settings
2.点击Dependencies,再点击右边绿色加号,选择File dependency,选择libs文件夹下的刚刚导入的jar包,点击确定即可完成。
完成以上步骤之后即可成功,如未成功需另寻方法解决。
结果悲催的验证了最后一句话。。。。。
最后在https://blog.csdn.net/qq_30442585/article/details/83413147这里解决了这个问题。