地图Android版V2:java.lang.NoClassDefFoundError的:com.google.android.gms.R $设置样式
由于很多,我得到了以下错误: java.lang.NoClassDefFoundError的:试图执行为Android V2地图时com.google.android.gms.R $设置样式
。
As many I get the following error: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable
when trying to implement Maps for Android V2.
不知怎的,我必须失去了什么,我究竟做错了,因为它不工作。我第一次尝试是对谷歌播放-services.lib复制到lib文件夹,但我看到的地方我不应该这样做。
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_apis - 谷歌-8作为一个项目,但该项目给出了错误进口com.google不能得到解决。
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.
我继 Vogella教程:
活动:
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>
我通过输入通过安装密钥工具插件..的 http://keytool.sourceforge.net/update 指纹; com.testmap.test在谷歌控制台
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.
和XML:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
我有我需要导入谷歌播放服务库的感觉,能有人告诉我一步一步如何在Eclipse中做到这一点,我已经跟着很多答案,但我似乎做的每一次有些不妥。
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_lib
并将其添加为一个库到您的项目。
Yes, you are right. You need to import google_play_services_lib
and add it as a library to your project.
对于这一点,你需要:
-
下载
谷歌播放服务
从Android SDK管理器
Download the
Google Play Services
from the Android SDK manager
添加
这是由导入现有的Android code基的项目。去〜/&LT; android_sdk&GT; /演员/谷歌/ google_play_services / libproject
和
添加到您的工作空间。
Add
this as a project by "Importing existing Android Code Base". Go to
~/<android_sdk>/extras/google/google_play_services/libproject
and
add this to your workspace.
在此项目已被添加到您的工作区中,右键单击
它,进入属性,然后为Android的标签,其标记为
库。
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的标签,并在库窗格中,
单击添加库。这将显示在 google_play_services
项目。这个加为你的项目的引用。
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". This should show you the google_play_services
project. Add this as a reference to your project.
这应该得到的地图上显示。
This should get the Maps running.
请注意:我们必须添加谷歌播放服务作为一个现有的Android code基项目,而不是作为一个JAR。
NOTE: We have to add the Google Play Services as an "Existing Android Code Base" project and not as a JAR.