Вылет activity с Yandex Mapkit после второго нажатия

После добавления ImageButton с переходом на активити с картой, и после возвращения назад на изначальное активити с ImageButton, при нажатии приложение вылетает. В этом же активити есть вторая ImageButton которая привязана на пустой активити с TextView, и с ней все исправно работает.

В logcat: Use databinding or explicit wiring of click listener in code

xml и java первого активити с кнопками: XML:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#64B5F6"
    tools:context=".ChoseActivity">


    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-medium"
        android:gravity="center"
        android:text="@string/culture"
        android:textColor="@color/white"
        android:textSize="34sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.024"
        tools:ignore="TextContrastCheck" />

    <ImageButton
        android:onClick="gomap"
        android:id="@+id/imageButton"
        android:layout_width="410dp"
        android:layout_height="247dp"
        android:layout_marginTop="18dp"
        android:backgroundTint="#00FFFFFF"
        android:contentDescription="@string/GoMap"
        android:scaleType="centerCrop"
        app:layout_constraintEnd_toEndOf="@+id/textView"
        app:layout_constraintStart_toStartOf="@+id/textView"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:srcCompat="@drawable/gomap"
        tools:ignore="ImageContrastCheck,UsingOnClickInXml" />

    <ImageButton
        android:onClick="GoList"
        android:id="@+id/imageButton2"
        android:layout_width="410dp"
        android:layout_height="247dp"
        android:backgroundTint="#00FFFFFF"
        android:contentDescription="@string/list"
        android:scaleType="centerCrop"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/imageButton"
        app:layout_constraintHorizontal_bias="0.444"
        app:layout_constraintStart_toStartOf="@+id/imageButton"
        app:layout_constraintTop_toBottomOf="@+id/imageButton"
        app:layout_constraintVertical_bias="0.456"
        app:srcCompat="@drawable/list" />

</androidx.constraintlayout.widget.ConstraintLayout>

Java:

package com.example.nachinaetsyazdes;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class ChoseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chose2);
    }
    public void gomap(View v){
        Intent intent = new Intent(this, HomeActivity.class);
        startActivity(intent);
    }
    public void GoList(View v){
        Intent intent = new Intent(this, ListActivity.class);
        startActivity(intent);
    }
}

Xml и Java активити с картой:

Xml:

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".HomeActivity">

    <com.yandex.mapkit.mapview.MapView
        android:id="@+id/mapview2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
**Java:**
package com.example.nachinaetsyazdes;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.yandex.mapkit.Animation;
import com.yandex.mapkit.MapKitFactory;
import com.yandex.mapkit.geometry.Point;
import com.yandex.mapkit.map.CameraPosition;
import com.yandex.mapkit.mapview.MapView;
import com.yandex.runtime.image.ImageProvider;

public class HomeActivity extends AppCompatActivity {

    private MapView mapview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        MapKitFactory.setApiKey("1679252a-bd27-4314-9146-6634f6461607");
        MapKitFactory.initialize(this);

        // Укажите имя Activity вместо map.
        setContentView(R.layout.activity_home);
        mapview = findViewById(R.id.mapview2);
        mapview.getMap().move(
                new CameraPosition(new Point(57.819276, 28.332451), 11.0f, 0.0f, 0.0f),
                new Animation(Animation.Type.SMOOTH, 0),
                null);
    }
    @Override
    protected void onStop() {
        mapview.onStop();
        MapKitFactory.getInstance().onStop();
        super.onStop();
    }

    @Override
    protected void onStart() {
        super.onStart();
        MapKitFactory.getInstance().onStart();
        mapview.onStart();
    }
}

Большое спасибо!


Ответы (1 шт):

Автор решения: BAD Pazific

у меня та же проблемы, ты случаем не нашёл решение???

→ Ссылка