找不到com.google.android.gms.common.GooglePlayServicesUtil方法 [英] 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...
我正在尝试添加推送通知到我的Android应用程序为了做到这一点,我使用google-play-services_lib和google-play-services.jar。我遵循了Google为Google提供的教程设置Google Play服务。
I'm trying to add the push notification to my android apps. In order to do that, I use the "google-play-services_lib" and the "google-play-services.jar". I followed the tutorial provided by Google Setting Up Google Play Services for Eclipse.
我做了什么:
- 使用Eclipse中的SDK Manager安装Google Play服务
-
将现有的Android代码导入Workspace(/ android-sdks / extras / google / google_play_services / libproject / google-play-services_lib),并将将项目复制到工作空间 。基于什么google建议
- Installing the Google play services with the SDK Manager in Eclipse
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 SDK目录。
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 - >图书馆 - >添加 - > google-play-services_lib)
Referencing the library into my project (Right Click -> Properties -> Android -> Library -> Add -> google-play-services_lib)
将google-play-services.jar的副本添加到我的projetc libs folde r。
Added a copy of the google-play-services.jar into my projetc libs folder.
将jar文件添加到我的构建路径...我不得不取消选中订单和导出选项卡下的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 :
[2014-07-14 09:41:56 - Dex Loader]无法执行dex:多个dex文件定义Lcom / google / android / gms / internal / a;
[2014-07-14 09:41:56]转换为Dalvik格式失败:无法执行dex:多个dex文件定义Lcom / google / android / gms /内部/ a;
[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 ] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define 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
GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)
我总是看到这个错误:
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.
推荐答案
我遇到这个完全相同的问题。开始清洁eclipse工作区(使用ADT 23.0.3.1327240)。通过SDK Manager下载最新的Play Services库(v 5.0.89-000)。遵循所有正确的说明,在应用启动时仍然存在链接器问题。
I ran into this exact same problem. Started clean eclipse workspace (using ADT 23.0.3.1327240). Downloaded the latest Play Services library (v 5.0.89-000) via SDK Manager. Followed all correct instructions, ans still got linker problems when app is launched.
我的解决方案是使用旧版本的Play Serices库(幸运的是,我的一个老项目中的lib已经有v4.4.52-000版本了。下载我的这里)。做一个导入此旧版本后,刷新和清理构建似乎解决了现在的问题。
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.
希望有人会对记录错误,并给我们一个真正的解决方案。
Hopefully someone will comment on the logged bug and give us a real solution.
这篇关于找不到com.google.android.gms.common.GooglePlayServicesUtil方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!