2
能解決我的問題嗎? 我用Jsoup從Play商店進行版本檢查。當我從android工作室運行我的應用程序作爲調試apk。它運作良好。但是當生成簽名的Apk。當代碼運行並顯示消息時,它崩潰「不幸的是應用程序已停止」。有沒有人幫助我。我向你展示我的代碼。提前致謝。在proguard-rules.pro文件簽名apk使用jsoup崩潰但調試不
private void getCurrentVersion(){
try {
currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
new GetLatestVersion().execute();
}
public class GetLatestVersion extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
try {
latestVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + MainActivity.this.getPackageName() + "&hl=it")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com").get().select("div[itemprop=softwareVersion]").first().ownText();
return latestVersion;
}catch (Exception e){
return latestVersion;
}
}
@Override
protected void onPostExecute(String version) {
super.onPostExecute(version);
if(version!=null) {
if (!currentVersion.equals(latestVersion)){
showUpdateDialog();
}
}
else
dialog.dismiss();
}
public boolean isFinished() {
return true;
}
}
private void showUpdateDialog(){
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("A New Update is Available");
builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse
("market://details?id=com.kjsdeveloper.sattagamblers")));
dialog.dismiss();
}
});
builder.setNegativeButton("Later", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setCancelable(false);
dialog = builder.show();
}
問題是與您簽署的apk。 [檢查這個答案](https://stackoverflow.com/a/44387533/5860777),你有解決方案。 –