这个项目以前曾经工作过.运行该应用程序时,我不断收到InflateException.
04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: Process: com.example.ali.GoogleandroID, PID: 1489504-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ali.GoogleandroID/com.example.ali.GoogleandroID.MapsActivity}: androID.vIEw.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class fragment04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2416)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.app.ActivityThread.-wrap11(ActivityThread.java)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.os.Handler.dispatchMessage(Handler.java:102)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.os.Looper.loop(Looper.java:148)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at androID.app.ActivityThread.main(ActivityThread.java:5417)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at java.lang.reflect.Method.invoke(Native Method)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:616)04-01 12:16:36.102 14895-14895/com.example.ali.GoogleandroID E/AndroIDRuntime: Caused by: androID.vIEw.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class fragment
MapsActivity.java:
package com.example.ali.GoogleandroID;import androID.Manifest;import androID.annotation.TargetAPI;import androID.content.Context;import androID.content.Intent;import androID.content.pm.PackageManager;import androID.location.Criteria;import androID.location.Location;import androID.location.LocationManager;import androID.media.MediaPlayer;import androID.os.Build;import androID.support.v4.app.ActivityCompat;import androID.support.v4.app.FragmentActivity;import androID.os.Bundle;import androID.support.v4.content.ContextCompat;import androID.support.v7.app.AppCompatActivity;import androID.vIEw.VIEw;import androID.Widget.button;import androID.Widget.EditText;import androID.Widget.Imagebutton;import androID.Widget.Toast;import com.Google.androID.gms.common.ConnectionResult;import com.Google.androID.gms.common.GooglePlayServicesUtil;import com.Google.androID.gms.common.API.Googleapiclient;import com.Google.androID.gms.location.LocationListener;import com.Google.androID.gms.location.LocationRequest;import com.Google.androID.gms.location.LocationServices;import com.Google.androID.gms.maps.CameraUpdateFactory;import com.Google.androID.gms.maps.GoogleMap;import com.Google.androID.gms.maps.MapFragment;import com.Google.androID.gms.maps.OnMapReadyCallback;import com.Google.androID.gms.maps.SupportMapFragment;import com.Google.androID.gms.maps.UiSettings;import com.Google.androID.gms.maps.model.BitmapDescriptorFactory;import com.Google.androID.gms.maps.model.Cameraposition;import com.Google.androID.gms.maps.model.LatLng;import com.Google.androID.gms.maps.model.Marker;import com.Google.androID.gms.maps.model.MarkerOptions;import java.lang.reflect.Array;import java.util.ArrayList;public class MapsActivity extends AppCompatActivity implements Googleapiclient.ConnectionCallbacks, Googleapiclient.OnConnectionFailedListener, LocationListener, GoogleMap.OnMyLocationchangelistener, GoogleMap.OnMarkerClickListener { private static final int REQUEST_FINE_LOCATION = 0; private static int doubleTap =0; static GoogleMap mMap; MediaPlayer mp; Googleapiclient mGoogleapiclient; LocationRequest mLocationRequest; static Location myLocation; static LocationManager lm; LatLng latLng; SupportMapFragment mFragment; static ArrayList<Double> DataLon; static ArrayList<Double> DataLatit; static ArrayList<String> DataFirst_name; static ArrayList<String> DataSurname; public static boolean closeDown = false; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mp = MediaPlayer.create(this, R.raw.two_tone_nav); loadPermissions(Manifest.permission.ACCESS_FINE_LOCATION, REQUEST_FINE_LOCATION); if (!isGooglePlayServicesAvailable()) { finish(); } setContentVIEw(R.layout.activity_maps); mFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByID(R.ID.map); mMap = mFragment.getMap(); mMap.setMyLocationEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setZoomGesturesEnabled(true); buildGoogleapiclient(); mGoogleapiclient.connect(); lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Todo: ConsIDer calling // public voID requestPermissions(@NonNull String[] permissions, int requestCode) // here to request the missing permissions, and then overrIDing // public voID onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for Activity#requestPermissions for more details. return; } myLocation = lm.getLastKNownLocation(LocationManager.GPS_PROVIDER); if (myLocation != null) { double latitude = myLocation.getLatitude(); double longitude = myLocation.getLongitude(); LatLng latLng = new LatLng(latitude, longitude); mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); mMap.animateCamera(CameraUpdateFactory.zoomTo(20)); mMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).Title(" You are here!")); } //insert gather data methods GatherDataLoclogon(); GatherUserlogon(); //*************Add for loop to load all submitted diary entrIEs****************** for (int i = 0; i < SignInScreen.DEntry.size(); i++) { String Lat = SignInScreen.Latit.get(i); double DoubleLat = Double.parseDouble(Lat); String Long = SignInScreen.Lon.get(i); double DoubleLong = Double.parseDouble(Long); // mMap.setonMarkerClickListener(this); LatLng NewLatLng = new LatLng(DoubleLong, DoubleLat); mMap.addMarker(new MarkerOptions() .position(new LatLng(DoubleLong, DoubleLat)) .Title(SignInScreen.ETitle.get(i).toString()) .snippet(SignInScreen.DEntry.get(i).toString()) ); mMap.moveCamera(CameraUpdateFactory.newLatLng(NewLatLng)); mMap.animateCamera(CameraUpdateFactory.zoomTo(8)); } }
activity_maps.xml:
<absoluteLayout xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:orIEntation="vertical" androID:background="#619ec9" xmlns:androID="http://schemas.androID.com/apk/res/androID"> <fragment androID:ID="@+ID/map" androID:name="com.Google.androID.gms.maps.SupportMapFragment" xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="362dp" androID:layout_height="323dp" tools:context=".MapsActivity" /> <Imagebutton androID:onClick="CreateDiaryEntry" androID:layout_wIDth="84dp" androID:layout_height="84dp" androID:ID="@+ID/DiaryEntry" androID:adjustVIEwBounds="true" androID:padding="20dp" androID:scaleType="fitXY" androID:layout_aligntop="@+ID/trackownlocation" androID:layout_alignParentEnd="true" androID:layout_alignBottom="@+ID/trackownlocation" androID:src="@drawable/create_entry" androID:background="@drawable/button_state4" androID:layout_alignParentStart="false" androID:layout_x="267dp" androID:layout_y="330dp" /> <Imagebutton androID:onClick="TrackOwnLocation" androID:layout_wIDth="80dp" androID:layout_height="80dp" androID:ID="@+ID/trackownlocation" androID:src="@drawable/own_location" androID:adjustVIEwBounds="true" androID:padding="20dp" androID:scaleType="fitXY" androID:layout_below="@+ID/map" androID:layout_alignParentStart="false" androID:background="@drawable/button_state2" androID:layout_x="9dp" androID:layout_y="429dp" /> <Imagebutton androID:layout_wIDth="80dp" androID:layout_height="80dp" androID:ID="@+ID/help" androID:adjustVIEwBounds="true" androID:padding="20dp" androID:scaleType="fitXY" androID:src="@drawable/help" androID:background="@drawable/button_state3" androID:layout_aligntop="@+ID/trackownlocation" androID:layout_centerHorizontal="true" androID:layout_margintop="41dp" androID:layout_x="139dp" androID:layout_y="431dp" /> <Imagebutton androID:layout_wIDth="80dp" androID:layout_height="80dp" androID:ID="@+ID/imagebutton" androID:src="@mipmap/settings_icon" androID:adjustVIEwBounds="true" androID:padding="20dp" androID:scaleType="fitXY" androID:layout_below="@+ID/map" androID:layout_alignParentStart="false" androID:background="@drawable/button_state5" androID:layout_x="8dp" androID:layout_y="333dp" /> <Imagebutton androID:layout_wIDth="80dp" androID:layout_height="80dp" androID:ID="@+ID/imagebutton2" androID:src="@mipmap/search_icon" androID:adjustVIEwBounds="true" androID:padding="20dp" androID:scaleType="fitXY" androID:layout_below="@+ID/map" androID:layout_alignParentStart="false" androID:background="@drawable/button_state6" androID:layout_x="138dp" androID:layout_y="333dp" /></absoluteLayout>
清单文件:
<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID" package="com.example.ali.GoogleandroID" > <!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use Google Maps AndroID API v2, but you must specify either coarse or fine location permissions for the 'MyLocation' functionality. --> <uses-sdk androID:minSdkVersion="10" androID:targetSdkVersion="23" /> <uses-feature androID:glEsversion="0x00020000" androID:required="true" /> <permission androID:name="com.example.ali.GoogleandroID.permission.MAPS_RECEIVE" androID:protectionLevel="signature" /> <uses-permission androID:name="com.example.ali.GoogleandroID.permission.MAPS_RECEIVE" /> <uses-permission androID:name="androID.permission.ACCESS_FINE_LOCATION" /> <uses-permission androID:name="androID.permission.INTERNET" /> <uses-permission androID:name="androID.permission.CAMERA" /> <uses-permission androID:name="androID.permission.READ_EXTERNAL_STORAGE" /> <uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /> <uses-permission androID:name="androID.permission.CHANGE_NETWORK_STATE" /> <uses-permission androID:name="androID.permission.ACCESS_WIFI_STATE" /> <uses-permission androID:name="androID.permission.CHANGE_WIFI_STATE" /> <uses-permission androID:name="androID.location.GPS_ENABLED_CHANGE" /> <uses-permission androID:name="com.Google.androID.provIDers.gsf.permission.READ_GSERVICES" /> <androID:uses-permission androID:name="androID.permission.READ_PHONE_STATE" /> <application androID:allowBackup="true" androID:icon="@mipmap/ic_launcher" androID:label="@string/app_name" androID:supportsRtl="true" androID:theme="@style/Apptheme" > <!-- The API key for Google Maps-based APIs is defined as a string resource. (See the file "res/values/Google_maps_API.xml"). Note that the API key is linked to the encryption key used to sign the APK. You need a different API key for each encryption key, including the release key that is used to sign the APK for publishing. You can define the keys for the deBUG and release targets in src/deBUG/ and src/release/. --> <Meta-data androID:name="com.Google.androID.geo.API_KEY" androID:value="@string/Google_maps_key" /> <activity androID:name=".SignInScreen" > <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity androID:name=".Entry_dislplay" > </activity> <activity androID:name=".Diary_Entry" > </activity> <activity androID:name=".Recover_Code" > </activity> <activity androID:name=".SecDialog" > </activity> <activity androID:name=".Create_A_New_Acc" > </activity> <activity androID:name=".ThirDialog" > </activity> <activity androID:name=".Help_GuIDe" > </activity> <activity androID:name=".PersDialog" > </activity> <activity androID:name=".MapsActivity" > </activity> <activity androID:name=".logoutDialog" > </activity> </application></manifest>
的build.gradle:
apply plugin: 'com.androID.application'androID { compileSdkVersion 23 buildToolsversion "23.0.2" defaultConfig { applicationID "com.example.ali.GoogleandroID" minSdkVersion 22 targetSdkVersion 23 versionCode 1 versionname "1.0" } buildTypes { release { MinifyEnabled false proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } } productFlavors { }}dependencIEs { compile filetree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.androID.support:appcompat-v7:23.2.1' compile 'com.Google.androID.gms:play-services:8.4.0'}
解决方法:
您应该使用fragment class =“ com.Google.androID.gms.maps.SupportMapFragment” …而不是androID:name =“ com.Google.androID.gms.maps.SupportMapFragment”
总结以上是内存溢出为你收集整理的java-错误放大活动映射xml中的类片段全部内容,希望文章能够帮你解决java-错误放大活动映射xml中的类片段所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)