【发布时间】:2013-08-20 00:21:36
【问题描述】:
我收到以下错误:java.lang.noclassdeffounderror: com.google.android.gms.R$styleable 在尝试为 Android V2 实施地图时。
不知何故,我一定错过了我到底做错了什么,因为它不起作用。我首先尝试的是将 google-play-services.lib 复制到 lib 文件夹中,但我看到了不应该这样做的地方。
然后我尝试将 addon-google_apis-google-8 作为项目导入,但是项目给出了错误The import com.google cannot be resolved.
我在关注Vogella Tutorial:
活动:
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);
清单:
<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>
我通过输入通过在 google 控制台中安装 keytool 插件检索到的 SHA1 检索到 a_real_api_key.. http://keytool.sourceforge.net/updatefingerprint;com.testmap.test。
还有xml:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
我觉得我需要导入 google-play-services 库,有人可以逐步告诉我如何在 Eclipse 中执行此操作,我已经遵循了很多答案,但我似乎每次都做错了什么。
【问题讨论】:
标签: android maps noclassdeffounderror supportmapfragment mapfragment