1、Android9得网络请求变为了https。要想继续使用http需要添加如下配置:
在androidmanifest中的application添加:
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
在res中新建xml文件夹,文件夹下新建network_security_config.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
2、 Android Studio在build时,提示 Unable to find optional library: org.apache.http.legacy
在androidmanifest中application下方添加代码:
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
位置如下:
或者在APP build.gradle中添加:
android {
useLibrary'org.apache.http.legacy'
}
重新同步build.gradle。
3、SQLite 引入了一种新的日志模式 Write-Ahead Log (常简写为 WAL )。数据库的工作方式发生了变化。
android 9.0以下的版本 不会出现“File opened that is not a database file file is encrypted or is not a database”。
处理方法:手动关闭WAL,强制使用JOURNAL模式。
DatabaseHelper helper=DatabaseHelper.getInstance(context);
db=helper.getReadableDatabase();
db.disableWriteAheadLogging(); //禁用WAL模式
在oncreat方法中修改代码:
@Override
public void onCreate(SQLiteDatabase db) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
db.disableWriteAheadLogging(); //禁用WAL模式
}
}
大功告成。
做一些记录以便于后期使用。