【发布时间】:2016-06-07 18:09:36
【问题描述】:
我是 Android 开发的新手。我正在使用 Eclipse 进行开发。现在我正在尝试在我的应用程序中集成谷歌地图 v2。但是我收到一个错误 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/R$styleable;。我已经使用以下步骤集成了它,
在https://console.developers.google.com/ 中创建新项目并启用谷歌地图并使用SHA1 指纹生成新的android api 密钥。
从
C:\Adt-bundle\sdk\extras\google\google_play_services\libproject\google-play-services_lib导入的google-play-services_lib项目已将
google-play-services_lib库项目添加到我的应用程序中。Added Permissions
ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE, INTERNET, ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, WRITE_EXTERNAL_STORAGE在我的清单中还添加了使用我的应用程序包名称进行映射的权限,
**
<permission android:name="myPackageName.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="myPackageName.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
**
-
在清单上添加了 api 密钥,
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="--myapikey--" />
当我在布局文件中添加 MapFragment 片段布局时,我收到一个错误 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/R$styleable; 这是我添加的 MapFragment 片段
> <fragment
> android:id="@+id/map"
> android:name="com.google.android.gms.maps.MapFragment"
> android:layout_width="match_parent"
> android:layout_height="match_parent" />
【问题讨论】:
-
你在用proguard吗?
-
我已将 MapFragment 更改为 SupportMapFragment。然后我得到 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.shidhi.offerzone/com.shidhi.xxxxxx.HomeScreen}: android.view.InflateException: Binary XML file line #29: Error inflating class fragment
标签: android eclipse google-maps