【问题标题】:Android - Deletes R.java file when importing google-play-services-libAndroid - 导入 google-play-services-lib 时删除 R.java 文件
【发布时间】:2014-02-10 12:31:27
【问题描述】:

我正在做一个项目,我想在其中显示一个地图,为此我想添加 google-play-service-lib,但是当我添加它时,我的 R.java 文件被删除并且没有重新生成。

我尝试将google-play-service-lib 添加到构建路径中。添加后一切正常。但是,当我运行该项目时,它给出了一个错误提示,java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

当我将它添加到项目中时,R.java 被删除。我尝试了在googleSO 上找到的排列和组合的数量。但是没有可行的方案,解决了我的问题。

请帮帮我..!!

编辑

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<fragment
 android:id="@+id/map_gle"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

【问题讨论】:

  • 你看过“问题”中产生的错误吗?
  • 是的,我什么都试过了。并且还清理了项目 50 次.. 仍然无法正常工作.. :(
  • Problems 中报告的错误是什么?
  • 当我导入 google_library 时,它删除了 R.java,当我删除库时它显示错误,例如缺少 com.google.gms......
  • 您可以发布清单的内容吗?

标签: android google-maps google-maps-api-2


【解决方案1】:

确保您的 Google Play 服务存在于同一工作目录中,并将此项目作为对原始项目的引用..

 Ensure you have the latest version (v2) of the Google Play Services installed.

Select Window > Android SDK Manager or run android at the command line.
Scroll to the bottom of the package list and select Extras > Google Play services. The Google Play services SDK is downloaded to your computer and installed in your Android SDK environment at <android-sdk-folder>/extras/google/google_play_services/

Add the Google Play Services project into your Eclipse workspace.

Click File -> Import..., select Android -> Existing Android Code into Workspace
Browse to and select <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib

To add the dependency to Google Play Services into your project

Project -> Properties -> Android -> Library, Add -> google-play-services_lib

提供link可以看到正在导入的Google play服务

甚至可以通过 sdk 管理器检查您的 google play 服务是否是最新的...

【讨论】:

  • 它已更新..我的 R.java 丢失了,我该如何运行项目并发布 logcat?
  • 我已经发布了。请检查
  • 我面临同样的问题.. 错误是:- LocationClient 无法解决.. 当我单击文件 -> 导入...时,选择 Android -> 现有 Android 代码进入工作区 浏览并选择 /extras/google/google_play_services/libproject/google-play-services_lib 它没有更新我的 GooglePlayServiceLib 我该怎么办????
  • 您是否添加了与我所说的相同的内容,甚至是您按照我提供的链接进行的操作...,这可能是 Google Play 服务的问题没有正确添加...
  • 您需要更新 Google Play Service SDK,然后使用更新后的库。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-09-29
  • 2014-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多