Version: 2020.1
Troubleshooting Android development
Reporting crash bugs under Android

Gradle troubleshooting

If you just switched to export your Android project using GradleAn Android build system that automates several build processes. This automation means that many common build errors are less likely to occur. More info
See in Glossary
instead of the old system, you may encounter build errors, especially if you are using additional Android libraries, or if you have added a custom AndroidManifest.xml.

The Android Gradle plug-inA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary
is much more picky than the old ADTAn Android project type that is no longer supported by Google and is considered obsolete. More info
See in Glossary
/Ant system. It does not accept anything it considers an error, whether it’s duplicate symbols, references to resources that don’t exist, or a library project that sets the same attribute as the main application.

In most cases, fixing the problem involves editing an AndroidManifest.xml file; either the main one, or one from a library your project uses.

In a non-trivial project, or if the project has issues not described by the troubleshooting section below, export the project as a Gradle project (from Build Settings) and build from the command line. Building from the command line gives you more detailed error messages, and makes for a quicker turnaround when applying changes.

Specific problems

Resource not found

An AndroidManifest.xml file, either the main one or in a library, references a non-existing resource. Often it is the application icon or label string that is set by a library. This can happen if you have copied your main manifest to a library project without removing those references.

Remove the attribute from one of the Android Manifests – normally the one from the library.

MinSDK in Manifest

The android:minSdkVersion attribute is specified in the AndroidManifest.xml file. It can be in the main manifest file, or in a file in one of the directories which Unity treats as Android libraries. .aar plugins shouldn’t cause this issue.

The solution is to remove the uses-sdk android:minSdkVersion element from the main manifest and / or manifests in library directories. Instead, you should specify the minimum SDK version in the build.gradle file instead. If you don’t have a custom Gradle template, Unity automatically handles this. If you do have a custom Gradle template, make sure the minSDK is specified in the defaultConfig section of the template.

Duplicate files in APK

You have a file name collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a rigidbody component and is in motion. More info
See in Glossary
between your main application and a library project, or between two library projects. Keep in mind that all of the files are copied into the same APKThe Android Package format output by Unity. An APK is automatically deployed to your device when you select File > Build & Run. More info
See in Glossary
package.

You need to remove one of the files.

Colliding package names

A library can not use the same Java package as the main application, or any other library.

Usually, you should change the package name of the library to something different. If the library contains a lot of code, it may be easier to change the main package name (from the Player settings).

Colliding attributes

A library can not freely override attributes from the main AndroidManifest.xml file. Often this error is caused by a library setting the application icon or label string, similar to the Resource not found problem above.

Either remove the attribute from the library, or add a tools:replace attribute to your application tag, to indicate how the merge conflict should be resolved.

Troubleshooting Android development
Reporting crash bugs under Android