Wednesday, May 2, 2018

Embedded Unity in Android crashes app

Leave a Comment

I have an embedded Unity3d project in my android program. The 3d project opens fine in stereo view to be used in a DayDream headset (although it always says controller disconnected which is a separate issue). When I click the x to exit the VR view, it goes back to the android application as expected but after 1 second the app flips to landscape and crashes.

Below is the part of the stacktrace where I think the error is occurring but I definitely could be wrong. Any help would be welcome. Thanks

04-16 10:11:17.382 1931-9239/? W/IcingConfig: Invalid input from icing corpus JSON flag.     android.util.MalformedJsonException: Expected ':' at line 60 column 9         at android.util.JsonReader.syntaxError(JsonReader.java:1159)         at android.util.JsonReader.objectValue(JsonReader.java:687)         at android.util.JsonReader.peek(JsonReader.java:347)         at android.util.JsonReader.hasNext(JsonReader.java:319)         at android.util.JsonReader.skipValue(JsonReader.java:549)         at com.google.android.apps.gsa.staticplugins.searchboxroot.features.n.a.k.sA(SourceFile:37)         at com.google.android.apps.gsa.staticplugins.searchboxroot.features.n.a.k.<init>(SourceFile:11)         at com.google.android.apps.gsa.staticplugins.searchboxroot.bf.c(SourceFile:101)         at com.google.android.apps.gsa.staticplugins.searchboxroot.bf.a(SourceFile:60)         at com.google.android.apps.gsa.staticplugins.searchboxroot.bq.<init>(SourceFile:35)         at com.google.android.apps.gsa.staticplugins.searchboxroot.cb.get(SourceFile:54)         at dagger.internal.DoubleCheck.get(SourceFile:10)         at com.google.android.apps.gsa.staticplugins.searchboxroot.a.cmZ(SourceFile:323)         at com.google.android.apps.gsa.staticplugins.searchboxroot.a.b.get(SourceFile:14)         at com.google.android.apps.gsa.search.core.service.worker.a.g.call(Unknown Source:4)         at com.google.android.libraries.gsa.runner.a.a.d(SourceFile:27)         at com.google.android.libraries.gsa.runner.a.d.call(Unknown Source:4)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)         at java.util.concurrent.FutureTask.run(FutureTask.java:266)         at com.google.android.apps.gsa.shared.util.concurrent.b.f.run(Unknown Source:4)         at com.google.android.apps.gsa.shared.util.concurrent.b.at.run(SourceFile:4)         at com.google.android.apps.gsa.shared.util.concurrent.b.at.run(SourceFile:4)         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)         at java.lang.Thread.run(Thread.java:764)         at com.google.android.apps.gsa.shared.util.concurrent.b.h.run(SourceFile:6) 

app homescreen unity opening in stereo modeunity 3d project openapp crashing

My code is attached below MAIN ACTIVITY

public class MainActivity extends AppCompatActivity {      Button unityVRButton;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          unityVRButton = (Button)findViewById(R.id.open_unity);         unityVRButton.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View view) {                 startActivity(new Intent(MainActivity.this,GameActivity.class));             }         });     } } 

ACTIVITY THAT CALLS UNITY

import android.os.Bundle;  import com.rbw.TestVR.UnityPlayerActivity;  /**  * Created by kshah on 3/15/2018.  */  public class GameActivity extends UnityPlayerActivity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);     } } 

Entire project can be found at this link

https://drive.google.com/drive/folders/1jFp4pZBMgevB6Z2YgFinYNg6d4KPQJDb?usp=sharing

1 Answers

Answers 1

There may be a couple different issues. One is the malformed json in the stack trace.

However crashes on screen rotation are usually something else.

It would seem that there is some task that is finishing with references to your old view. When the app is switched to landscape the activity is destroyed and recreated and all your views are recreated. If a long running process is carrying a reference to the view that was garbage collected, your app will crash.

A quick way to tell if this is actually the issue is to add this to your manifest under the calling activity. This will force the calling activity to remain in a portrait mode. If the app does not crash after exit, then its likely that there is a process that is holding reference to destroyed views.

  <activity android:name=".MyActivity" android:label="@string/title_my_activity" android:screenOrientation="portrait" /> 

Here is more info: http://code.hootsuite.com/orientation-changes-on-android/

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment