android地图应用程序没有在设备中运行

时间:2014-01-14 10:15:17

标签: java android

我正在尝试在我的samsung s2设备上运行android地图应用程序,但它没有运行。 我已经在清单文件中给出了所有权限,并且还从谷歌控制台生成了api密钥,但它仍然无效。

我还将库项目链接到我的应用程序。

以下是log cat条目

 01-14 15:38:39.219: W/dalvikvm(13258): VFY: unable to resolve static field 1563 (MapAttrs) in Lcom/google/android/gms/R$styleable;

    01-14 15:38:39.219: D/dalvikvm(13258): VFY: replacing opcode 0x62 at 0x000e

    01-14 15:38:39.227: D/AndroidRuntime(13258): Shutting down VM

    01-14 15:38:39.227: W/dalvikvm(13258): threadid=1: thread exiting with uncaught exception (group=0x41bb22a0)

    01-14 15:38:39.227: E/AndroidRuntime(13258): FATAL EXCEPTION: main

    01-14 15:38:39.227: E/AndroidRuntime(13258): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.Activity.onCreateView(Activity.java:4835)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.Activity.setContentView(Activity.java:1920)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at com.example.mapapp.MainActivity.onCreate(MainActivity.java:12)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.Activity.performCreate(Activity.java:5185)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2132)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.ActivityThread.access$700(ActivityThread.java:140)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.os.Handler.dispatchMessage(Handler.java:99)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.os.Looper.loop(Looper.java:137)
    01-14 15:38:39.227: E/AndroidRuntime(13258):    at android.app.ActivityThread.main(ActivityThread.java:4918)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at java.lang.reflect.Method.invokeNative(Native Method)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at java.lang.reflect.Method.invoke(Method.java:511)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)

    01-14 15:38:39.227: E/AndroidRuntime(13258):    at dalvik.system.NativeStart.main(Native Method)

清单文件:>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>
<permission android:name="com.example.mapapp.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="com.example.mapapp.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission             android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
 Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name="com.google.android.maps"/>
    <meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Api key"/>
    <activity
        android:name="com.example.mapapp.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application> 
</manifest>

1 个答案:

答案 0 :(得分:0)

您的项目似乎没有引用Google Play服务 将库项目导入工作区
- 单击文件&gt;导入,选择Android&gt;现有Android代码进入Workspace,并从“C:\ Users * 您的路径 * \ Local \ Android \ android-sdk \ extras \ google \ google_play_services”浏览到库项目的副本
- 请小心,最多 - google_play_services,而不是google_play_services_lib
- 选择您的项目(而不是Google Play服务库项目),然后右键单击它。选择属性&gt;从左上角选择Android标签&gt;在“库”部分中按“添加”选择google-play-services_lib项目,然后按“确定”。如果一切正常,您可以在Google Play服务库的左侧看到绿色勾选。
之后你可以清理你的工作区,它应该工作
如果您需要进一步研究,请使用ReferencingLibraryProjectSetup
还要将此作为应用程序的子项添加到您的清单中

  

元数据android:name =“com.google.android.gms.version”android:value =“@ integer / google_play_services_version”/&gt;