简体   繁体   中英

Solved - Fatal exception error in Android Studio with imported Unity project

I am running into a "Fatal exception error" in Android Studio. I have created an app, that when a button is clicked is supposed to launch a unity project that I have imported into Android Studio in a.aar format. It's throwing a Fatal exception error that I am unsure of how to solve. The app launches fine but when I press the button it crashes. The logcat print out is below:

2020-05-05 21:40:56.094 24376-24376/? D/OpenGLRenderer: Skia GL Pipeline
2020-05-05 21:40:56.131 24376-24406/? I/Adreno: QUALCOMM build                   : 4c638fb, I557c585805
    Build Date                       : 10/06/18
    OpenGL ES Shader Compiler Version: EV031.25.03.01
    Local Branch                     : 
    Remote Branch                    : 
    Remote Branch                    : 
    Reconstruct Branch               : 
2020-05-05 21:40:56.131 24376-24406/? I/Adreno: Build Config                     : S L 6.0.7 AArch64
2020-05-05 21:40:56.134 24376-24406/? I/Adreno: PFP: 0x005ff112, ME: 0x005ff066
2020-05-05 21:40:56.136 24376-24406/? I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2020-05-05 21:40:56.137 24376-24406/? I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2020-05-05 21:40:56.137 24376-24406/? I/OpenGLRenderer: Initialized EGL, version 1.4
2020-05-05 21:40:56.137 24376-24406/? D/OpenGLRenderer: Swap behavior 2
2020-05-05 21:41:00.711 24376-24376/com.jonathan.vrtest3 W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@da7daa7
2020-05-05 21:41:00.738 24376-24376/com.jonathan.vrtest3 E/onathan.vrtest: Invalid ID 0x00000000.
2020-05-05 21:41:00.738 24376-24376/com.jonathan.vrtest3 D/AndroidRuntime: Shutting down VM
2020-05-05 21:41:00.740 24376-24376/com.jonathan.vrtest3 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.jonathan.vrtest3, PID: 24376
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jonathan.vrtest3/com.unity3d.player.UnityPlayerActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3047)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3182)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6898)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
        at android.content.res.Resources.getText(Resources.java:348)
        at android.content.res.Resources.getString(Resources.java:441)
        at com.unity3d.player.UnityPlayer.GetGlViewContentDescription(Unknown Source:20)
        at com.unity3d.player.UnityPlayer.<init>(Unknown Source:226)
        at com.unity3d.player.UnityPlayerActivity.onCreate(UnityPlayerActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:7149)
        at android.app.Activity.performCreate(Activity.java:7140)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3027)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3182) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6898) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
2020-05-05 21:41:00.742 24376-24376/com.jonathan.vrtest3 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.jonathan.vrtest3, PID: 24376
    java.lang.Error: FATAL EXCEPTION [main]
    Unity version     : 2019.3.12f1
    Device model      : OnePlus ONEPLUS A5000
    Device fingerprint: OnePlus/OnePlus5/OnePlus5:9/PKQ1.180716.001/2002242003:user/release-keys

    Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jonathan.vrtest3/com.unity3d.player.UnityPlayerActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3047)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3182)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6898)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
        at android.content.res.Resources.getText(Resources.java:348)
        at android.content.res.Resources.getString(Resources.java:441)
        at com.unity3d.player.UnityPlayer.GetGlViewContentDescription(Unknown Source:20)
        at com.unity3d.player.UnityPlayer.<init>(Unknown Source:226)
        at com.unity3d.player.UnityPlayerActivity.onCreate(UnityPlayerActivity.java:41)
        at android.app.Activity.performCreate(Activity.java:7149)
        at android.app.Activity.performCreate(Activity.java:7140)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3027)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3182) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6898) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
2020-05-05 21:41:00.748 24376-24422/com.jonathan.vrtest3 D/OSTracker: OS Event: crash

And my main_activity.java is:

package com.jonathan.vrtest3;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.unity3d.player.UnityPlayerActivity;

public class MainActivity extends AppCompatActivity {


    public static final String EXTRA_LOC_ID = "arguments";

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

        //final Intent intent = new Intent(this, UnityPlayerActivity.class);



        ((Button) findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(MainActivity.this, UnityPlayerActivity.class);

                startActivity(intent);
            }
        });
    }
}

And my manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jonathan.vrtest3">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Any help would be greatly appreciated!

Your manifest is missing the activity, change it to:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jonathan.vrtest3">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name="com.unity3d.player.UnityPlayerActivity" >
            <intent-filter>
                <action android:name="android.intent.action.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".GameActivity"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

and start the unity activity from another activity by chaining the intent with:

GameActivity.java:

class GamesActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
    super.onCreate(savedInstanceState, persistentState);

    Intent intent = new Intent(this, UnityPlayerActivity.class);
    startActivity(intent);
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM