google-ar / arcore-unity-extensions

Google ARCore Extensions and Geospatial Creator for Unity's AR Foundation
Other
351 stars 98 forks source link

Cloud Anchors INTERNAL_ERROR on hosting #4

Open gtluszcz opened 4 years ago

gtluszcz commented 4 years ago

Hi! I am developing AR game using ARFoundation on Unity 2019.3.0b7. I wanted to use Cloud Anchors API by google and followed this codelab

Every time I try to host anchor I see TaskInProgress and then after 0.8-2s InternalError which is frustrating. InternalError doesn't really tell me anything. I'm integrating Cloud Anchors for the first time. Does anyone know why it doesn't work or can give me any tip to make it work?

this is a screen from my Package Manager for you to check out package versions:

Screenshot 2019-11-06 at 18 24 40

This is my code responsible for cloud anchor management:

public ConnectionHandler connectionHandler;
public Game game;
public UiController uiController;
public ARReferencePointManager pointManager;
private ARCloudReferencePoint m_CloudReferencePoint;

void Update()
    {
        if (state == AnchorManagerState.WaitingToHostAnchor)
        {
            CloudReferenceState cloudReferenceState = m_CloudReferencePoint.cloudReferenceState;
            uiController.NoticePlayer(cloudReferenceState.ToString());  //prints status on screen
            if (cloudReferenceState == CloudReferenceState.Success)
            {
                // On success logic here
                m_CloudReferencePoint = null;
                state = AnchorManagerState.Idle;
            }
        }

        if (state == AnchorManagerState.WaitingToFetchAnchor)
        {
            CloudReferenceState cloudReferenceState = m_CloudReferencePoint.cloudReferenceState;
            uiController.NoticePlayer(cloudReferenceState.ToString()); //prints status on screen
            if (cloudReferenceState == CloudReferenceState.Success)
            {
                game.referencePoint = pointManager.AddReferencePoint(m_CloudReferencePoint.pose);

                m_CloudReferencePoint = null;
                state = AnchorManagerState.Idle;
            }
        }
    }

    public void CreateAnchor()
    {
        Pose pose = new Pose();
        pose.position = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10.0f));
        game.referencePoint = pointManager.AddReferencePoint(pose);

        m_CloudReferencePoint = pointManager.AddCloudReferencePoint(game.referencePoint);
        if (m_CloudReferencePoint == null)
        {
            // Here handle error
        }
        else
        {
            state = AnchorManagerState.WaitingToHostAnchor;
        }
    }

    public void DownloadAnchor(string anchorId)
    {
        m_CloudReferencePoint = pointManager.ResolveCloudReferenceId(anchorId);
        if (m_CloudReferencePoint == null)
        {
            // Here handle error
        }
        else
        {
            state = AnchorManagerState.WaitingToFetchAnchor;
        }
    }
gtluszcz commented 4 years ago

Today I plugged in logcat. This is what prints out right after call to CreateAnchor(): Does anyone know how to get RPC logs and this arguments especially?

2019-11-07 16:55:35.746 16285-16462/? E/ARCore-AnchorServiceClient: Error calling CreateAnchors RPC: 
    djp: INVALID_ARGUMENT: Request contains an invalid argument.
        at djm.a(PG:53)
        at dyg.a(PG:24)
        at djb.a(PG:4)
        at dgj.a(PG:7)
        at dlo.a(PG:46)
        at djb.a(PG:4)
        at dgj.a(PG:7)
        at dlw.a(PG:13)
        at dma.a(PG:225)
        at dmb.a(PG:39)
        at dmg.a(PG:15)
        at dmv.run(PG:5)
        at due.run(PG:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
gtluszcz commented 4 years ago

also found that!

2019-11-07 16:42:03.467 14689-14711/? E/ARCore-AuthenticationManager: Exception during AuthenticationManager construction: com.google.android.gms.common.GoogleApiAvailability
    java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at com.google.ar.persistence.AuthenticationManager.a(PG:72)
        at com.google.ar.persistence.AuthenticationManager.<init>(PG:4)
        at com.google.ar.persistence.AuthenticationManagerFactory.create(PG:3)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
        at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:214)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
     Caused by: java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:454) 
        at com.google.ar.persistence.AuthenticationManager.a(PG:72) 
        at com.google.ar.persistence.AuthenticationManager.<init>(PG:4) 
        at com.google.ar.persistence.AuthenticationManagerFactory.create(PG:3) 
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method) 
        at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) 
        at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) 
        at android.os.Handler.dispatchMessage(Handler.java:103) 
        at android.os.Looper.loop(Looper.java:214) 
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) 
tanpeter commented 4 years ago

Hi Grzegorz,

Do you still have the same issue? INVALID_ARGUMENT is most likely caused by a malformed or invalid API key. Could you please check the value you copy from the GCP console (as stated in https://codelabs.developers.google.com/codelabs/arcore-extensions-cloud-anchors/#6)

mohamedragabkamal98 commented 4 years ago

i have same error and i don`t use api just edit in build gradle and put compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } and implementation "com.google.ar.sceneform.ux:sceneform-ux:1.0.0" and edit mainfest :

<uses-feature android:name="android.hardware.camera.ar" />
    <meta-data android:name="com.google.ar.core" android:value="required" />

and put fragment only and get same error and app crush

tanpeter commented 4 years ago

@mohamedragabkamal98 java.lang.ClassNotFoundException: com.google.android.gms.common.GoogleApiAvailability is actually a benign error and it will be suppressed in the next release (sorry about the noise!)

You probably need to look at the logs more closely to find the actual error causing the crash.

gmartinsnull commented 4 years ago

UPDATE:

Ok I actually managed to figure it out. In my case, the problem was that I was disabling plane detection/tracking in order to save memory and battery life after I was happy with the planes I've detected. Apparently, Cloud Anchors does not like it and requires to have plane detection on at all times.

The solution was to simply remove the line of code where I was disabling it which was arPlaneManager.detectionMode = PlaneDetectionMode.None;


Hi there!

I'm having almost the exact same issue except that I have no clue as to what the error it may be/mean. It returns a ErrorInternal state after calling anchorManager.HostCloudAnchor().

This is what I get on logcat:

05-27 01:34:49.262 8221 8418 W native : hotspot_anchor_hoster_v1beta2.cc:116 INTERNAL: Compact dataset does not contain keyframes. 05-27 01:34:49.301 8221 8249 I Unity : Fail to host Cloud Anchor with state: ErrorInternal 05-27 01:34:49.301 8221 8249 I Unity : UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object) 05-27 01:34:49.301 8221 8249 I Unity : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) 05-27 01:34:49.301 8221 8249 I Unity : UnityEngine.Logger:Log(LogType, Object) 05-27 01:34:49.301 8221 8249 I Unity : UnityEngine.Debug:Log(Object)

Strange thing is that it works on the sample project(which I based my app off of) so I wonder if I'm missing something?

Even more strange, without doing anything at all I managed to get a success once time ...