android 自动更新应用程序,安装不成功问题?

1.各位大神谁可以帮忙看出我这里更新的问题
2.新版本的文件下载存储都没有问题,读取也没问题
3.总是走到安装的那一步【点击同意并安装】这个按钮就告诉我,应用未安装


//更新代码逻辑
protected void UpdateApp() {

final ProgressDialog pd; //进度条对话框

pd = new ProgressDialog(this);

pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

pd.setMessage(getResources().getString(R.string.msg_downloading_update));

pd.show();

new Thread(){

@Override

public void run() {

try {

//File file = kApplication.DownloadFile(AppURL, pd);
//String path = Environment.getExternalStorageDirectory()+"/";

                String path = Environment.getExternalStorageDirectory().toString() + "/shidoe";
                int i = AppURL.lastIndexOf("/");
                String FileName= AppURL.substring(i + 1);
                //File file = downLoadFromUrl(AppURL,FileName,path);
                String pp = path+File.separator+FileName;
                if(fileIsExists(pp))
                {
                //installApk4(pp);
                //sleep(2000); 
                install3(pp);
                //installApk2(pp);
                //installApk(file); 
                }else
                {
                    Toast.makeText(HomeGrid.this,
                            "未发现程序安装包", Toast.LENGTH_SHORT).show();

                }
                pd.dismiss(); //结束掉进度条对话框   
            } catch (Exception e) {   
                Log.i("DSK___loader.java___>>","dsk---------- Run Downloadfile or installapk failed" ); 
                Log.i("DSK___loader.java___>>","dsk-" + e.toString() ); 
            }   
        }}.start();   
}   

 private void install3(String filePath) {
    Log.i("安装", "开始执行安装: " + filePath);
    File apkFile = new File(filePath);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (Build.VERSION.SDK_INT >= 24) {
        Log.w("安装", "版本大于 N ,开始使用 fileProvider 进行安装");
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        Uri contentUri = FileProvider.getUriForFile(
                this
                , "com.dsk.chinacrown.fileprovider"
                , apkFile);
        intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
    } else {
        Log.w("安装", "正常进行安装");
        intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    }
    startActivity(intent);
}

点击更新按钮更新并安装新版本
但是总是在安装最后一步告诉我,应用未安装

Android版本限制

建议看一下下载后的安装包对不对,有可能读写错误,https://blog.csdn.net/androidwubo/article/details/84070331

1.确保安装包没有问题。
可以手动卸载原先的APP,再安装。
2.确保下载安装包完整。

安装之后对比md5 判断安装包是否损坏,安装包的版本必须必手机的版本大才能替换安装

Android studio 先去Androidmainifest.xml 给你的版本加1 再用用build apk生成一个apk,这个apk就可以安装了。
eclipse 直接去Androidmainifest.xml 给你的版本加1 再生成apk 安装

一般出现这种情况,1安装包不完整,2安装包签名不一致