升級時碰見的異常 異常 W/asset ( 1245): Asset path /data/data/com.****.******/files/apps/pjlauncher.apk is neither a directory nor file (type=0).W/DefContainer( ...
升級時碰見的異常
private void installPackage(String appName,final File apk) { if (!apk.exists()) { setHasNewVersion(appName,false); hideProgressDialog(); return; } apk.setReadable(true, false); apk.setExecutable(true, false); //走完installPackage之後就結束了,回調observer內的代碼是非同步執行了 final PackageManager pm = getPackageManager(); PackageInstallObserver observer = new PackageInstallObserver(appName); Log.i(TAG, "install the apk begin : "+appName+";;getAbsolutePath="+apk.getAbsolutePath()); pm.installPackage( Uri.parse("file://" + apk.getAbsolutePath()), observer, PackageManager.INSTALL_REPLACE_EXISTING, null); }
private class PackageInstallObserver extends IPackageInstallObserver.Stub { private String appname; public PackageInstallObserver(String appName) { appname=appName; } public void packageInstalled(final String packageName, int returnCode) { setHasNewVersion(appname,false); String appPath = getFilesDir().getAbsolutePath()+"/apps/"+appname+".apk"; File apk = new File(getFilesDir(), appname+".apk"); Log.i(TAG, "install is end and delete "+apk.getAbsoluteFile()); apk.delete(); hideProgressDialog(); if(returnCode==1){ installReturnCode=3; }else{ if(returnCode<0){ installReturnCode=returnCode; }else{ installReturnCode=-123455; } } Log.i(TAG, "installReturnCode "+installReturnCode+"; packageName = "+packageName); new Thread(){ public void run() { postUpdateResult(packageName,appname,installReturnCode);//安裝成功 }; }.start(); } }
異常
W/asset ( 1245): Asset path /data/data/com.****.******/files/apps/pjlauncher.apk is neither a directory nor file (type=0).
W/DefContainer( 1245): Failed to parse package
W/ActivityManager( 535): No content provider found for permission revoke: file:///data/data/com.****.***/files/apps/*****.apk
D/dalvikvm( 535): GC_EXPLICIT freed 573K, 24% free 4589K/6028K, paused 2ms+3ms, total 35ms
I/AppUpgradeService( 1227): install is end and delete /data/data/com.****.******/files/apps/*****.apk
查了好半天有說是要添加許可權的,有說是要在使用時給apk修改許可權的,試了半天都沒有效果。
最後修改了apk文件的下載存放路徑,結果安裝成功。
* 如果apk下載到這個目錄/data/data/com.****.******/files/apps
* 會出現No content provider found for permission這個異常
* 如果是這個目錄/data/data/com.****.******/files
* 則沒有問題
感覺很奇怪我在其他機頂盒上測試的時候,即使是在/data/data/com.****.******/files/apps這個目錄也可以順利安裝apk,但是換了一臺機頂盒之後就不可以了
可能是不同機頂盒系統有差異吧!
ps:這個功能需要進行系統簽名,以及配置android:sharedUserId="android.uid.system"