問題描述
APK 擴展文件下載不起作用 (APK Expansion file download doesn´t work)
我需要將擴展支持集成到我的應用中。到目前為止,我的應用程序中有示例 DownloaderActivity、Service 和 Receiver。
現在我設置了 XAPKFile
return new XAPKFile[]{new XAPKFile(
true,//is main?
3,//Version
4550105L)};//File size
文件大小是正確的,它不是“磁盤大小”,但我也試過了。
版本號始終等於我的 apk 包版本。
我將這兩個版本都作為 alhpa 版本上傳到市場上以對其進行測試並使其他人無法訪問。
測試帳戶是開發者帳戶。
問題是現在,下載不會開始。我總是收到提示“下載失敗,因為您可能沒有購買此應用程序”。
我昨天在下載器服務中調試了很多應用程序,以找到實際問題。我在 LicenseValidator.java 驗證方法中從服務器返回的響應代碼始終為 NOT_LICENSED。
RSA 密鑰是正確的。
為什麼我的應用沒有獲得許可?
編輯:
我現在在另一個帳戶上對其進行了測試,得到了不同的錯誤:
該帳戶已作為測試帳戶添加到開發者控制台的許可中
參考解法
方法 1:
I´ve waited one day and now it magically works. Seems that Google needed some time for progressing.
Edit:
Now it stopped working again with the error "Download failed because the resources could not be found", how funny...
方法 2:
When I use Android 5.0.1 I set targetSdkVersion 19 after then my problem solved.
<uses‑sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
Wehn I use Android 5.0.1 I set targetSdkVersion 21 I have below error.
<uses‑sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
download failed because you may not have purchased this app
LogCat error like this:
12‑28 15:06:34.521: E/AndroidRuntime(14153): FATAL EXCEPTION: main
12‑28 15:06:34.521: E/AndroidRuntime(14153): Process: your_app_package_name, PID: 14153
12‑28 15:06:34.521: E/AndroidRuntime(14153): java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.licensing.ILicensingService }
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1674)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1773)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.app.ContextImpl.bindService(ContextImpl.java:1751)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.content.ContextWrapper.bindService(ContextWrapper.java:538)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at com.google.android.vending.licensing.LicenseChecker.checkAccess(LicenseChecker.java:150)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at com.google.android.vending.expansion.downloader.impl.DownloaderService$LVLRunnable.run(DownloaderService.java:768)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.os.Handler.handleCallback(Handler.java:739)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.os.Handler.dispatchMessage(Handler.java:95)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.os.Looper.loop(Looper.java:135)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at android.app.ActivityThread.main(ActivityThread.java:5221)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at java.lang.reflect.Method.invoke(Native Method)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at java.lang.reflect.Method.invoke(Method.java:372)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
12‑28 15:06:34.521: E/AndroidRuntime(14153): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
方法 3:
Make sure the file size same as expansion file uploaded to the android console,
return new XAPKFile[]{new XAPKFile(
true,//is main?
3,//Version
99695373L)};//File size
And I had the same problem also, but the problem come from here
boolean expansionFilesDelivered() {
for (XAPKFile xf : xAPKS) {
String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false))
return false;
}
return true;
}
It returning false
, so the app can not validated the expansion file even the file is downloaded, so I fixed by adding else
boolean expansionFilesDelivered() {
for (XAPKFile xf : xAPKS) {
String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, true)) {
return false;
}else{
return true;
}
}
return true;
}
and on account setting, setting licensed test response to LICENSED
Hope that can help you :)
(by Marian Klühspies、Marian Klühspies、ethemsulan、ilovebali)