giandifra / arcore_flutter_plugin

Flutter plugin for ARCore SDK, Android platform to build new augmented reality experiences
MIT License
435 stars 281 forks source link

Unable to detect ARCore even when its apk is installed #204

Open abhishekdv1 opened 1 year ago

abhishekdv1 commented 1 year ago

I'm trying to test out an minimal example that uses your library but always end up with a Google Play installation overlay (even if Google Play Services for Augumented is already installed') which is followed by a "Handle exception: null" toast, which indicates that an com.google.ar.core.exceptions.UnavailableUserDeclinedInstallationException was thrown

Here's our main.dart code:

//ignore_for_file: no_leading_underscores_for_local_identifiers, unused_element, unused_local_variable

import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';
import 'package:vector_math/vector_math_64.dart' as vector;

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  ArCoreController? arCoreController;

  _onArCoreViewCreated(ArCoreController _arcoreController) {
    arCoreController = _arcoreController;
    _addSphere(arCoreController!);
  }

  _addSphere(ArCoreController _arcoreController) {
    final material = ArCoreMaterial(color: Colors.redAccent);
    final sphere = ArCoreSphere(materials: [material], radius: 0.5);
    final node = ArCoreNode(
      shape: sphere,
      position: vector.Vector3(
        0,
        0,
        -1,
      ),
    );

    _arcoreController.addArCoreNode(node);
  }

  @override
  void dispose() {
    arCoreController?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ArCoreView(
        onArCoreViewCreated: _onArCoreViewCreated,
      ),
    );
  }
}

The rest of the installation procedure was followed from the suggested medium article: https://medium.com/@difrancescogianmarco/arcore-flutter-plugin-configurations-3ee53f2dc749

Is there any way we could please fix this issue? We have confirmed from the Settings > Apps section too that the Google Play Services for AR is installed on the target device and othjer AR apps from Play store too work as expected

Thanks a lot in advance!

GoodMorrrrning commented 1 year ago

same problem

JanSeibicke commented 1 year ago

I am having the same problem, did you manage to fix it yet?

hasnentai commented 1 year ago

Stuck with the same issue Not even able to make the example work

JanSeibicke commented 1 year ago

For everyone still wondering I found a solution that works for me.

The example project worked after i installed a Pixel 4 API 29 Emulator in Android Studio using the current version of Google Play Services for AR.

I was trying to make it work on emulators and physical devices that all used APIs above 30 which makes me believe that the APIs below 30 work just fine with this plugin

hasnentai commented 1 year ago

Thanks @JanSeibicke I will try it out

abhishekdv1 commented 1 year ago

Did it work @hasnentai ?

Marmik123 commented 1 year ago

@olexale Please help in this issue most of the people are facing this Issue

hasnentai commented 1 year ago

@abhishekdv1 I din tried this lib I tried out the DeepAR to make it work which is not free

farinchan commented 1 year ago

@abhishekdv1 Change targetSdkVersion to targetSdkVersion 28, it works for me.

Yacine-Benali commented 1 year ago

@abhishekdv1 Change targetSdkVersion to targetSdkVersion 28, it works for me.

while this can work you won't be able to publish your app on google play store as they require you target at least a two year old version from the current version, which right now means u must target API level 30