0

以下是代码:

AndroidMarketClient client;
        try {
            client = new AndroidMarketClient("myname@gmail.com",
                    "mypassword","androidID" "dd/MM/yyyy", Locale.ENGLISH);

尽管我已将 androidmarketapi-0.6.jar 添加到项目路径中,但它会因以下异常而崩溃。

04-11 23:03:25.455: D/dalvikvm(32628): Late-enabling CheckJNI
04-11 23:03:25.755: D/dalvikvm(32628): GC_FOR_ALLOC freed 66K, 7% free 12801K/13663K, paused 26ms
04-11 23:03:25.805: I/dalvikvm-heap(32628): Grow heap (frag case) to 15.741MB for 3288496-byte allocation
04-11 23:03:25.845: D/dalvikvm(32628): GC_FOR_ALLOC freed 3K, 6% free 16009K/16931K, paused 22ms
04-11 23:03:25.885: D/dalvikvm(32628): GC_CONCURRENT freed <1K, 6% free 16009K/16931K, paused 1ms+5ms
04-11 23:03:25.945: E/dalvikvm(32628): Could not find class 'com.gc.android.market.api.MarketSession', referenced from method androidmarketclient.AndroidMarketClient.<init>
04-11 23:03:25.945: W/dalvikvm(32628): VFY: unable to resolve new-instance 26 (Lcom/gc/android/market/api/MarketSession;) in Landroidmarketclient/AndroidMarketClient;
04-11 23:03:25.945: D/dalvikvm(32628): VFY: replacing opcode 0x22 at 0x0003
04-11 23:03:25.945: I/dalvikvm(32628): Could not find method com.gc.android.market.api.MarketSession.getContext, referenced from method androidmarketclient.AndroidMarketClient.getAndroidId
04-11 23:03:25.945: W/dalvikvm(32628): VFY: unable to resolve virtual method 78: Lcom/gc/android/market/api/MarketSession;.getContext ()Lcom/gc/android/market/api/model/Market$RequestContext$Builder;
04-11 23:03:25.945: D/dalvikvm(32628): VFY: replacing opcode 0x6e at 0x0002
04-11 23:03:25.945: I/dalvikvm(32628): Could not find method com.gc.android.market.api.model.Market$AppsRequest.newBuilder, referenced from method androidmarketclient.AndroidMarketClient.requestApps
04-11 23:03:25.945: W/dalvikvm(32628): VFY: unable to resolve static method 86: Lcom/gc/android/market/api/model/Market$AppsRequest;.newBuilder ()Lcom/gc/android/market/api/model/Market$AppsRequest$Builder;
04-11 23:03:25.945: D/dalvikvm(32628): VFY: replacing opcode 0x71 at 0x0001
04-11 23:03:25.945: I/dalvikvm(32628): Could not find method com.gc.android.market.api.model.Market$CommentsRequest.newBuilder, referenced from method androidmarketclient.AndroidMarketClient.requestComments
04-11 23:03:25.945: W/dalvikvm(32628): VFY: unable to resolve static method 97: Lcom/gc/android/market/api/model/Market$CommentsRequest;.newBuilder ()Lcom/gc/android/market/api/model/Market$CommentsRequest$Builder;
04-11 23:03:25.945: D/dalvikvm(32628): VFY: replacing opcode 0x71 at 0x0001
04-11 23:03:25.945: E/dalvikvm(32628): Could not find class 'com.gc.android.market.api.model.Market$Comment', referenced from method androidmarketclient.AndroidMarketClient.requestReviews
04-11 23:03:25.945: W/dalvikvm(32628): VFY: unable to resolve check-cast 30 (Lcom/gc/android/market/api/model/Market$Comment;) in Landroidmarketclient/AndroidMarketClient;
04-11 23:03:25.945: D/dalvikvm(32628): VFY: replacing opcode 0x1f at 0x001e
 04-11 23:03:25.945: D/dalvikvm(32628): DexOpt: unable to opt direct call 0x004a at 0x05 in Landroidmarketclient/AndroidMarketClient;.<init>
04-11 23:03:25.945: I/dalvikvm(32628): Failed resolving Landroidmarketclient/AndroidMarketClient$2; interface 25 'Lcom/gc/android/market/api/MarketSession$Callback;'
04-11 23:03:25.945: W/dalvikvm(32628): Link of class 'Landroidmarketclient/AndroidMarketClient$2;' failed
04-11 23:03:25.945: D/dalvikvm(32628): DexOpt: unable to opt direct call 0x0021 at 0x21 in Landroidmarketclient/AndroidMarketClient;.requestApps
04-11 23:03:25.945: I/dalvikvm(32628): Failed resolving Landroidmarketclient/AndroidMarketClient$1; interface 25 'Lcom/gc/android/market/api/MarketSession$Callback;'
 04-11 23:03:25.945: W/dalvikvm(32628): Link of class 'Landroidmarketclient/AndroidMarketClient$1;' failed
04-11 23:03:25.945: D/dalvikvm(32628): DexOpt: unable to opt direct call 0x001e at 0x1c in Landroidmarketclient/AndroidMarketClient;.requestComments

04-11 23:03:25.955: D/AndroidRuntime(32628): Shutting down VM
04-11 23:03:25.955: W/dalvikvm(32628): threadid=1: thread exiting with uncaught  exception (group=0x40ac0210)
04-11 23:03:25.965: E/AndroidRuntime(32628): FATAL EXCEPTION: main
04-11 23:03:25.965: E/AndroidRuntime(32628): java.lang.NoClassDefFoundError: com.gc.android.market.api.MarketSession
04-11 23:03:25.965: E/AndroidRuntime(32628):    at androidmarketclient.AndroidMarketClient.<init>(AndroidMarketClient.java:65)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at androidmarketclient.AndroidMarketClient.<init>(AndroidMarketClient.java:121)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at com.nykkos.dailydeals.DealsActivity.onCreate(DealsActivity.java:54)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.Activity.performCreate(Activity.java:4465)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.os.Looper.loop(Looper.java:137)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at android.app.ActivityThread.main(ActivityThread.java:4441)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at java.lang.reflect.Method.invokeNative(Native Method)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at java.lang.reflect.Method.invoke(Method.java:511)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
04-11 23:03:25.965: E/AndroidRuntime(32628):    at dalvik.system.NativeStart.main(Native Method)

我不明白为什么上面的代码会崩溃。相同的代码可以工作,对于单独的 java 项目来说非常好。

虽然我在路径中添加了 jar,但我不知道为什么它仍然显示

Could not find class 'com.gc.android.market.api.MarketSession'

解决问题的任何帮助表示赞赏。

4

1 回答 1

1

如果它是 jar,请将其添加到您的 libs 文件夹中。如果它是一个 android 项目,请将其添加为项目。如果这些都不起作用,请检查您的 project.properties 文件并确保它确实添加了引用(我今天浪费了一个小时,因为 Eclipse 实际上并没有更新该文件)。

于 2013-04-12T06:22:38.727 回答