【问题标题】:Maps Android V2: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable地图 Android V2: java.lang.noclassdeffounderror: com.google.android.gms.R$styleable
【发布时间】: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


    【解决方案1】:

    是的,你是对的。您需要导入 google_play_services_lib 并将其作为库添加到您的项目中。

    为此,您需要:

    1. 从 Android SDK 管理器下载Google Play Services

    2. 添加 通过“导入现有的 Android 代码库”将其作为一个项目。去 ~/&lt;android_sdk&gt;/extras/google/google_play_services/libproject 和 将此添加到您的工作区。

    3. 将此项目添加到您的工作区后,右键单击 它,转到“属性”,然后转到“Android”选项卡并将其标记为 图书馆。

    4. 转到您的应用程序,然后右键单击以转到 “属性”并转到“Android”选项卡和库窗格中, 单击“添加库”。这应该向您显示google_play_services 项目。将此添加为对您的项目的引用。

    5. 另一个要求是右键单击您的项目并转到 “Android 工具”选项和“添加支持库...”。

    这应该让地图运行。

    注意:我们必须将 Google Play 服务添加为“现有 Android 代码库”项目,而不是 JAR。

    【讨论】:

    • 我现在得到一个白屏,错误找不到类'maps.af.k',从方法maps.ag.an.a引用,但不知何故我更近了地图无法加载
    猜你喜欢
    • 2013-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多