Facebook Unity SDK android barfs when project conn

2019-07-17 02:08发布

问题:

Tricky little issue. A test project with FB plugin worked fine, my project gave me below error. Turns out when i connected FB test project to asset server, and the .meta files got created for each folder, it would barf also. Any way to tell compiler to skip .meta files?

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the     Console for details.
/Users/me/android-sdk-macosx/platform-tools/aapt package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "/Users/me/android-sdk-   macosx/platforms/android-17/android.jar" -F bin/resources.ap_ --extra-packages com.facebook.android -S "/Users/me/Unity/FBTest/Assets/Plugins/Android/facebook/res"

stderr[
invalid resource directory name: /Users/me/Unity/FBTest/Assets/Plugins/Android/facebook/res/drawable-hdpi.meta
invalid resource directory name: /Users/me/Unity/FBTest/Assets/Plugins/Android/facebook/res/drawable-ldpi.meta
invalid resource directory name: /Users/me/Unity/FBTest/Assets/Plugins/Android/facebook/res/drawable-mdpi.meta

UPDATE: can't seem to get rid of .meta files, even though i disconnected from asset server :( any ideas?

UPDATE: had to go Edit -> Project Settings -> Editor and disable version control to get this to compile. Would be nice if this could be fixed so meta files are ignored in the packageing of an APK...

回答1:

May as well mark this as answered. The .meta files added for asset server are breaking the android packaging, so the work around is to disable source control under Edit -> Project Settings -> Editor before doing a build. Be nice if this was fixed so that step was unnecessary though...

UPDATE:

Um, reconnecting to asset server makes it think everything locally has changed, so this is a really, really sucky workaround



回答2:

Found a stupid workaround because I was having the exact same problem, only tested on OSX since it relies on executing a python script via the hashbang line.

  1. Go find the path where aapt is in your android SDK (android-sdk-macosx/build-tools/17.0.0/aapt for example) and rename it to aapt.real
  2. Make a new file called aapt and put the following in it:

    #!/usr/bin/env python
    
    import os
    import sys
    
    os.execv(os.path.join(os.path.split(__file__)[0], 'aapt.real'), ['aapt'] + sys.argv[1:] + ['--ignore-assets', '!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~:!*.meta'])
    
  3. Wonder why Unity doesn't include the --ignore-assets option to fix this problem.


回答3:

i added the line

<property name="aapt.ignore.assets" value="!*.meta:!.svn:!.git:.*:&lt;dir&gt;_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" />

to the build.xml file of the facebook android unity sdk. no need to patch android sdk.



回答4:

Another workaround that seems to work is to delete all the .meta files from the res folder after starting the build, but before unity starts the packaging process. Unity will not recreate the meta files while it is building the project. This way you don't have to disable and re-enable version control.