gpt4 book ai didi

java - 已停止申请! GOOGLE API V2 - map

转载 作者:行者123 更新时间:2023-11-30 03:01:06 25 4
gpt4 key购买 nike

我已按照 youtube 上的说明创建 map /位置应用程序。我的第一步只是显示 map ,但由于“不幸的是,MyLocApp 已停止”而卡住了。遵循我的代码。我做错了什么?

list :

<manifest xmlns:android="http://schemas.android.com/apk/res/android":
package="tri.mylocapp"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="14" />
<permission
android:name="tri.mylocapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"
/>
<uses-permission android:name="tri.mylocapp.permission.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"/>
<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="AIzaSyDZIavpm2Kcj4QXnb01qxoZqiEXTBXTABw"/>
<activity
android:name="tri.mylocapp.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>

这是布局 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"/>

这是 proguard-project.txt:

-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}

这是 MainActivity.java:

package tri.mylocapp;
import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

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

LogCat:

 D/AndroidRuntime(639): Shutting down VM
W/dalvikvm(639): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
E/AndroidRuntime(639): FATAL EXCEPTION: main
E/AndroidRuntime(639): java.lang.RuntimeException: Unable to start activity ComponentInfo{tri.mylocapp/tri.mylocapp.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
E/AndroidRuntime(639): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
E/AndroidRuntime(639): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
E/AndroidRuntime(639): at android.app.ActivityThread.access$600(ActivityThread.java:122)
E/AndroidRuntime(639): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
E/AndroidRuntime(639): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(639): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(639): at android.app.ActivityThread.main(ActivityThread.java:4340)
E/AndroidRuntime(639): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(639): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(639): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(639): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(639): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(639): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
E/AndroidRuntime(639): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
E/AndroidRuntime(639): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
E/AndroidRuntime(639): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
E/AndroidRuntime(639): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
E/AndroidRuntime(639): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
E/AndroidRuntime(639): at android.app.Activity.setContentView(Activity.java:1835)
E/AndroidRuntime(639): at tri.mylocapp.MainActivity.onCreate(MainActivity.java:10)
E/AndroidRuntime(639): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(639): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(639): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
E/AndroidRuntime(639): ... 11 more
E/AndroidRuntime(639): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4242000 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" />
E/AndroidRuntime(639): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.maps.internal.q.v(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.maps.internal.q.u(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.maps.MapFragment$b.ex(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.dynamic.a.a(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
E/AndroidRuntime(639): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
E/AndroidRuntime(639): at android.app.Activity.onCreateView(Activity.java:4242)
E/AndroidRuntime(639): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
E/AndroidRuntime(639): ... 20 more
I/Process(639): Sending signal. PID: 639 SIG: 9

最佳答案

你的logcat说的很清楚

.818: E/AndroidRuntime(639): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4242000 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" />
03-20 17:11:43.818:icesUtil.isGooglePlayServicesAvailable(Unknown

将 Google Play 服务版本添加到您应用的 list

Edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.

您需要添加 <meta-data><application> 下标记到您的 AndroidManifest.xml

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

这是因为最新的 google play 服务需要一个版本名称,要使用 <meta-data .. /> 提及。里面AndroidManifest.xml

像这样构建您的 ma​​nifest.xml:

 ....<application>
..............
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDrcKDGxUgl0Ps4u2ptOsIUCI6ooXmZ0RU" />

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

</application>

关于java - 已停止申请! GOOGLE API V2 - map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22522407/

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