简体   繁体   中英

Unity exporting android project with Facebook SDK issue

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM