解决方案找到---检查底部
我知道有很多类似于我的问题,但我已经在这方面工作了好几天,无法弄清楚如何让这个工作。
我正在尝试将Google Play服务整合到我的应用程序中以使用推送通知。
这是我到目前为止所做的:
在我的project.properties
中添加了以下代码proguard.config = $ {sdk.dir} /tools/proguard/proguard-android.txt:proguard-project.txt
目标=机器人-20 android.library.reference.1 = .. \ appcompat_v7 android.library =真 android.library.reference.2 = .. \谷歌播放-services_lib
将以下代码添加到MainActivity.java的onCreate函数中:
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); if(status == ConnectionResult.SUCCESS){ Log.v("播放""购!!!!&#34); } 其他{ ((Dialog)GooglePlayServicesUtil.getErrorDialog(status,this,10))。show(); }
当我运行我的程序时,我得到了
10-06 19:23:40.733: I/dalvikvm(16563): Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.example.gcm_test.MainActivity.onCreate
10-06 19:23:40.733: W/dalvikvm(16563): VFY: unable to resolve static method 9321: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
10-06 19:23:40.733: D/dalvikvm(16563): VFY: replacing opcode 0x71 at 0x0014
10-06 19:23:40.823: V/Play(16563): LOG
10-06 19:23:40.823: D/AndroidRuntime(16563): Shutting down VM
10-06 19:23:40.823: W/dalvikvm(16563): threadid=1: thread exiting with uncaught exception (group=0x41786898)
10-06 19:23:40.823: E/AndroidRuntime(16563): FATAL EXCEPTION: main
10-06 19:23:40.823: E/AndroidRuntime(16563): java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil
10-06 19:23:40.823: E/AndroidRuntime(16563): at com.example.gcm_test.MainActivity.onCreate(MainActivity.java:21)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.Activity.performCreate(Activity.java:5372)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.ActivityThread.access$700(ActivityThread.java:165)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.os.Handler.dispatchMessage(Handler.java:99)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.os.Looper.loop(Looper.java:137)
10-06 19:23:40.823: E/AndroidRuntime(16563): at android.app.ActivityThread.main(ActivityThread.java:5455)
10-06 19:23:40.823: E/AndroidRuntime(16563): at java.lang.reflect.Method.invokeNative(Native Method)
10-06 19:23:40.823: E/AndroidRuntime(16563): at java.lang.reflect.Method.invoke(Method.java:525)
10-06 19:23:40.823: E/AndroidRuntime(16563): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
10-06 19:23:40.823: E/AndroidRuntime(16563): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
10-06 19:23:40.823: E/AndroidRuntime(16563): at dalvik.system.NativeStart.main(Native Method)
10-06 19:28:41.224: I/Process(16563): Sending signal. PID: 16563 SIG: 9
任何帮助将不胜感激!
更新:
我进入appcompat_v7 libs文件夹并右键单击每个.jar文件并单击"添加到构建"我也进入了"订单和出口"对于这个项目并选择了两个jar文件并取消选择" Android Dependencies"。
我为google-play-services_lib项目做了同样的事情。
我收到这些错误消息:
10-06 22:13:08.303: I/dalvikvm(24857): Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.example.gcm_tester2.MainActivity.onCreate
10-06 22:13:08.303: W/dalvikvm(24857): VFY: unable to resolve static method 9321: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
10-06 22:13:08.303: D/dalvikvm(24857): VFY: replacing opcode 0x71 at 0x000d
10-06 22:13:08.434: D/AndroidRuntime(24857): Shutting down VM
10-06 22:13:08.434: W/dalvikvm(24857): threadid=1: thread exiting with uncaught exception (group=0x41786898)
10-06 22:13:08.434: E/AndroidRuntime(24857): FATAL EXCEPTION: main
10-06 22:13:08.434: E/AndroidRuntime(24857): java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil
10-06 22:13:08.434: E/AndroidRuntime(24857): at com.example.gcm_tester2.MainActivity.onCreate(MainActivity.java:21)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.Activity.performCreate(Activity.java:5372)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.ActivityThread.access$700(ActivityThread.java:165)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.os.Handler.dispatchMessage(Handler.java:99)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.os.Looper.loop(Looper.java:137)
10-06 22:13:08.434: E/AndroidRuntime(24857): at android.app.ActivityThread.main(ActivityThread.java:5455)
10-06 22:13:08.434: E/AndroidRuntime(24857): at java.lang.reflect.Method.invokeNative(Native Method)
10-06 22:13:08.434: E/AndroidRuntime(24857): at java.lang.reflect.Method.invoke(Method.java:525)
10-06 22:13:08.434: E/AndroidRuntime(24857): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
10-06 22:13:08.434: E/AndroidRuntime(24857): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
10-06 22:13:08.434: E/AndroidRuntime(24857): at dalvik.system.NativeStart.main(Native Method)
更新2:
任何人都可以为我提供一个打印屏幕,显示你的pacakge资源管理器在你正确执行时的样子。就像在引用的库,android依赖项等下应该是什么一样。我在这一点上变得非常沮丧
更新3:
经过几天的研究后,我意识到问题是我需要更新我的" Android SDK构建工具"。 OMG I GOT IT WORKING。
答案 0 :(得分:0)
您需要添加库jar来构建路径;
您在eclipse中添加appcompat_v7支持库时缺少一些步骤。这被视为包含资源的库please follow instructions under Eclipse here