微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我试图在单击按钮时启动UnityPlayerActivity.但是它抛出一个错误“无法找到主文件”.

在清单中

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

解决方法:

只需构建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"
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐