Unity exporting android project with Facebook SDK issue

懵懂的女人 提交于 2019-12-10 17:15:07

问题


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:

  1. Create a Unity project and add Facebook sdk (Import custom package etc)
  2. Then configure it from the menu on the top bar under Facebook > Edit settings (it's enough adding the app id)
  3. In build settings select Android platform and edit player prefs adding a bundle id and setting min sdk version to 15
  4. Save the scene
  5. Try to build an apk, it should work
  6. Now instead of building check 'Google Android project' in build setting and click export
  7. After that open android studio and click on import project
  8. 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
  9. Press next and finish
  10. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!