我在应用程序中使用的是Google Maps v2.密钥已正确生成,所有权限都存在于清单中.我遵循了Google Maps v2的教程.我遵循了每一个步骤,但是没有用.请帮忙
日志
03-04 01:25:23.145: E/Trace(19467): error opening trace file: No such file or directory (2)03-04 01:25:23.293: E/AndroIDRuntime(19467): FATAL EXCEPTION: main03-04 01:25:23.293: E/AndroIDRuntime(19467): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vogella.androID.locationAPI.maps/com.appscourt.jooging.track.map.health.MainActivity}: androID.vIEw.InflateException: Binary XML file line #11: Error inflating class fragment03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2136)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2174)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.ActivityThread.access0(ActivityThread.java:141)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1267)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.os.Handler.dispatchMessage(Handler.java:99)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.os.Looper.loop(Looper.java:137)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.ActivityThread.main(ActivityThread.java:5059)03-04 01:25:23.293: E/AndroIDRuntime(19467): at java.lang.reflect.Method.invokeNative(Native Method)03-04 01:25:23.293: E/AndroIDRuntime(19467): at java.lang.reflect.Method.invoke(Method.java:511)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:555)03-04 01:25:23.293: E/AndroIDRuntime(19467): at dalvik.system.NativeStart.main(Native Method)03-04 01:25:23.293: E/AndroIDRuntime(19467): Caused by: androID.vIEw.InflateException: Binary XML file line #11: Error inflating class fragment03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:704)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:746)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.rInflate(LayoutInflater.java:749)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:489)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:396)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:352)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.androID.internal.policy.impl.PhoneWindow.setContentVIEw(PhoneWindow.java:260)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.Activity.setContentVIEw(Activity.java:1893)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.appscourt.jooging.track.map.health.MainActivity.onCreate(MainActivity.java:20)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.Activity.performCreate(Activity.java:5058)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2100)03-04 01:25:23.293: E/AndroIDRuntime(19467): ... 11 more03-04 01:25:23.293: E/AndroIDRuntime(19467): 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-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.common.GooglePlayServicesUtil.n(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.maps.internal.q.v(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.maps.internal.q.u(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.maps.MapsInitializer.initialize(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.maps.MapFragment$b.ex(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.maps.MapFragment$b.a(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.dynamic.a.a(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.dynamic.a.onInflate(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at com.Google.androID.gms.maps.MapFragment.onInflate(UnkNown Source)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.app.Activity.onCreateVIEw(Activity.java:4713)03-04 01:25:23.293: E/AndroIDRuntime(19467): at androID.vIEw.LayoutInflater.createVIEwFromTag(LayoutInflater.java:680)03-04 01:25:23.293: E/AndroIDRuntime(19467): ... 22 more
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" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="vertical" > <fragment androID:ID="@+ID/map" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_marginBottom="35dip" /> </linearLayout></relativeLayout>
MainActivity.Java
public class MainActivity extends FragmentActivity {private GoogleMap GoogleMap;protected LocationListener locationListener;@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); initializeMap();}@OverrIDepublic voID onBackpressed() { finish();}private voID initializeMap(){ if(GoogleMap == null){ GoogleMap = ((MapFragment) getFragmentManager().findFragmentByID(R.ID.map)) .getMap(); // check if map is created successfully or not if (GoogleMap == null) { Toast.makeText(getApplicationContext(), "Sorry! unable to create maps", Toast.LENGTH_SHORT) .show(); } } }}
的Manifest.xml
<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID" package="com.vogella.androID.locationAPI.maps" androID:versionCode="1" androID:versionname="1.0" > <uses-sdk androID:minSdkVersion="12" androID:targetSdkVersion="19" /> <permission androID:name="com.example.mapdemo.permission.MAPS_RECEIVE" androID:protectionLevel="signature" /> <uses-feature androID:glEsversion="0x00020000" androID:required="true" /> <uses-permission androID:name="com.example.mapdemo.permission.MAPS_RECEIVE" /> <uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE"/> <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" /> <application androID:allowBackup="true" androID:icon="@drawable/ic_launcher" androID:label="@string/app_name" androID:theme="@style/Apptheme" > <activity androID:name="com.appscourt.jooging.track.map.health.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="AIzaSyCV0yduNQJCXrSWNzk6h__6FYaEg_bfCvE" /> </application></manifest>
解决方法:
你的logcat清楚地说
03-04 01:25:23.293: E/AndroIDRuntime(19467): 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-04 01:25:23.293: E/AndroIDRuntime(19467):
将Google Play服务版本添加到您的应用清单中
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服务需要一个版本名称,该名称要使用<元数据.. />来提及.在AndroIDManifest.xml中
并更改MainActivity扩展Activity
有关更多信息,请访问:: https://developers.google.com/maps/documentation/android
总结以上是内存溢出为你收集整理的android-由于膨胀异常,Google Map无法加载全部内容,希望文章能够帮你解决android-由于膨胀异常,Google Map无法加载所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)