在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Android  網(wǎng)絡(luò)安全/ Android 7.1.1 安裝Apk問(wèn)題。

Android 7.1.1 安裝Apk問(wèn)題。

我在測(cè)試Android 7.0 安裝APK 問(wèn)題時(shí),為何使用了新的安裝方式還是不能安裝提示 解析軟甲包時(shí)出現(xiàn)問(wèn)題

非常簡(jiǎn)單的代碼:

一、 這是安裝的邏輯。因?yàn)槲沂侵苯优茉贏ndroid模擬器上面的。所以沒(méi)有做版本號(hào)的判斷。

File apkFile = new File(Environment.getExternalStorageDirectory() + File.separator + "apkFile", "aaa.apk");
if (apkFile.exists()) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri apkFileUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".fileprovider", apkFile);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setDataAndType(apkFileUri, "application/vnd.android.package-archive");
    startActivity(intent);
}

二、 這是 Provider 的配置。

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="com.example.along.installtest.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_path">

    </meta-data>
</provider>

三、這是權(quán)限的配置:

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

四、這是xml文件中的共享目錄配置:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path
        name="apkFile"
        path="apkFile" />
</paths>

然后我將此項(xiàng)目的VersionCode調(diào)高之后,打包之后,放在對(duì)應(yīng)的apkFile文件中,然后調(diào)低VersionCode打包,然后運(yùn)行顯示解析包錯(cuò)誤。這個(gè)問(wèn)題調(diào)了好久了。 請(qǐng)大神幫忙。。。。。。一下。 賊雞兒煩。

回答
編輯回答
夏夕

你把file_path.xml里面的配置改成:<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/ap...;>

<external-path
    name="external_storage_root"
    path="." />

</paths>
試一下,我的改成這樣就可以了,其他代碼跟你一樣

2018年1月18日 09:33