Unity Android12 error solution

As the title states, the project requirements require unity to export the Android package, and the target level requires Android 12 (API 31) or above. As a result, an error occurs when exporting. The reason: Android Build Tools 31.0.0 is incompatible with the Unity build system. Starting from Android Build Tools version 31.0.0, DX was removed and replaced by D8, causing Unity's Android build to be interrupted.

Solution: 1.

 Find the custom file:

  • Assets/Plugins/Android/mainTemplate.gradle
  • Assets/Plugins/Android/launcherTemplate.gradle

 Set the compiled SDK version and buildTools version as shown above.

2. Open the customized Mainfest.XML file, find the Activity started by the application, and android:exported="true"属性加进去,否则会在部分机型上解析失败导致不能安装。

<activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>

Guess you like

Origin blog.csdn.net/u013748096/article/details/126362618