APK扩展文件-下载程序库不支持安卓奥利奥和安卓工作室3.2版



我认为最初的APK扩展库设计有点过头。并且不支持android奥利奥。

首先:我正在尝试使用谷歌的下载库和应用程序许可服务,因为我的应用程序将使用APK扩展。我从中阅读指南https://developer.android.com/google/play/expansion-files#java和https://kitefaster.com/2017/02/15/expansion-apk-files-android-studio/,一切都很顺利。但是error.expandition.downloader不存在。我做的每件事都是作为向导在此处输入图像描述,在此处输入图片描述,在这里输入图片描述

最终,我使用了git-hub中的libhttps://github.com/bolein/better-apk-expansion但在下载OBB文件时,它总是处于IDownloaderClient.STATE_FAILED_FETCHING_URL状态,并且它不支持带有错误toast的Android奥利奥。开发人员警告包未能在频道上发布通知。代码下载OBB文件:

if (!expansionFilesDelivered()) {
try {
Intent launchIntent = SampleDownloaderActivity.this
.getIntent();
Intent intentToLaunchThisActivityFromNotification = new Intent(
SampleDownloaderActivity
.this, SampleDownloaderActivity.this.getClass());
intentToLaunchThisActivityFromNotification.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentToLaunchThisActivityFromNotification.setAction(launchIntent.getAction());
if (launchIntent.getCategories() != null) {
for (String category : launchIntent.getCategories()) {
intentToLaunchThisActivityFromNotification.addCategory(category);
}
}
// Build PendingIntent used to open this activity from
// Notification
PendingIntent pendingIntent = PendingIntent.getActivity(
SampleDownloaderActivity.this,
0, intentToLaunchThisActivityFromNotification,
PendingIntent.FLAG_UPDATE_CURRENT);
// Request to start the download
int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this,
pendingIntent, SampleDownloaderService.class);
if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
// The DownloaderService has started downloading the files,
// show progress
initializeDownloadUI();
return;
} // otherwise, download not needed so we fall through to
// starting the movie
} catch (NameNotFoundException e) {
Log.e(LOG_TAG, "Cannot find own package! MAYDAY!");
e.printStackTrace();
}
} else {
validateXAPKZipFiles();
}

我希望有人能给我一个解决方案。


尝试使用Github中的最新扩展代码。谷歌还没有更新他们的文档。代码位于:https://github.com/google/play-apk-expansion

我真的不知道你的问题,但我下面的代码使用的是play-apk扩展,运行良好。只需注意,当使用模拟器使用谷歌播放支持的图像。

void check_apkx(){
if (!expansionFilesDelivered()) {
try {                  
Intent launchIntent = MainActivity.this.getIntent();
Intent intentToLaunchThisActivityFromNotification = new Intent(
MainActivity.this, MainActivity.this.getClass());
intentToLaunchThisActivityFromNotification.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentToLaunchThisActivityFromNotification.setAction(launchIntent.getAction());
if (launchIntent.getCategories() != null) {
for (String category : launchIntent.getCategories()) {
intentToLaunchThisActivityFromNotification.addCategory(category);
}
}
// Build PendingIntent used to open this activity from
// Notification
PendingIntent pendingIntent = PendingIntent.getActivity(
MainActivity.this,
0, intentToLaunchThisActivityFromNotification,
PendingIntent.FLAG_UPDATE_CURRENT);
// Request to start the download
DownloaderClientMarshaller.startDownloadServiceIfRequired(this,
pendingIntent, SampleDownloaderService.class);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
} else {
//            validateXAPKZipFiles();

}

最新更新