android - 从 Android 启动 Unity 时无法找到 main(错误)

标签 android unity-game-engine

我正在尝试在单击按钮时启动 UnityPlayerActivity。但它抛出一个错误“无法找到 main”。

在 list 中,

<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"
    }
}

关于android - 从 Android 启动 Unity 时无法找到 main(错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44437720/

相关文章:

android - 在 Web 服务中将 JSON 对象作为参数传递 - 返回 "Bad Request"响应

android - MaterialComponents 主题警报对话框按钮

Android - 运行进程和缓存后台进程的区别

android - 取消 Google Play 游戏登录后 Facebook 登录崩溃(反之亦然)

c# - 使用 Unity3D 写入 HoloLens 2 上的 Application.persistentDataPath,然后通过设备 Web 门户访问文件

android - 空指针异常 - findViewById()

android - 无法导航至主要 Activity

android - 统一设置显示分辨率限制

unity-game-engine - Unity 2017.10f3 .Net 4.6 目标问题

javascript - unity 触摸按钮仅带有此标签