4

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?

Community
  • 1
  • 1
Massimo Frasson
  • 427
  • 3
  • 10
  • I've never used the "Google android project" export because i could never get it to work.. The project output it exports is not supported by Android studio, you have to jump through some hoops to get it running. Frankly, if there's any good reason to export as a project, i would avoid it altogether. Note that in Unity 5.5 (released a few days ago), you can select "Gradle" as the build option in Unity. – lysergic-acid Dec 03 '16 at 22:11
  • The reason I export the project is because I need to enable multi dex. I hope that upgrading unity will be a solution, I must check if I can face problems upgrading – Massimo Frasson Dec 04 '16 at 18:25
  • It is really discouraged to use multidex from a few different reasons. If you can avoid it, that's your best solution. – lysergic-acid Dec 04 '16 at 19:21
  • I know, but I have no choice. I have already removed all the frameworks etc I could. There is another solution or something else I should try? – Massimo Frasson Dec 04 '16 at 21:13

1 Answers1

0

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)