从Android启动Unity时无法找到主(错误)

时间:2017-06-08 13:54:53

标签: android unity3d

我正在尝试按下按钮启动UnityPlayerActivity。但它引发了一个错误“无法找到主要”。

在Manifest中,

<activity
        android:name="com.unity3d.player.UnityPlayerActivity"
        android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="landscape">
        <intent-filter>
            <category android:name="com.google.intent.category.CARDBOARD" />
        </intent-filter>
        <meta-data
            android:name="unityplayer.UnityActivity"
            android:value="true" />
    </activity>

我正在使用以下代码启动

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

1 个答案:

答案 0 :(得分:3)

只需构建armeabi-v7a版本即可。但是如果你正在尝试构建像x86或通用apk这样的其他构建,那么你就会遇到这种错误。

因此,在gradle中指定仅构建armeabi-v7a apk。

splits {

    // Configures multiple APKs based on ABI.
    abi {

        // Enables building multiple APKs per ABI.
        enable true

        // By default all ABIs are included, so use reset() and include to specify that we only
        // want APKs for x86, armeabi-v7a, and mips.

        // Resets the list of ABIs that Gradle should create APKs for to none.
        reset()

        // Specifies a list of ABIs that Gradle should create APKs for.
        include "armeabi-v7a"
    }
}