getSupportFragmentManager ()에 액세스 할 수 없습니다.

Aug 23 2020

기본 예제를 만들고이 2 개의 오류가 발생합니다.

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.net.Uri;
import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.ImageButton;
import android.widget.Toast;
import com.google.ar.core.Anchor;
import com.google.ar.core.HitResult;
import com.google.ar.core.Plane;
import com.google.ar.sceneform.AnchorNode;
import com.google.ar.sceneform.rendering.ModelRenderable;
import com.google.ar.sceneform.ux.ArFragment;
import com.google.ar.sceneform.ux.BaseArFragment;
import com.google.ar.sceneform.ux.TransformableNode;
import com.google.ar.sceneform.math.Quaternion;
import com.google.ar.sceneform.math.Vector3;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private ArFragment arFragment;
    private ModelRenderable modelRenderable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.fragment);

오류 발생 :

Inconvertible types; cannot cast 'androidx.fragment.app.Fragment' to 'com.google.ar.sceneform.ux.ArFragment'

조각 가져 오기를 추가 했습니까?

  1. 또한 빌드 중에이 오류를 제공합니다.

    sceneformsrc \ sceneform \ src \ main \ java \ com \ google \ ar \ sceneform \ AnchorNode.java : 3 : 오류 : android.support.annotation 패키지가 존재하지 않습니다. import android.support.annotation.Nullable;

이 오류가 발생하는 것을 놓치고 있습니까?

Sceneform 1.16 및 Andriod studio 4.1을 사용하고 있습니다.

답변

AkashVerma Sep 01 2020 at 08:36
<fragment
        android:id="@+id/face_fragment"
        android:name="com.google.ar.sceneform.ux.ArFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

android : name 태그를 언급 하셨나요?