gpt4 book ai didi

java - 另一个谷歌地图 v2 无法充气,请

转载 作者:行者123 更新时间:2023-12-02 05:50:03 29 4
gpt4 key购买 nike

我知道有很多关于此的帖子,但我就是无法让我的谷歌地图工作。我尝试了数百万种不同的方法来实现这一点,我发现最好的方法是这样的:

MainActivity.java

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {

@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.activity_main, menu);
return true;
}

}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
android:name="in.wptrafficanalyzer.locationgooglemapv2demo.MainActivity"/>

</RelativeLayout>

Manifest.xml

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

<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />

<permission
android:name="in.wptrafficanalyzer.LocationGoogleMapV2Demo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>

<uses-permission android:name="in.wptrafficanalyzer.LocationGoogleMapV2Demo.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"/>
<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" >
<activity
android:name="in.wptrafficanalyzer.locationgooglemapv2demo.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.maps.v2.API_KEY"
android:value="AIzaSyAxS05MA_zbMWq27N83FOqKh7MlwLz-2Lg"/>

</application>

</manifest>

但我仍然遇到很多人都遇到的错误:(我实现了 google-play-services_lib

 05-13 13:18:39.673: E/ActivityThread(14542): Failed to inflate
05-13 13:18:39.673: E/ActivityThread(14542): android.view.InflateException: Binary XML file line #7: Error inflating class fragment
05-13 13:18:39.673: E/ActivityThread(14542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-13 13:18:39.673: E/ActivityThread(14542): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-13 13:18:39.673: E/ActivityThread(14542): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-13 13:18:39.673: E/ActivityThread(14542): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-13 13:18:39.673: E/ActivityThread(14542): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-13 13:18:39.673: E/ActivityThread(14542): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.Activity.setContentView(Activity.java:1881)
05-13 13:18:39.673: E/ActivityThread(14542): at in.wptrafficanalyzer.locationgooglemapv2demo.MainActivity.onCreate(MainActivity.java:12)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.Activity.performCreate(Activity.java:5122)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2432)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2530)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.ActivityThread.access$600(ActivityThread.java:176)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1385)
05-13 13:18:39.673: E/ActivityThread(14542): at android.os.Handler.dispatchMessage(Handler.java:107)
05-13 13:18:39.673: E/ActivityThread(14542): at android.os.Looper.loop(Looper.java:194)
05-13 13:18:39.673: E/ActivityThread(14542): at android.app.ActivityThread.main(ActivityThread.java:5546)
05-13 13:18:39.673: E/ActivityThread(14542): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 13:18:39.673: E/ActivityThread(14542): at java.lang.reflect.Method.invoke(Method.java:525)
05-13 13:18:39.673: E/ActivityThread(14542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-13 13:18:39.673: E/ActivityThread(14542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
05-13 13:18:39.673: E/ActivityThread(14542): at dalvik.system.NativeStart.main(Native Method)
05-13 13:18:39.673: E/ActivityThread(14542): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.maps.internal.q.B(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.maps.internal.q.A(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.maps.SupportMapFragment$b.gW(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.dynamic.a.a(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
05-13 13:18:39.673: E/ActivityThread(14542): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
05-13 13:18:39.673: E/ActivityThread(14542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
05-13 13:18:39.673: E/ActivityThread(14542): ... 21 more
05-13 13:18:39.683: E/AndroidRuntime(14542): FATAL EXCEPTION: main
05-13 13:18:39.683: E/AndroidRuntime(14542): java.lang.RuntimeException: Unable to start activity ComponentInfo{in.wptrafficanalyzer.locationgooglemapv2demo/in.wptrafficanalyzer.locationgooglemapv2demo.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2478)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2530)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.ActivityThread.access$600(ActivityThread.java:176)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1385)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.os.Handler.dispatchMessage(Handler.java:107)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.os.Looper.loop(Looper.java:194)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.ActivityThread.main(ActivityThread.java:5546)
05-13 13:18:39.683: E/AndroidRuntime(14542): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 13:18:39.683: E/AndroidRuntime(14542): at java.lang.reflect.Method.invoke(Method.java:525)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
05-13 13:18:39.683: E/AndroidRuntime(14542): at dalvik.system.NativeStart.main(Native Method)
05-13 13:18:39.683: E/AndroidRuntime(14542): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.Activity.setContentView(Activity.java:1881)
05-13 13:18:39.683: E/AndroidRuntime(14542): at in.wptrafficanalyzer.locationgooglemapv2demo.MainActivity.onCreate(MainActivity.java:12)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.Activity.performCreate(Activity.java:5122)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2432)
05-13 13:18:39.683: E/AndroidRuntime(14542): ... 11 more
05-13 13:18:39.683: E/AndroidRuntime(14542): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.maps.internal.q.B(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.maps.internal.q.A(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.maps.SupportMapFragment$b.gW(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.dynamic.a.a(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
05-13 13:18:39.683: E/AndroidRuntime(14542): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
05-13 13:18:39.683: E/AndroidRuntime(14542): ... 21 more

请有人可以帮助我...我试图制作简单的谷歌地图应用程序一个多月了,但我没有选择...:(

最佳答案

你的logcat说得很清楚

Caused by: java.lang.IllegalStateException: The meta- data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the element:

您需要使用 <meta-data> 添加 Google Play 服务版本标签 <application>标签在你的 manifest.xml文件

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

关于java - 另一个谷歌地图 v2 无法充气,请,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23629987/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com