包括 Google Play 下载器库 |APK 文件扩展库 [英] Including Google Play Downloader Library | APK File Expansion Library

查看:28
本文介绍了包括 Google Play 下载器库 |APK 文件扩展库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 http://developer.android.com 上的开发指南/guide/market/expansion-files.html 以便将其他资产下载到我的 apk.

I'm following dev guide at http://developer.android.com/guide/market/expansion-files.html in order to download additional assets to my apk.

我已经完成了有关导入库等的所有部分.我还在我的主程序中实现了示例代码(为了检测扩展文件是否已经下载,如果我们需要下载它们并启动下载等..)

I've done all the part about the importation of libraries, etc .. I've also implemented the samples code in my main program (in order to detect if expansion files are already downloaded, if we need to download them and launch the download, etc ..)

我在 eclipse 中没有错误,但是当我启动应用程序并开始从库中调用方法和类时,我遇到了各种崩溃:

I have no errors in eclipse, but when I launch the app and starting to call the methods and classes from the library, I have various crashes:

1 - 首先,在安装时,adb 说找不到库.. :

[2012-04-17 22:50:13 - MyApp] adb is running normally.
[2012-04-17 22:50:13 - MyApp] Performing com.gmla.MyApp activity launch
[2012-04-17 22:50:16 - MyApp] Uploading MyApp.apk onto device 'SH16PV801048'
[2012-04-17 22:50:16 - MyApp] Installing MyApp.apk...
[2012-04-17 22:50:22 - MyApp] Success!
[2012-04-17 22:50:22 - Google Play Downloader Library] Could not find Google Play Downloader Library.apk!
[2012-04-17 22:50:22 - Google Play License Library] Could not find Google Play License Library.apk!

这是我尝试导入库的屏幕截图:http://floy.fr/perso/floy/expfiles/4.PNG

Here is a screenshot of how I have tried to import my libraries: http://floy.fr/perso/floy/expfiles/4.PNG

我已经在 J​​ava 构建路径中导入了带有项目导入的库,如部分 a),在我的主要项目属性中:(下载库中的license库也是这样导入的)

I have imported the libraries with project import in the Java Build Path like part a), in my main project properties: (imported the licence library in the download library that way too)

我也尝试只导入 b) 部分中的 jar(安装时没有错误)

I've also tried to import only the jars like in part b) (no error at installation with this one)

c)部分的Android库导入(这似乎是开发指南中推荐的,但我有编译错误,eclipse没有找到一些参考我无法构建项目):

and with the Android Library import like in part c) (It seems to be the one recommended in the dev guide, but I have compilation errors with this one, eclipse don't find some references and i can't build the project):

因此,jar 导入似乎是最好的,在编译和安装时没有错误,但是之后我在调用库中的方法和类时出现了其他错误:

So, the jar importation seems to be the best, no errors at compilation and installation, but I have other errors after, when I'm making a call to the methodes and classes from the library:

2 - 在应用中:

当我尝试使用帮助程序以使用此方法检查 XAPKFiles 的存在时:

When i'm trying to use the helper in order to check the presence of the XAPKFiles with this method :

boolean expansionFilesDelivered() {

        XAPKFile[] xAPKS = {new XAPKFile(true, 3, 687801613L)
        // main file only
        };

        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;
    } 

我在 DDMS 中崩溃了:

I have this crash in DDMS:

04-17 23:14:24.614: I/dalvikvm(23201): Could not find method com.google.android.vending.expansion.downloader.Helpers.getExpansionAPKFileName, referenced from method com.gmla.guideaudio.apkexp.GmlaCheckExpFiles.expansionFilesDelivered
04-17 23:14:24.614: W/dalvikvm(23201): VFY: unable to resolve static method 1295: Lcom/google/android/vending/expansion/downloader/Helpers;.getExpansionAPKFileName (Landroid/content/Context;ZI)Ljava/lang/String;
04-17 23:14:24.614: D/dalvikvm(23201): VFY: replacing opcode 0x71 at 0x001b
04-17 23:14:24.614: W/dalvikvm(23201): Unable to resolve superclass of Lcom/gmla/guideaudio/apkexp/GmlaDownloaderService; (250)
04-17 23:14:24.614: W/dalvikvm(23201): Link of class 'Lcom/gmla/guideaudio/apkexp/GmlaDownloaderService;' failed
04-17 23:14:24.614: E/dalvikvm(23201): Could not find class 'com.gmla.guideaudio.apkexp.GmlaDownloaderService', referenced from method com.gmla.guideaudio.apkexp.GmlaCheckExpFiles.onCreate
04-17 23:14:24.614: W/dalvikvm(23201): VFY: unable to resolve const-class 135 (Lcom/gmla/guideaudio/apkexp/GmlaDownloaderService;) in Lcom/gmla/guideaudio/apkexp/GmlaCheckExpFiles;
04-17 23:14:24.614: D/dalvikvm(23201): VFY: replacing opcode 0x1c at 0x001c
04-17 23:14:24.624: V/Performance(23201): >>com.gmla.guideaudio.apkexp.GmlaCheckExpFiles@40db32b0 onCreate
04-17 23:14:24.624: D/AndroidRuntime(23201): Shutting down VM
04-17 23:14:24.624: W/dalvikvm(23201): threadid=1: thread exiting with uncaught exception (group=0x40abf228)
04-17 23:14:24.624: E/AndroidRuntime(23201): FATAL EXCEPTION: main
04-17 23:14:24.624: E/AndroidRuntime(23201): java.lang.NoClassDefFoundError: com.google.android.vending.expansion.downloader.Helpers
04-17 23:14:24.624: E/AndroidRuntime(23201):    at com.gmla.guideaudio.apkexp.GmlaCheckExpFiles.expansionFilesDelivered(GmlaCheckExpFiles.java:64)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at com.gmla.guideaudio.apkexp.GmlaCheckExpFiles.onCreate(GmlaCheckExpFiles.java:22)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.Activity.performCreate(Activity.java:4524)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2115)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2189)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.os.Looper.loop(Looper.java:154)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at android.app.ActivityThread.main(ActivityThread.java:4894)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at java.lang.reflect.Method.invokeNative(Native Method)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at java.lang.reflect.Method.invoke(Method.java:511)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-17 23:14:24.624: E/AndroidRuntime(23201):    at dalvik.system.NativeStart.main(Native Method)

当我在导入库时使用方法 1 或 2 时会发生这种崩溃.

This crash happen when i'm using the method 1 or 2 when i'm importing the libraries.

我尝试将 ant 更新到最新的 1.8.3,因为我读到 1.7.1 可能在库导入方面存在一些问题......但没有成功解决我的问题.

I have tried to update ant to latest 1.8.3 because I read that 1.7.1 could have some issues with library imports .. with no success on resolving my problems .

我的主要应用程序在 Google API 8 (Android 2.2) 上

My main application is on Google API 8 (Android 2.2)

我已经搜索了很多东西才能使它起作用,但是..现在我完全没有想法了!

I have searched a lot of things in order to make this to work but .. now i'm completely out of ideas !

如果有人知道如何让它工作,那就太好了:p

If someone knows how to get this working that would be very kind :p

抱歉这篇长文章,抱歉我的英语,如果我拼错了,那是因为我是法国人:p

Sorry for this long post and sorry for my english, if i made misspelling mistakes, that's because i'm french :p

我已经尝试过下载器示例代码,使用库导入方法c),这次我没有编译错误,但是在安装过程中:>

I have tried the downloader sample code, with the library import method c), I have no compilation errors this time, but during the installation :

[2012-04-18 01:56:16 - GuideAudio] Android Launch!
[2012-04-18 01:56:16 - GuideAudio] adb is running normally.
[2012-04-18 01:56:16 - GuideAudio] Performing com.gmla.guideaudio.GuideAudio activity launch
[2012-04-18 01:56:19 - GuideAudio] Uploading GuideAudio.apk onto device 'SH16PV801048'
[2012-04-18 01:56:19 - GuideAudio] Installing GuideAudio.apk...
[2012-04-18 01:56:21 - GuideAudio] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2012-04-18 01:56:21 - GuideAudio] Please check logcat output for more details.
[2012-04-18 01:56:21 - GuideAudio] Launch canceled!

我不明白,因为图书馆似乎很好地导入了......我可以在 Eclipse 的参考库"下看到它们.

I don't understand because the library seems to be well imported ... I can see them under "Referenced Library" in Eclipse.

我也在清单上写过:

<uses-library android:name="com.google.android.vending.expansion.downloader" />
         <uses-library android:name="com.google.android.vending.licensing" />

推荐答案

答案可能在这个对类似问题的回答中:https://stackoverflow.com/a/10109546/180538

The answer might be in this answer to a similar question: https://stackoverflow.com/a/10109546/180538

两天前我也遇到了这个问题,答案解决了.特别是阅读最后一段.

I had this issue two days ago, too, and the answer solved it. Especially read the last paragraph.

标签不打算用于第三方的东西,仅用于设备上安装的现有库.就像地图一样,它安装在每个官方的安卓设备上(亚马逊 Kindle 不是官方的安卓设备,仅作为示例).

The <uses-library> tags are not meant to be used for third party stuff, only for already existing libraries installed on the devices. Like Maps, which is installed on each official android device (Amazon Kindle is not an official android device, just as an example).

我也不确定您是否已将库项目添加到项目同时链接了 jar.这也可能会造成麻烦.

I am also not sure if you have added your library projects to your project and linking the jars at the same time. That might also cause trouble.

这篇关于包括 Google Play 下载器库 |APK 文件扩展库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆