AndroidStudio踩坑记录
1.Permission is only granted to system apps:
在添加一些系统权限时,我们会遇到编译出错的情况如下:
Android Studio的解决方法
File -> Settings -> Editor -> Inspections
在Android Lint下面,将 Using system app permission的Error改成Warning。
2.Could not find com.android.tools.build:aapt2:3.2.0-alpha14-4748712.
在最上级的builde.gralde增加谷歌库 解决问题
allprojects {
repositories {
google()//新增的
jcenter()
}
}
3.Android9.0_P:ClassNotFoundException: Didn’t find class "org.apache.http.conn.scheme.SchemeRegistry"
解决方案见官方文档:https://developer.android.google.cn/about/versions/pie/android-9.0-changes-28
参考连接:https://blog.youkuaiyun.com/chinaboyliusir/article/details/82755193
Apache HTTP 客户端弃用、
在 Android 6.0 中,我们取消了对 Apache HTTP 客户端的支持。 从 Android 9 开始,默认情况下该内容库已从 bootclasspath 中移除且不可用于应用。
要继续使用 Apache HTTP 客户端,以 Android 9 及更高版本为目标的应用可以向其 AndroidManifest.xml的application节点下 添加以下内容:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
4. Cleartext HTTP traffic to … not permitted
参考自:https://blog.youkuaiyun.com/xfhy_/article/details/83000541
接入bugly sdk时候 发现接完了 错误不在bugly后台显示,报了这个错Cleartext HTTP traffic to android.bugly.qq.com not permitted
,搜了一下,原因如下:
Android P需要进行适配(限制了明文流量的网络请求,非加密的流量请求都会被系统禁止掉). 当我发现这个的时候,仿佛看到了一丝光明,抱着试一试的心态,搞了一下,果然可行.(测试机型为Android 9.0)
解决办法
具体原因:Android P - CLEARTEXT communication not permitted by network security policy 详细介绍
在资源文件res目录下新建xml目录,新建文件network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">android.bugly.qq.com</domain>
</domain-config>
//我这里是使用这句话代替上面三句,我按照上面的三句不起作用 可能跟我的啥设置有关系 这里用<base-config cleartextTrafficPermitted="true" />
</network-security-config>
然后在清单文件中application下加入android:networkSecurityConfig="@xml/network_security_config"
即可