2016-04-01 17 views
1

önce çalışıyor kullanılan Bu proje eşler. Uygulamayı çalıştırırken, InflateException almaya devam ediyorum.Hata xml

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> 

Bildiri dosyası:

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

Eğer göndermeden senin tezahür? –

+0

done @RohitArya –

+0

Mutlak düzen uzun zaman önce kullanımdan kaldırıldı. Neden hala kullanıyorsun? –

cevap

0

yerine android:name="com.google.android.gms.maps.SupportMapFragment"

+0

için teşekkürler ama sorun düzeltmedi –

+0

Aynı şişirme hatası? – jomartigcal

+0

evet @jonmartigcal –

0

arasında ... fragman class="com.google.android.gms.maps.SupportMapFragment" kullanmak yöntemini OnResume ekleyin ve başlaması ve çok

0

Bildiriminize Bu ekle orada Harita belirlesin :

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

teşekkür ama aynı zamanda 'build.gradle' gönderebilir sorunu –

+0

saptamak vermedi? –

+0

tamamlandı, yayını düzenledi –

İlgili konular