简体   繁体   English

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

[英]android map application not running in device

I am trying to run android map application on my samsung s2 device but it is not running . 我正在尝试在三星s2设备上运行android map应用程序,但未运行。 i have given all the permission in manifest file and also generated the api key from google console but still it is not working. 我已经在清单文件中授予了所有权限,并且还从Google控制台生成了api密钥,但仍然无法正常工作。

I have also linked the library project to my app . 我还将图书馆项目链接到我的应用程序。

following is the log cat entries 以下是日志猫条目

 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)

manifest file :> 清单文件:>

<?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>

Your project doesn't seem to reference google play services. 您的项目似乎未引用Google Play服务。
Import the library project into your workspace 将库项目导入到您的工作区中
- Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project from "C:\\Users* your path *\\Local\\Android\\android-sdk\\extras\\google\\google_play_services" -点击文件>导入,选择Android>进入工作区的现有Android代码,然后从“ C:\\ Users * 您的路径 * \\ Local \\ Android \\ android-sdk \\ extras \\ google \\ google_play_services”浏览到库项目的副本
- Be careful brose only upto - google_play_services and not upto google_play_services_lib -注意不要超过google_play_services,而不要超过google_play_services_lib
- Select your project (not the Google Play services Library Project), then right click on it. -选择您的项目(不是Google Play服务库项目),然后右键单击它。 Select Properties > Select Android tab from top left corner > In the Library Section Press Add Select google-play-services_lib project and press OK. 选择属性>从左上角选择Android选项卡>在“库”部分中,按添加选择google-play-services_lib项目,然后按确定。 You can see a green tick in the Library Section left to Google Play Service Library if everything is done right. 如果一切正确,您会在Google Play服务库左侧的库部分中看到一个绿色的勾号。
after that you can clean your workspace and it should work 之后,您可以清理工作区,它应该可以工作
Use ReferencingLibraryProject and Setup if you need to research more. 如果需要更多研究,请使用ReferenceencingLibraryProjectSetup
also add this to your manifest as a child to the application 还将其作为子项添加到您的清单中

meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 元数据android:name =“ com.google.android.gms.version” android:value =“ @ integer / google_play_services_version” />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM