Legacy Documentation: Version 2017.2 (Go to current version)
Gradle for Android
Android Manifest
Other Versions

Gradle troubleshooting

If you just switched to export your Android project using Gradle 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-in is much more picky than the old ADT/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.

Duplicate files in APK

You have a file name collision 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 APK 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 Player Settings).

Colliding attributes

A library can not freely override attributes from the main AndroidManifest.xml. 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.





























































对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答