古いシステムの代わりに、Gradle を使って Android プロジェクトをエクスポートしたばかりならば、ビルドエラーに遭遇するかもしれません。特に、Android ライブラリを追加して使用している場合や、カスタムの AndroidManifest.xml を加えた場合にエラーになる可能性があります。
Android Gradle プラグインは、古い ADT/Ant システムよりもはるかに詳細にこだわります。Android Gradle プラグインは、エラーと考えられるものはすべて受け付けません。例えば、複製のシンボルや、存在しないリソースへの参照などです。主要アプリケーションと同じ属性を設定するライブラリプロジェクトさえ、エラーになります。
問題を修正するには、主要なものでも、プロジェクトが使用するライブラリでも、 AndroidManifest.xml ファイルを編集することが必要です。
問題の原因が不明なプロジェクトや、後述のトラブルシューティングの部分で表示されない問題がある場合は、Build Settings から Gradle プロジェクトとしてプロジェクトをエクスポートして、コマンドラインでビルドします。コマンドラインでビルドすると、さらに詳細なエラーメッセージが表示され、より素早い修正ができます。
AndroidManifest.xml ファイルは、主要なものであってもライブラリのものでも、存在しないリソースを参照します。これは、ライブラリによって設定されたアプリケーションアイコンや、ラベルの文字列であることがしばしばです。これは、参照を削除せずに、主要マニフェストをライブラリプロジェクトにコピーすると発生します。
Android Manifest の 1 つ (通常はライブラリのマニフェスト) から属性を削除してください。
android:minSdkVersion
属性は AndroidManifest.xml
ファイルで指定されます。これは、メインのマニフェストファイル、または Unity が Android ライブラリとして扱うディレクトリの 1 つにあります。.aar プラグインはこの問題を引き起こしません。
解決策は、メインのマニフェストやライブラリディレクトリのマニフェストから uses-sdk android:minSdkVersion
要素を削除することです。代わりに、build.gradle
ファイルで最低限の SDK バージョンを指定する必要があります。カスタム Gradle テンプレートがない場合は、Unity が自動的にこれを処理します。カスタムの Gradle テンプレートがある場合は、必ず minSDK が テンプレートの defaultConfig
セクションで指定されていることを確認してください。
主要アプリケーションとライブラリプロジェクト間や、2 つのライブラリプロジェクト間で、同じ名のファイルがあります。すべてのファイルが同じ APK パッケージにコピーされることに注意してください。
ファイルの 1 つを削除する必要があります。
ライブラリは、同じ Java パッケージを主要アプリケーションや、他のライブラリとして使用できません。
通常、ライブラリのパッケージ名を別のものに変更する必要があります。 コードが大量に含まれているライブラリの場合、(Player 設定で) メインパッケージ名を変更する方が簡単かもしれません。
ライブラリは、主要な AndroidManifest.xml
ファイルの属性を自由にオーバーライドすることはできません。しばしば、このエラーは、上記の Resource not found 問題と同様に、アプリケーションアイコンやラベル文字列を設定するライブラリによって発生します。
ライブラリから属性を削除するか tools:replace 属性を application タグに加えて、マージの競合の解決方法を示します。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.