3

マップビューをロードするための簡単なアプリを開発しています。私はAPIに従っています。 https://developers.google.com/maps/documentation/android/start#add_a_map

しかし

実行後アプリが強制終了し、LOGCAT ERROR アプリの AndroidManifest.xml のメタデータ タグに正しい値がありません。4030500 を予期していましたが、0 が見つかりました。これは私のマニフェストです

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

<uses-sdk
    android:minSdkVersion="12"
    android:targetSdkVersion="13" />

<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" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyA5QozHkGwJP_9iJi7jtBV938T1wws02gA" />

    <activity
        android:name="com.example.newgmaps.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>

     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>

これは私のメインのxmlです

<?xml version="1.0" encoding="utf-8"?>

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>

そしてこれが主な活動です

package com.example.newgmaps;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

4

7 に答える 7

2

今のところ、以前のバージョンの Google Play Services libproject を使用してください。ここからダウンロードできます: https://dl-ssl.google.com/android/repository/google_play_services_3225130_r10.zip

私のために働いた。

その後、Google が最新バージョンをすべてのユーザーが利用できるようにしたときにこれを更新できますが、この変更がすべてのデバイスに反映されるまでにはしばらく時間がかかることがわかります。

于 2013-11-04T19:27:56.910 に答える
1

これを「AndroidManifest.xml」のxmlコードの下に追加しました

<Application 
...
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
...
</Application>

クラッシュエラーが消えました。でも電話したら…

int iErrorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

"iErrorCode" は 2 です。2 は次のような意味です

public static final int SERVICE_VERSION_UPDATE_REQUIRED インストールされている Google Play サービスのバージョンが古くなっています。呼び出し元のアクティビティは、このエラー コードを getErrorDialog(int, Activity, int) に渡して、表示されたときにエラーを解決するローカライズされたエラー ダイアログを取得する必要があります。定数値: 2 (0x00000002) 詳細...

また、LogCatは言った...

W/GooglePlayServicesUtil(4728): Google Play サービスが古くなっています。4030500 が必要ですが、3266136 が見つかりました

バージョンコード「4030500」はどこ??

[SDK]\extras\google\google_play_services\libproject\google-play-services_lib\res\values

「version.xml」が表示されます。それを開く!

<?xml version="1.0" encoding="utf-8"?> <resources>
    <integer name="google_play_services_version">4030500</integer>
</resources>

いないいないばあ~~!:) これが、新しい SDK を更新して新しい「google-play-services-lib」を使用するときに、この errorCode(2) を取得した理由です。

わかった!とった!デバイスで Google Play のバージョンを確認してみましょう。

ここに画像の説明を入力

私の携帯のバージョンは「4.4.21」で問題ないと思います。この「3266136」は何ですか?これはどこから来たのですか?これは理解できません。

これがわかったら、この長い回答を更新します。

幸運を!みんな!:)

更新 1: apk 4.4.22 をダウンロードして携帯電話にインストールしました。しかし、LogCat にはまだ「3266136」と表示されます。これは本当に奇妙なことです。Google チームはできるだけ早く修正する必要があると思います!!

4.4.22 ここからダウンロード...

更新 2: 結局、「google-play-services_lib」と「android-support-v4.jar」を以前のバージョンにダウングレードすることにしました。私は彼らを待ちます。:)

于 2013-11-04T01:06:35.260 に答える
1

Google は Google Play サービスをバージョン 4.xxx に更新する必要があります ここに画像の説明を入力

于 2013-11-01T20:53:25.853 に答える
0

Manifest の application タグにこのメタデータ タグを追加してみてください。

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
于 2013-11-01T17:08:07.010 に答える