我正在尝试在单击按钮时启动 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/