[英]Could not find method com.google.android.gms.common.GooglePlayServicesUtil
I know this question had already a lot of answer and fix...But nothing worked for me... 我知道这个问题已经有很多答案和解决方法......但是没有什么对我有用......
I'm trying to add the push notification to my android apps. 我正在尝试将推送通知添加到我的Android应用程序中。 In order to do that, I use the "google-play-services_lib" and the "google-play-services.jar". 为此,我使用“google-play-services_lib”和“google-play-services.jar”。 I followed the tutorial provided by Google Setting Up Google Play Services for Eclipse. 我按照谷歌设置Google Play Services for Eclipse提供的教程。
What I did : 我做了什么 :
Import an Existing Android Code into Workspace (/android-sdks/extras/google/google_play_services/libproject/google-play-services_lib), with the "Copy projects into workspace" checked...Based on what google suggested 将现有的Android代码导入Workspace(/ android-sdks / extras / google / google_play_services / libproject / google-play-services_lib),选中“将项目复制到工作区”...根据谷歌的建议
Note: You should be referencing a copy of the library that you copied to your development workspace—you should not reference the library directly from the Android SDK directory. 注意:您应该引用复制到开发工作区的库的副本 - 不应直接从Android SDK目录引用库。
Referencing the library into my project (Right Click -> Properties -> Android -> Library -> Add -> google-play-services_lib) 将库引用到我的项目中(右键单击 - >属性 - > Android - >库 - >添加 - > google-play-services_lib)
Added a copy of the google-play-services.jar into my projetc libs folder. 在我的projetc libs文件夹中添加了google-play-services.jar的副本。
Adding the jar file to my build path...I had to uncheck the jar files under the Order and export tab to avoid the following error : 将jar文件添加到我的构建路径...我必须取消选中Order and export选项卡下的jar文件以避免以下错误:
[2014-07-14 09:41:56 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/android/gms/internal/a; [2014-07-14 09:41:56 - Dex Loader]无法执行dex:多个dex文件定义Lcom / google / android / gms / internal / a;
[2014-07-14 09:41:56 ] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/android/gms/internal/a; [2014-07-14 09:41:56]转换为Dalvik格式失败:无法执行dex:多个dex文件定义Lcom / google / android / gms / internal / a;
Added the following to my Manifest file : 在我的清单文件中添加了以下内容:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Creating the pro guard exception 创建专业保护例外
-keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); } -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; } -keepnames @com.google.android.gms.common.annotation.KeepName class * -keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; } -keepnames class * implements android.os.Parcelable { public static final ** CREATOR; }
When i try to simply check if the device have the Google Play Service APK with the following 当我尝试简单地检查设备是否具有以下的Google Play服务APK时
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)
I always see this error : 我总是看到这个错误:
Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.example.testpush.MainActivity.onCreate
And : 而且:
07-14 10:34:53.631: E/AndroidRuntime(421): FATAL EXCEPTION: main
07-14 10:34:53.631: E/AndroidRuntime(421): java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil
07-14 10:34:53.631: E/AndroidRuntime(421): at com.example.testpush.MainActivity.onCreate(MainActivity.java:16)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.os.Handler.dispatchMessage(Handler.java:99)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.os.Looper.loop(Looper.java:123)
07-14 10:34:53.631: E/AndroidRuntime(421): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-14 10:34:53.631: E/AndroidRuntime(421): at java.lang.reflect.Method.invokeNative(Native Method)
07-14 10:34:53.631: E/AndroidRuntime(421): at java.lang.reflect.Method.invoke(Method.java:507)
07-14 10:34:53.631: E/AndroidRuntime(421): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-14 10:34:53.631: E/AndroidRuntime(421): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-14 10:34:53.631: E/AndroidRuntime(421): at dalvik.system.NativeStart.main(Native Method)
Am I missing something here???? 我在这里遗漏了什么???? Thanks for any idea. 谢谢你的想法。
I ran into this exact same problem. 我遇到了同样的问题。 Started clean eclipse workspace (using ADT 23.0.3.1327240). 开始清理eclipse工作区(使用ADT 23.0.3.1327240)。 Downloaded the latest Play Services library (v 5.0.89-000) via SDK Manager. 通过SDK Manager下载最新的Play服务库(v 5.0.89-000)。 Followed all correct instructions , ans still got linker problems when app is launched. 遵循所有正确的说明 ,当应用程序启动时仍然会出现链接器问题。
My solution was to use an older version of Play Serices library (luckily still had v4.4.52-000 of the lib in one of my older projects. Download mine here .) Doing a refresh and clean build after importing this older version seems to solve the problem for now. 我的解决方案是使用较旧版本的Play Serices库(幸运的是在我的一个旧项目中仍然使用了v4.4.52-000的lib。 在这里下载我的 。)在导入这个旧版本后进行刷新和清理构建似乎解决了现在的问题。
Hopefully someone will comment on the logged bug and give us a real solution. 希望有人会评论已记录的错误并给我们一个真正的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.