错误在活动地图xml中膨胀类别片段 [英] Error Inflating class fragment in activity maps xml

查看:70
本文介绍了错误在活动地图xml中膨胀类别片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个项目以前一直在努力。在运行应用程序时,我一直在收到InflateException。

  04-01 12:16:36.102 14895-14895 / com.example。 ali.googleandroid E / AndroidRuntime:进程:com.example.ali.googleandroid,PID:14895 
04-01 12:16:36.102 14895-14895 / com.example.ali.googleandroid E / AndroidRuntime:java.lang .RuntimeException:无法启动活动ComponentInfo {com.example.ali.googleandroid / com.example.ali.googleandroid.MapsActivity}:android.view.InflateException:二进制XML文件行#8:二进制XML文件行#8:错误充气类片段
04-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 / AndroidRunt ime:在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-01 12:16:36.102 14895-14895 / com.example.ali.googleandroid E / AndroidRuntime:引起:android.view.InflateException:二进制XML文件行#8:二进制XML文件行#8:错误的扩展类片段

MapsActivity.java

  package com.example.ali.googleandroid; 

导入android.Manifest;
导入android.annotation.TargetApi;
导入android.content.Context;
导入android.content.Intent;
导入android.content.pm.PackageManager;
导入android.location.Criteria;
导入android.location.Location;
导入android.location.LocationManager;
导入android.media.MediaPlayer;
导入android.os.Build;
导入android.support.v4.app.ActivityCompat;
导入android.support.v4.app.FragmentActivity;
导入android.os.Bundle;
导入android.support.v4.content.ContextCompat;
导入android.support.v7.app.AppCompatActivity;
导入android.view.View;
导入android.widget.Button;
导入android.widget.EditText;
导入android.widget.ImageButton;
导入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;
导入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;
导入com.google.android.gms.maps.model.Marker;
导入com.google.android.gms.maps.model.MarkerOptions;

import java.lang.reflect.Array;
import java.util.ArrayList;


公共类MapsActivity扩展AppCompatActivity实现GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener,LocationListener的,GoogleMap.OnMyLocationChangeListener,GoogleMap.OnMarkerClickListener {

私有静态最终诠释REQUEST_FINE_LOCATION = 0;

private static int doubleTap = 0;

静态GoogleMap mMap;
MediaPlayer mp;
GoogleApiClient mGoogleApiClient;
LocationRequest mLocationRequest;

static Location myLocation;
静态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); $!
$ b 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);

如果(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)= PackageManager.PERMISSION_GRANTED&安培;&安培; checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)= PackageManager.PERMISSION_GRANTED!){
// TODO:考虑调用
// public void requestPermissions(@NonNull String [] permissions,int requestCode)
//在这里请求缺少的权限,然后重写
// public void onRequestPermissionsResult(int requestCode ,String []权限,
// int [] grantResults)
//处理用户授予权限的情况。有关更多详细信息,请参阅文档
//获得Activity#requestPermissions。
return;
}

myLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(myLocation!= null){
double latitude = myLocation.getLatitude();
double longitude = myLocation.getLongitude();

LatLng latLng =新LatLng(经度,纬度);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(20));
mMap.addMarker(new MarkerOptions()。position(new LatLng(latitude,longitude))。title(You are here!));

}

//插入收集数据方法
GatherDataLocLogon();
GatherUserLogon();


// *************添加for循环以加载所有提交的日记条目************** ****
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 =新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 =323dptools:context =。MapsActivity
/>

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
机器人:layout_alignParentEnd = 真正的
机器人:layout_alignBottom = @ + ID / trackownlocation
机器人:SRC = @绘制/ create_entry
android:background =@ drawable / button_state4

android:layout_alignParentStart =false
android:layout_x =267dp
android:layout_y =330dp/> ;

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/>

android:layout_width =80dp
android:layout_height =80dp
android:id =@ + id / help
android:adjustViewBounds =true
android:padding =20dp
android:scaleType =fitXY
$ b $ android:src =@ drawable / help
的android:背景= @绘制/ button_state3
机器人:layout_alignTop = @ + ID / trackownlocation
机器人:layout_centerHorizo​​ntal = 真正的
机器人:layout_marginTop = 41dp
android:layout_x =139dp
android:layout_y =431dp/>

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/>

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.0encoding =utf-8?> 
< manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.example.ali.googleandroid>
<! -
使用
Google地图Android API v2时不需要ACCESS_COARSE / FINE_LOCATION权限,但您必须指定粗略或精细的
位置权限作为' MyLocation'功能。
- >
< 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/>

<使用权限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/>
<使用权限android:name =android.permission.CAMERA/>
<使用权限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/>
<使用权限android:name =android.permission.CHANGE_NETWORK_STATE/>
<使用权限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/>
<使用权限android:name =com.google.android.providers.gsf.permission.READ_GSERVICES/>

< android:使用权限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>

<! - -
Google Maps API API键被定义为字符串资源。
(请参阅文件res / values / google_maps_api.xml)。
请注意,API密钥已链接到用于签署APK的加密密钥。
您需要为每个加密密钥使用不同的API密钥,包括用于
签名的发布密钥。
您可以在src / debug /和src / release /中定义调试和发布目标的键。
- >
< meta-data
android:name =com.google.android.geo.API_KEY
android:value =@ string / google_maps_key/>

< activity android:name =。SignInScreen>
< intent-filter>

< 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
buildToolsVersion23.0.2
defaultConfig {
applicationIdcom.example.ali.googleandroid
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName1.0
}
buildTypes {
释放{
minifyEnabled假
proguardFiles getDefaultProguardFile( 'proguard的-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

依赖项{
编译fileTree(包括:''.jar'],dir:'libs' )
testCompile'junit:junit:4.12'
compile'c​​om.android.support:appcompat-v7:23.2.1'
compile'c​​om.google.android.gms:play-services :8.4.0'
}




 < meta-class =h2_lin>解决方案 data android:name =com.google.android.gms.version
android:value =@ integer / google_play_services_version/>


This project used to be working before. When running the app, I keep getting InflateException.

04-01 12:16:36.102 14895-14895/com.example.ali.googleandroid E/AndroidRuntime: Process: com.example.ali.googleandroid, PID: 14895
04-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 fragment
04-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>

Manifest file:

<?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'
}

解决方案

Add this to your manifest:

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

这篇关于错误在活动地图xml中膨胀类别片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆