Невозможно загрузить Renderable при попытке реализовать ядро - PullRequest
0 голосов
/ 23 февраля 2020

Почему я получаю эту ошибку при попытке создать приложение AR?

Unable to load Renderable registryId='android.resource://com.nevco.ar/raw/cat'
    java.util.concurrent.CompletionException: java.lang.AssertionError: No RCB file at uri: android.resource://com.nevco.ar/raw/cat

Я пользуюсь этим руководством для создания простого приложения, но каждый раз, когда я запускаю свое приложение, я получаю эту ошибку. Я не уверен, что делать, чтобы это исправить. Некоторая помощь будет признательна. Я приложил ссылку на учебник. https://www.androidauthority.com/google-arcore-972579/

public class MainActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getSimpleName();
    private static final double MIN_OPENGL_VERSION = 3.0;

//Create a member variable for ModelRenderable//

    private ModelRenderable dinoRenderable;

//Create a member variable for ArFragment//

    private ArFragment arCoreFragment;

    @RequiresApi(api = VERSION_CODES.N)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!checkDevice((this))) {
            return;
        }

        setContentView(R.layout.activity_main);
        arCoreFragment = (ArFragment)

//Find the fragment, using fragment manager//

                getSupportFragmentManager().findFragmentById(R.id.main_fragment);

        if (Build.VERSION.SDK_INT >= VERSION_CODES.N) {

//Build the ModelRenderable//

            ModelRenderable.builder()
                    .setSource(this, R.raw.cat)
                    .build()
                    .thenAccept(renderable -> dinoRenderable = renderable)
                    .exceptionally(

//If an error occurs...//

                            throwable -> {

//...then print the following message to Logcat//

                                Log.e(TAG, "Unable to load renderable");
                                return null;
                            });
        }

//Listen for onTap events//

        arCoreFragment.setOnTapArPlaneListener(
                (HitResult hitResult, Plane plane, MotionEvent motionEvent) -> {
                    if (dinoRenderable == null) {
                        return;
                    }

                    Anchor anchor = hitResult.createAnchor();

//Build a node of type AnchorNode//

                    AnchorNode anchorNode = new AnchorNode(anchor);

//Connect the AnchorNode to the Scene//

                    anchorNode.setParent(arCoreFragment.getArSceneView().getScene());

//Build a node of type TransformableNode//

                    TransformableNode transformableNode = new TransformableNode(arCoreFragment.getTransformationSystem());

//Connect the TransformableNode to the AnchorNode//

                    transformableNode.setParent(anchorNode);

//Attach the Renderable//

                    transformableNode.setRenderable(dinoRenderable);

//Set the node//

                    transformableNode.select();
                });
    }

    public static boolean checkDevice(final Activity activity) {

//If the device is running Android Marshmallow or earlier...//

        if (Build.VERSION.SDK_INT < VERSION_CODES.N) {

//...then print the following message to Logcat//

            Log.e(TAG, "Sceneform requires Android N or higher");
            activity.finish();
            return false;
        }
        String openGlVersionString =
                ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE))
                        .getDeviceConfigurationInfo()

//Check the version of OpenGL ES//

                        .getGlEsVersion();

//If the device is running anything less than OpenGL ES 3.0...//

        if (Double.parseDouble(openGlVersionString) < MIN_OPENGL_VERSION) {

//...then print the following message to Logcat//

            Log.e(TAG, "Requires OpenGL ES 3.0 or higher");
            activity.finish();
            return false;
        }
        return true;
}

}

...