谷歌地图在安卓手机上能够正常使用,但我仍然收到一个错误提示:“Could not find class 'maps.i.k', referenced from method maps.z.ag.a”。

15
我通过下载库文件,将其添加到工作区,并将其作为库引用,成功地在我的Android应用程序中使用了Google Maps Android API v2。但是,一旦包含地图片段的活动开始,我仍然会收到以下错误提示:
Could not find class 'maps.i.k', referenced from method maps.z.ag.a

顺便提一下,我正在使用支持地图片段

这个错误似乎对我没有任何影响,也不会崩溃应用程序或其他什么,我需要去修复它吗?

已添加清单文件 P.S E_SelectJourney 是我显示和使用地图的地方

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.HelloMap.AndroidApp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <permission
        android:name="com.HelloMap.AndroidApp.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.HelloMap.AndroidApp.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <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_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <application
        android:allowBackup="true"
        android:configChanges="orientation"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.Sherlock" >
        <uses-library
            android:name="com.google.android.maps"
            android:required="true" />

        <activity
            android:name="com.HelloMap.AndroidApp.A_SplashScreen"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.B_TourSlides"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.C_RegisterLogin"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity android:name="com.facebook.LoginActivity" />
        <activity
            android:name="com.HelloMap.AndroidApp.D_RegistrationPage"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.E_SelectJourney"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.F_EnterFromToAddress"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.G_PickDateTime"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.H_ConfirmContact"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.I_MobileVerification"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.J_AvailableTaxis"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.K_SpecialRequirements"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.L_JourneyOverview"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.M_PaymentOptions"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.HelloMap.AndroidApp.N_Confirmation"
            android:configChanges="orientation"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBoWsWNaUTWyHxGuJuNehzfbNvyTv1zIeA" />
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="141236504136755" />
    </application>

</manifest>

添加了logcat

03-26 16:57:14.897: W/dalvikvm(27771): Unable to resolve superclass of Lmaps/p/s; (427)
03-26 16:57:14.897: W/dalvikvm(27771): Link of class 'Lmaps/p/s;' failed
03-26 16:57:14.897: W/dalvikvm(27771): Unable to resolve superclass of Lmaps/y/bo; (3820)
03-26 16:57:14.897: W/dalvikvm(27771): Link of class 'Lmaps/y/bo;' failed
03-26 16:57:14.897: W/dalvikvm(27771): Unable to resolve superclass of Lmaps/i/k; (4208)
03-26 16:57:14.897: W/dalvikvm(27771): Link of class 'Lmaps/i/k;' failed
03-26 16:57:14.897: E/dalvikvm(27771): Could not find class 'maps.i.k', referenced from method maps.z.ag.a
03-26 16:57:14.897: W/dalvikvm(27771): VFY: unable to resolve new-instance 3540 (Lmaps/i/k;) in Lmaps/z/ag;
03-26 16:57:15.567: W/SchedPolicy(27771): add_tid_to_cgroup failed to write '' (Invalid argument); background=0

一样!你解决了这个问题吗? - Stéphane Bruckert
不好意思,我还是遇到了完全相同的错误,但是应用程序总是正常工作。 - Mohamed Heiba
1
这个有帮助吗?https://dev59.com/4eo6XIcBkEYKwwoYOR0q - jermel
@jermel 我都跟着做了,但还是不知道我的问题在哪里。 - Mohamed Heiba
你在应用程序中启用了Proguard吗? - ilango j
不是同一个问题,但可能相关:我在控制台中看到与地图相关的资源错误,但一切似乎都正常工作。https://dev59.com/-GMl5IYBdhLWcg3w3aA- - Kristopher Johnson
6个回答

13

移除此代码:

 <uses-library
        android:name="com.google.android.maps"
        android:required="true" />

首先,Google Map API V2 不需要这个。

接下来,请尝试将此代码移动到关闭的 application 标记之前:

 <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBoWsWNaUTWyHxGuJuNehzfbNvyTv1zIeA" />

就像这样:

 <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBoWsWNaUTWyHxGuJuNehzfbNvyTv1zIeA" />
</application>

最后,请确保您已在 Google API 控制台 中启用了 正确的API服务

enter image description here

您可以从我撰写的这两篇博客文章中获取有关这两个主题的更多信息:

谷歌地图API V2

和:

谷歌地图API V2密钥

更新:

有关许可证的检查,请查看此链接:

http://android-er.blogspot.co.il/2012/12/include-open-source-software-license.html

基本上,在应用程序的某个位置,无论是活动还是对话框,您都必须运行以下内容:

String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());

并以某种方式呈现结果。


按照您的建议尝试了所有方法,但仍然遇到相同的错误,将把它们添加到问题中。 - Mohamed Heiba
我记得我做过类似的事情,但是我该如何/在哪里检查? - Mohamed Heiba
谁知道呢,也许就是那样。 - Emil Adz
@EmilAdz,我也遇到了同样的错误,而且我已经按照你在这里写的所有步骤执行了,但是我还是无法看到地图。我的最低API版本是8,目标API版本是16。 - Chintan Khetiya
@chintankhetiya,请打开另一个问题并在此处发布链接,我会尽力帮助您。请查看我在此处发布的Google Maps指南文章,并确保在发布问题之前完成所有步骤。 - Emil Adz
显示剩余2条评论

2

我不确定,但另一个问题中包含了相同的错误,而在那种情况下,应用程序未正确签名。如果这是问题所在,您需要在专业部署应用程序之前修复它,因为它只能在调试模式下工作。

https://stackoverflow.com/a/15465572/1873970


我已经为我的应用程序签名了调试和发布密钥,我在调试模式下遇到了这个错误,因此现在让我们暂时不考虑发布模式,请查看我的清单并告诉我是否有任何问题。 - Mohamed Heiba

2

我按照指南操作了,但仍然找不到问题,请查看我的清单并告诉我是否有做错的地方。 - Mohamed Heiba
嗯...清单看起来不错。我认为你的哈希密钥有些问题,尝试使用openssl进行sha-1加密。下载openssl-0.9.8e_X64(openssl-0.9.8k_X64无法给出正确的哈希值)。类似于这样:"C:\Program Files (x86)\Java\jdk1.7.0_07\bin\keytool" -exportcert -alias atif -keystore "H:\Android\All Aliases\Get Inspired\Get Inspired" | "C:\O pesnSSL\bin\openssl" sha1 -binary | "C:\OpesnSSL\bin\openssl" base64 - Atif Farrukh
顺便提一下,出于隐私原因,我在这个问题中故意更改了API密钥,但我会尝试你说的方法。 - Mohamed Heiba
哦,等一下,我不记得在谷歌上使用openssl了,只是在Facebook API中使用过它。 - Mohamed Heiba
是的,我不知道为什么要使用你在评论中给我的命令。 - Mohamed Heiba
由于隐私原因,我已经故意更改了此问题中的 API 密钥。请仅返回翻译后的文本。 - Mohamed Heiba

2

您不必担心那些Dalvik警告。我相信这些警告出现是因为Google Maps库编译到了比您手机运行的API级别更高的级别。一些只在更高API级别上可用的类在您的手机上不可用,但库必须已经有一些代码来补偿此差异。


非常正确,我正在Android Froyo API 8上运行它。 - Mohamed Heiba

1

我终于做到了!如果你正在使用SupportFragmentMap,我认为你应该在api控制台上打开google maps android v2,因为我一开始使用的是Google Maps v2并且在FragmentMap上运行良好,但当我改用SupportFragmentMap以包括froyo和gingerbread兼容性时,它就无法运行了。我花了四个充满压力的小时在搜索、尝试、编码、更改密钥、库、更新……后来我只是打开了Google Android Maps v2并关闭了Google Maps v2,现在它正常运行!非常感谢。


0
<uses-library android:name="com.google.android.maps" />

在你的清单文件中添加这个库。


不行,这个在我的清单文件的<application>下已经有了:<uses-library android:name="com.google.android.maps" android:required="true" />。 - Mohamed Heiba
这不需要 Google Map API V2。 - Lucas
不要混合使用Google Maps API V1和V2。 - Gugelhupf

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接