Android - Deletes R.java file when importing google-play-services-lib

我与影子孤独终老i 提交于 2019-12-20 07:31:31

问题


I am working on a project in which I want to show a Map, for that I want to add google-play-service-lib but when I add it my R.java files gets deleted and not getting regenerated.

I tried adding google-play-service-lib into build path. After adding everything goes ok. But, when I run the project it gives an error says, java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

And when I add it into the project, R.java gets deleted. I tried number of permutations and combinations which I found on google and SO. But there is no feasible solution, which solves my problem.

Please help me out for this..!!

EDIT

<?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>

回答1:


making sure your Google play services is present in same working directory and make this project as a reference to the original project..

 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

Providing the link you can see the importing Google play services

and even check your google play services is up to date by going to sdk manger...



来源:https://stackoverflow.com/questions/21677327/android-deletes-r-java-file-when-importing-google-play-services-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!