问题
I found an issue on exporting a project from Unity3D to Android Studio when Facebook SDK is involved. Currently I'm using Unity 5.4.1f1 and facebook-unity-sdk-7.9.0.
Here the steps to reproduce the issue:
- Create a Unity project and add Facebook sdk (Import custom package etc)
- Then configure it from the menu on the top bar under Facebook > Edit settings (it's enough adding the app id)
- In build settings select Android platform and edit player prefs adding a bundle id and setting min sdk version to 15
- Save the scene
- Try to build an apk, it should work
- Now instead of building check 'Google Android project' in build setting and click export
- After that open android studio and click on import project
- Select the folder with the name of the project you choose, you can find it inside the folder you select during the export procedure from Unity
- Press next and finish
- When grade finishes his stuff and builds you get the error
Error:(131) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.NoActionBar'.
Error:(136) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Dialog'.
Error:(131) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.NoActionBar'.
Error:(136) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Dialog'.
Error:Execution failed for task ':facebookandroidsdk4170:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt
Someone did face this and has already found a solution?
回答1:
Seems like you are missing the appcompat library, the problem with exporting to android studio is that it doesn't export .aar files well (at least before Unity 5.5).
You have to copy all your .aar files in your Plugins/Android (there may be also in the facebook folder) into your android studio project libs folder.
Then open your app build.gradle (normally named app or same as your project's name) and put inside the dependencies this for each .aar file:
compile(name: 'aarlibrarywithoutextension', ext: 'aar')
for example if you have a common.aar file you should put this:
compile(name: 'common', ext: 'aar')
make sure in that file that you have this also:
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
as the flatDir libs tells android studio to look for libraries there (remember that you copied all your .aar files from unity into the libs folder inside android studio project)
来源:https://stackoverflow.com/questions/40934964/unity-exporting-android-project-with-facebook-sdk-issue