问题
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 ..)
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 - First, at the installation, adb says that the libraries couldn't be found.. :
[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!
Here is a screenshot of how I have tried to import my libraries: http://floy.fr/perso/floy/expfiles/4.PNG
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)
I've also tried to import only the jars like in part b) (no error at installation with this one)
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):
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 - In the app :
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;
}
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)
This crash happen when i'm using the method 1 or 2 when i'm importing the libraries.
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 .
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 !
If someone knows how to get this working that would be very kind :p
Sorry for this long post and sorry for my english, if i made misspelling mistakes, that's because i'm french :p
EDIT: 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!
I don't understand because the library seems to be well imported ... I can see them under "Referenced Library" in Eclipse.
I've also write on the manifest :
<uses-library android:name="com.google.android.vending.expansion.downloader" />
<uses-library android:name="com.google.android.vending.licensing" />
回答1:
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.
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).
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.
回答2:
For People who are reading this, The right method to use to import the Expansion Library is the one i referred as c) in my first post.
Take care of your path length when you are importing project library in your main project. My path was too long due to my Android SDK installation folder which was not on the same drive as my workspace. The library import may fail because of that. ( took me one day to realize .. -_- )
回答3:
I think the real issue here is the one described in this answer: Eclipse is not able to resolve path names if the included library project and the referencing project are in different drives. E.g. Library in C: and Referencing project in D:
来源:https://stackoverflow.com/questions/10199590/including-google-play-downloader-library-apk-file-expansion-library