在升级到Java 8和将端点升级到V2之后,我一直在获取服务器错误并在我的Appengine日志中收到以下错误:
private boolean isChromeInstalledAndVersionGreaterThan65() {
PackageInfo pInfo;
try {
pInfo = getPackageManager().getPackageInfo("com.android.chrome", 0);
} catch (PackageManager.NameNotFoundException e) {
//chrome is not installed on the device
return false;
}
if (pInfo != null) {
//Chrome has versions like 68.0.3440.91, we need to find the major version
//using the first dot we find in the string
int firstDotIndex = pInfo.versionName.indexOf(".");
//take only the number before the first dot excluding the dot itself
String majorVersion = pInfo.versionName.substring(0, firstDotIndex);
return Integer.parseInt(majorVersion) > 65;
}
return false;
}
答案 0 :(得分:2)
原来是因为作为应用引擎升级的一部分,以下语句不再有效
import com.google.appengine.repackaged.com.google.gson.Gson;
import com.google.appengine.repackaged.com.google.gson.GsonBuilder;
...
Gson gson = new GsonBuilder().create();
您需要改用新的Json库:
1)向您的gradle文件添加新的依赖项:
compile 'com.google.code.gson:gson:2.8.1'
2)替换
import com.google.appengine.repackaged.com.google.gson.Gson;
import com.google.appengine.repackaged.com.google.gson.GsonBuilder;
使用
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;