[英]Maps Android V2: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable
As many I get the following error: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable
when trying to implement Maps for Android V2. 尝试执行Android V2版地图时,我得到了以下错误: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable
。
Somehow I must be missing what I exactly am doing wrong, since it's not working. 由于某种原因,我一定会错过我确切在做错的事情。 What I tried first is to copy the google-play-services.lib into the lib folder, but I saw somewhere I shouldn't do this. 我首先尝试的是将google-play-services.lib复制到lib文件夹中,但是我发现我不应该这样做。
Then I tried to import addon-google_apis-google-8 as a project, but the project gives the error The import com.google cannot be resolved.
然后,我尝试将addon-google_apis-google-8导入为一个项目,但是该项目给出错误The import com.google cannot be resolved.
I'm following the Vogella Tutorial : 我正在关注Vogella教程 :
Activity: 活动:
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
map = fm.getMap();
//map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.btn_logo)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
Manifest: 表现:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.testmap.test.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.testmap.test.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="a_real_api_key" />
</application>
I retrieved a_real_api_key by entering the SHA1 retrieved by installing the keytool plugin.. http://keytool.sourceforge.net/update fingerprint;com.testmap.test in the google console. 我通过输入通过安装检索的检索SHA1 a_real_api_key 密钥工具插件.. http://keytool.sourceforge.net/update com.testmap.test在谷歌控制台;指纹。
And xml: 和xml:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
I have the feeling I need to import the google-play-services library, can somebody tell me step by step how to do this in Eclipse, I've followed many answers, but I seem to do something wrong every time. 我觉得我需要导入google-play-services库,有人可以一步一步告诉我如何在Eclipse中做到这一点,我遵循了很多答案,但每次似乎都做错了。
Yes, you are right. 是的,你是对的。 You need to import google_play_services_lib
and add it as a library to your project. 您需要导入google_play_services_lib
并将其作为库添加到您的项目中。
For this, you need to: 为此,您需要:
Download the Google Play Services
from the Android SDK manager 从Android SDK管理器下载Google Play Services
Add this as a project by "Importing existing Android Code Base". 通过“导入现有的Android代码库”将其添加为项目。 Go to ~/<android_sdk>/extras/google/google_play_services/libproject
and add this to your workspace. 转到~/<android_sdk>/extras/google/google_play_services/libproject
并将其添加到您的工作区中。
Once this project has been added to your workspace, right-click on it, go to "Properties" and then to "Android" tab and mark it as a library. 将该项目添加到工作区后,右键单击它,转到“属性”,然后转到“ Android”选项卡并将其标记为库。
Go to your application, and then right-click to go to the "Properties" and go to the "Android" tab and in the Library pane, click "Add Library". 转到您的应用程序,然后右键单击以转到“属性”,然后转到“ Android”选项卡,然后在“库”窗格中单击“添加库”。 This should show you the google_play_services
project. 这应该向您显示google_play_services
项目。 Add this as a reference to your project. 将此添加为对您的项目的引用。
This should get the Maps running. 这应该使地图运行。
NOTE: We have to add the Google Play Services as an "Existing Android Code Base" project and not as a JAR. 注意:我们必须将Google Play服务添加为“现有Android代码库”项目,而不是JAR。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.