我试图在单击按钮时启动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"
}
}