其他分享
首页 > 其他分享> > android – 包括Google Play Downloader Library | APK文件扩展库

android – 包括Google Play Downloader Library | APK文件扩展库

作者:互联网

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

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

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

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

我已在我的主项目属性中导入了Java构建路径中的项目导入库(如a)部分:
(也在下载库中导入了许可证库)

我也尝试过只导入罐子里的b)
(安装时没有错误)

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

因此,jar输入似乎是最好的,在编译和安装时没有错误,但是当我正在调用库中的方法和类时,我还有其他错误:

2 – 在应用程序中:

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

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中崩溃了:

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时发生此崩溃.

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

我的主要应用是Google API 8(Android 2.2)

我已经搜索了很多东西,以使这个工作,但..现在我完全没有想法!

如果有人知道如何让这种工作非常友好:p

抱歉这篇长篇文章,对不起我的英文,如果我犯错误拼写,那是因为我是法国人:p

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

[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中的“Referenced Library”下看到它们.

我也写了清单:

<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

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

< uses-library>标签不适用于第三方内容,仅适用于设备上已安装的现有库.像地图,它安装在每个官方的Android设备上(亚马逊Kindle不是官方的Android设备,仅作为一个例子).

我也不确定您是否已将库项目添加到项目中并同时链接罐子.这也可能会带来麻烦.

标签:android,eclipse,apk,expansion
来源: https://codeday.me/bug/20190630/1334102.html