Building android application failed (re-package resources)

I have been attempting to build an old android application I have (from couple of years ago) and I keep on getting re-package failure errors. I’ve read couple of discussions with answers here on UnityAnswers but haven’t been able to fix the issue.

The console log reads:

Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
D:\Android SDK\build-tools\19.1.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "D:/Android SDK/platforms/android-21\android.jar" -F bin/resources.ap_ --extra-packages com.google.example.games.basegameutils:com.google.example.games.mainlibproj -S "D:\Projects\Amazing Paulsonothon u4\Temp\StagingArea\android-libraries\BaseGameUtils\res"

But I simply don’t understand what the error message is trying to tell me. I initially assumed it’s because of access rights to the folder, but it has read-write enabled.

I am trying to build on APK level 19 and I have android sdk installed and with api level 19 from there as well. I have also tried setting it lower in Unity and having lower android sdk stuff but it had no difference. I have bundle identifiers, keystores and keys set. I also have Google Play Games asset “installed” in project and setup with my Google play app id, but that hasn’t made any difference either.

The error message seems to refer to the newest sdk I currently have, but before I had that installed it also matched the api 19.

NOTE: For any issue that cannot be resolved using this answer, please check out this link.

This is a known issue with Android build-tools v21.0.

See this link for the entire discussion: http://forum.unity3d.com/threads/commandinvokationfailure-android-asset-packaging-tool-failed-no-stderr-to-lookup.274631/

You need to update your build-tools to the latest version (v21.0.2 should resolve this problem).

EDIT:

The upgrade to build tools v21.0.2 seems to resolved the original issue. Now you’re facing a different one.

The issue now is that either you (directly) or indirectly via some plugin reference google play services. Your project probably only contains the .jar without the accompanying resources (such as the resource that describes the version number).

You can add this manually by creating Plugins/Android/res/values/version.xml and have this in it:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="google_play_services_version">6171000</integer>
</resources>

*I am not sure this is the version you are using though, this is what i have in my machine

EDIT 2:

Also, you may do something else and drop the reference that looks up this resource id (it says that it is in AndroidManifest line 19)

I found one useful link here.

deleting plugins / android / google-play-services_lib / res / values / common_attrs removed this error…

source:
http://forum.unity3d.com/threads/failed-to-re-package-resources-help.345837/