我有问题,我试图使克里特岛应用程序android。但是当我运行我的应用程序时遇到这样的问题
11-14 19:36:51.989: W/dalvikvm(29668): VFY: unable to resolve virtual method 292: Landroid/app/Notification$Builder;.setPriority (I)Landroid/app/Notification$Builder;
11-14 19:36:51.989: W/dalvikvm(29668): threadid=1: thread exiting with uncaught exception (group=0x40b019f0)
11-14 19:36:51.999: E/AndroidRuntime(29668): FATAL EXCEPTION: main
11-14 19:36:51.999: E/AndroidRuntime(29668): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fuad.traffic/com.fuad.traffic.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.os.Looper.loop(Looper.java:137)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-14 19:36:51.999: E/AndroidRuntime(29668): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 19:36:51.999: E/AndroidRuntime(29668): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-14 19:36:51.999: E/AndroidRuntime(29668): at dalvik.system.NativeStart.main(Native Method)
11-14 19:36:51.999: E/AndroidRuntime(29668): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.Activity.setContentView(Activity.java:1837)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.fuad.traffic.MainActivity.onCreate(MainActivity.java:15)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.Activity.performCreate(Activity.java:4470)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-14 19:36:51.999: E/AndroidRuntime(29668): ... 11 more
11-14 19:36:51.999: E/AndroidRuntime(29668): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6111000 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" />
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.common.GooglePlayServicesUtil.E(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.maps.internal.u.S(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.maps.internal.u.R(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.maps.SupportMapFragment$b.my(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2158)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
11-14 19:36:51.999: E/AndroidRuntime(29668): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
11-14 19:36:51.999: E/AndroidRuntime(29668): ... 21 more
这是我的代码
package com.fuad.traffic;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.Menu;
//import com.google.android.gms.maps.SupportMapFragment;
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.main, menu);
return true;
}
/**@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}*/
}
这是我的androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fuad.traffic"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<permission
android:name="com.fuad.traffic"
android:protectionLevel="signature">
</permission>
<uses-permission android:name="com.fuad.traffic"/>
<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=".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="AIzaSyA_5aZyzrTpGcKuigTrCZcjK6TZ2MU4Glc"/>
</application>
</manifest>
这是针对mainactivity.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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.fuad.traffic.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<fragment
android:id="@+id/map"
android:layout_height="match_parent"
android:layout_width="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
对于stackoveflow中的master,thanx,请帮帮我
thanx stackoverflow
答案 0 :(得分:1)
在堆栈跟踪中清楚地给出了它。
您应用的AndroidManifest.xml中的元数据标记没有正确的值。预期6111000但找到0. 您必须在元素中包含以下声明:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
您可能已将Google Play服务导入为库,但未将此行添加到清单中。