简体   繁体   中英

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 . i have given all the permission in manifest file and also generated the api key from google console but still it is not working.

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.
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"
- Be careful brose only upto - google_play_services and not upto google_play_services_lib
- Select your project (not the Google Play services Library Project), then right click on it. Select Properties > Select Android tab from top left corner > In the Library Section Press Add Select google-play-services_lib project and press OK. You can see a green tick in the Library Section left to Google Play Service Library if everything is done right.
after that you can clean your workspace and it should work
Use ReferencingLibraryProject and Setup if you need to research more.
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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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