Google map android api v2 application crashes

后端 未结 2 1193
轻奢々
轻奢々 2021-01-06 04:09

I am using Eclipse helios and Android 4.1.2 i have followed the following documentation https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

相关标签:
2条回答
  • 2021-01-06 04:34

    Whoo...after scratching ma head for so long atlast i got the solution first i did debugging with real device using DDMS following its documentation which is fabulous then i discovered the following error

    12-12 15:08:29.458: E/AndroidRuntime(26382): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.example.emeterfinalapp/com.example.emeterfinalapp.SelectLocation}:     android.view.InflateException: Binary XML file line #17: Error inflating class fragment
    

    and then after few more lines of code there was another error which was eye catching

    12-12 15:08:29.458: E/AndroidRuntime(26382): Caused by: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
    

    and then i realised that my api key code is a child of manifest not application which the above error pointed out and then i rectified my manifest to following

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.emeterfinalapp"
    android:versionCode="1"
    android:versionName="1.0" >
    
    
    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="16" />
    
      <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_CORSE_LOCATION" />
    
    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
     <permission
         android:name="com.example.emeterfinalapp.permission.MAPS_RECEIVE"
         android:protectionLevel="signature"/>
    <uses-permission  android:name="com.example.emeterfinalapp.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"/>
    
    
    <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"/>
        <activity
            android:name="com.example.emeterfinalapp.EmeterMainActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.emeterfinalapp.EnterLocationActivity"
            android:label="@string/title_activity_enter_location"
            android:parentActivityName="com.example.emeterfinalapp.EmeterMainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.emeterfinalapp.EmeterMainActivity" />
        </activity>
    
        <activity
            android:name="com.example.emeterfinalapp.SelectLocation"
            android:label="@string/title_activity_select_location"
            android:parentActivityName="com.example.emeterfinalapp.EnterMainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.emeterfinalapp.EnterMainActivity" />
        </activity>
    
         <meta-data
       android:name="com.google.android.maps.v2.API_KEY"
       android:value="my api key"/>
    </application>
    

    and then it went like a zoom and everythng worked just perfectly...Debugging with real device helped a lot...

    0 讨论(0)
  • 2021-01-06 04:35

    I have been using Android Log Viewer (logcat) Application for gathering application logs from the phone and seems to work quite well.

    0 讨论(0)
提交回复
热议问题