Google Play Services integration and duplicate files in APK error

Hi,

I’ve been attempting to integrate Google Play Services into my game using nsight vsi, but I’m struggling to get it to package the application.

During the packaging phase, I’m getting the following error:

-package:
1>  [apkbuilder] Current build type is different than previous build: forced apkbuilder run.
1>  [apkbuilder] Creating testproject-debug-unaligned.apk and signing it with a debug key...
1>  [apkbuilder] Found duplicate file for APK: AndroidManifest.xml
1>  [apkbuilder] Origin 1: c:\AndroidProjects\testproject\Tegra-Android\Debug\bin\testproject.ap_
1>  [apkbuilder] Origin 2: c:\AndroidProjects\testproject\AndroidManifest.xml

 BUILD FAILED
1>  C:\NVPACK\android-sdk-windows\tools\ant\build.xml:958: The following error occurred while executing this line:
1>  C:\NVPACK\android-sdk-windows\tools\ant\build.xml:969: The following error occurred while executing this line:
1>  C:\NVPACK\android-sdk-windows\tools\ant\build.xml:312: com.android.sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK
1>  	at com.android.sdklib.build.ApkBuilder.doAddFile(ApkBuilder.java:821)
1>  	at com.android.sdklib.build.ApkBuilder.addFile(ApkBuilder.java:507)
1>  	at com.android.sdklib.build.ApkBuilder.processFileForResource(ApkBuilder.java:872)
1>  	at com.android.sdklib.build.ApkBuilder.addSourceFolder(ApkBuilder.java:623)

So far, I’ve followed the information from the following posts

Google Play Game Services C++ Integration : https://devtalk.nvidia.com/default/topic/781698/?comment=4335540
Google Play Services : https://devtalk.nvidia.com/default/topic/754393/?comment=4244313

… as well as the tutorials on Google’s developer site, and whilst I can get my code to work with Eclipse … I seem to always encounter the error above when building using nsight vsi.

My process so far is:

  1. Create an Android Native Application using the Nsight VSI Wizard.
  2. Add Google Play Services to my applications, using android update project --library google_play_services\libproject\google-play-services_lib
  3. Modify the AndroidManifest.xml to remove the hascode="False" ( I found that if I left this in, then my apk would build, but would be missing the google play services classes .. also, the eclipse generated androidmanifest.xml didn't have the hascode section .. so seemed to make sense to remove it )
  4. Rebuild .. observe error

As a side note, if I create a bare-bones Android Native Application using the Nsight VSI wizard, without integrating Google Play Services, and remove the hascode=“False” from the androidmanifest.xml, I get the same error.

Any ideas / suggestions on what I’m doing wrong or where to go from here?

Or even better, if someone has a working example of integrating Google Play Services into an application using nsight, or knows of a working example that I could look at / diff against my project, that would be really great :)

Thanks!

So, after posting this message I thought “hmm, I wonder if the provided samples have the same problem…”, so I grabbed the SimpleJNI sample project that comes with AndroidWorks and changed the androidmanifest.xml to have hascode=“True”.

Lo and behold, it built successfully!

I then added the Google Play Services lib to it … and again, it built and ran successfully.

So after lots of trial and error, I found that my project was missing a “src” folder, with an empty do_not_remove.txt file inside it, at the same directory level as the “res” folder. Seems this does something in the ant build that makes the build scripts work.

So, if you have this problem, ensure your directory structure when building looks something like…

<project>.sln
|-- bin\
|-- gen\
|-- libs\
|-- res\
+-- src\
    +-- do_not_remove.txt

It seems that the wizard doesn’t include that src/do_not_remove.txt that’s needed in this instance.

Hope that helps someone!