For the second day I’m trying to screw the google map, but everything is even. Basically, I took info from google documentation. I also tried other ways to solve this problem.
When building the application, the same error constantly goes out and for some reason always refers to the line where I initialized binding binding = DataBindingUtil.setContentView (this, R.layout.activity_screen_map);
I ask for help from more experienced colleagues.
A piece of typesetting with a fragment
<fragment android:id="@+id/mapView" class="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginEnd="8dp" android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/toolbar" /> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" style="@style/toolbar"/> </android.support.constraint.ConstraintLayout> The implementation class itself:
private SupportMapFragment mapFragment; private GoogleMap googleMap;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen_map); //Getting an instance binding = DataBindingUtil.setContentView(this, R.layout.activity_screen_map); googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); googleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions) .build(); mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapView); mapFragment.getMapAsync(this); //Call the toolbar setSupportActionBar(binding.toolbar); binding.toolbar.setTitle(getResources().getString(R.string.mapTitle)); } @Override public void onMapReady(GoogleMap gMap) { googleMap = gMap; LatLng sydney = new LatLng(-33.852, 151.211); googleMap.addMarker(new MarkerOptions().position(sydney) .title("Marker in Sydney")); googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); } Manifesto:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.USE_CREDENTIALS" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" /> <activity android:name=".MainActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".ScreenMapActivity" android:screenOrientation="portrait"/> <activity android:name=".ScreenFamilyActivity" android:label="@string/contacts" android:launchMode="singleTop" android:screenOrientation="portrait" android:parentActivityName=".ScreenMapActivity"/> <activity android:name=".AddContactActivity" android:label="@string/addContact"></activity> </application> All the necessary dependencies are connected.
The error itself:
android.view.InflateException: Binary XML file line # 11: Error inflating class fragment
11 line, this is just the line where the fragment begins. Already the whole head broke itself.
Also here is the following Binary XML file line # 11 error: Duplicate id 0x7f08006e, tag null, or parent id 0xffffffff for com.google.android.gms.maps.SupportMapFragment
It says that two identical id. I checked everything and found nothing.
I ask you not to throw stones, I just started studying android for a long time and I need real help.
idfor the fragment - FlippyMapViewinstead of a fragment - FlippyDataBinding, but the logic and the signature ofDataBindingUtil.setContentView(...)should be used instead ofActivity.setContentView(...)- then you call the second inflate of the markup because of the call of both and the second one falls into FragmentManager an instance of a map fragment, respectively, with identicalidandtag. - woesss