已解决 - 在Android Studio中导入Unity项目时出现致命的异常错误

问题描述 投票:0回答:1

我在Android Studio中遇到一个 "致命的异常错误"。我创建了一个应用程序,当一个按钮被点击时,应该启动一个unity项目,我已经以.ar格式导入到Android Studio。它正在抛出一个致命的异常错误,我不知道如何解决。该应用程序启动正常,但当我按下按钮时,它就崩溃了。下面是logcat打印出来的。

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

我的main_activity. java是:

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);
            }
        });
    }
}

还有我的manifest文件

<?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>

任何帮助将是非常感激的!

java android unity3d
1个回答
1
投票

你的清单中缺少活动,请将其改为。

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>

然后从另一个活动中启动unity活动,用链子连接意图。

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);
}

}

© www.soinside.com 2019 - 2024. All rights reserved.