I encountered several errors when building on Unity 2021 for Android Platform. They're all part of the same "error group" so I'll list all of them down here since they're all part of a single problem which is exporting a game for Android. I can't find a single solution since everything I'm listing is part of my solution.

Here are some of the errors I've encountered:

  1. In Google Play Console, "You cannot use API level 30 and below. For security reasons, your app should use API level 31+"
  2. In Unity, "android.enableR8 is deprecated"
  3. In Unity, unityLibrary:compileDebugJavaWithJavac
  4. In Unity, "Gradle Build Failed. Android resource linking failed... AAPT: error: attribute android:export not found"
  5. In Unity, "Gradle Build Failed. Android resource linking failed..."

2 Answers 2


"You cannot use API level 30 and below"

You just need to set the API level to 31+ in Edit/Project Settings/Player/Other Settings/Identification/Target API Level enter image description here


Google made breaking changes with how Unity builds the Android projects. The solution is to download a gradle that is v6.1.1+ and below v7 in https://gradle.org/releases/. This YouTube video explains it clearly. I'll list down the things he did to get his project working. Note: His steps didn't work for me; hence, the succeeding solutions may help you.

  1. Download gradle from link whose version is greater than or equal to 6.1.1 and less than 7.0.0. (why not below 6.1.1, because Unity said so.)(why not 7+, see section below). Extract it to a folder. Copy the folder path. The folder path should contain the lib folder which Unity will be needing.
  2. In Edit/Preferences/External Tools, untick the gradle checkbox and paste the folder path to your gradle you've extracted. external tools
  3. In Edit/Project Settings/Player/Publishing Tools, check these 5 items. check these
  4. Add android:export="true" in the first Activity tag in Assets\Plugins\Android\AndroidManifest.xml. (In my case, this didn't work but, for some, it worked for them. Just try doing it first)
  5. In Assets\Plugins\Android\baseProjectTemplate.gradle, make sure the version in this line is 4.0.1.
    classpath 'com.android.tools.build:gradle:4.0.1'
  1. In Assets\Plugins\Android\gradleTemplate.properties, comment out the android.enableR8 by placing a # at the start of the line.
  2. Attempt to build.

If not working, proceed to next section.


  1. Make sure you downloaded a gradle between 6.1.1 and the last version before it becomes 7. Here's a reference
  2. Attempt to build. If not working, proceed to next step.

AAPT: error: attribute android:export not found

  1. Remove android:export=true in the first Activity tag in Assets\Plugins\Android\AndroidManifest.xml
  2. Attempt to build. For me, the Unity project was already able to export the game.

Gradle Build Failed. Android resource linking failed...

  1. If still not working, see below content which is from here part 1
  1. Another solution is to go to the Editor folder in your project, create a file called AndroidManifestPostGenerateGradleProject.cs, and then paste the following script into it:
    public void OnPostGenerateGradleAndroidProject(string path)
        Debug.Log("Build path : " + path);
        string gradlePropertiesFile = path + "/../gradle.properties";
        if (File.Exists(gradlePropertiesFile)) File.Delete(gradlePropertiesFile);

        StreamWriter writer = File.CreateText(gradlePropertiesFile);
  1. If there's still a problem, see conversation regarding unicode characters

These are pretty much my research over the past week. Hopefully, this helps some devs.

  • \$\begingroup\$ will accept my answer in 2 days \$\endgroup\$ Jan 15, 2023 at 10:21

In my case the issue was in Target Level API.

By default API 34 was set.

After changing it to API 33 gradle built my project.

Probably the root cause is API 34 in beta at this moment.

Hope this will help if you are strugging a whole day like I am.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .