Search Unity

Unity 5.6 Gradle build problem

Discussion in 'Android' started by Apollo-Meijer, Apr 7, 2017.

  1. Apollo-Meijer

    Apollo-Meijer

    Joined:
    Mar 30, 2015
    Posts:
    31
    Hey!

    So I noticed that when I export a build to a gradle project and import it in android studio I get this error:

    Error:Execution failed for task ':processReleaseResources'.
    > Error: A library uses the same package as this project: com.youdagames.gop3multiplayer

    I fixed it and noticed that the unity-android-resources lib that the unity build process added now includes a manifest with the same package name as my project. In unity 5.5 this manifest had the package name "com.youdagames.gop3multiplayer.resources".. I have to manually change it everytime I want to build? is this intentional??
     
  2. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    This is a bug. Please submit a report - we'll fix it ASAP.
     
  3. Apollo-Meijer

    Apollo-Meijer

    Joined:
    Mar 30, 2015
    Posts:
    31
    For anyone who wants to know.. to fix it.. add ".resources" to the unity-android-resources manifest package name. hope this get fixes faster then my other bug xD took 4 months
     
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    I already pushed the fix to the development branch, so it will need just a week or so to appear in a patch release ;)
     
    liortal likes this.
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I am using gradle, how come i didn't see this? or does it only happen when importing into Android studio ?
     
  6. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @liortal if you're not using Assets/Plugins/Android/res folder (which I hope you don't) - you're not affected ;)
     
  7. Apollo-Meijer

    Apollo-Meijer

    Joined:
    Mar 30, 2015
    Posts:
    31
    Thanks Yury! Some plugins use the "Assets/Plugins/Android/res" folder, can you explain to me why you hope we dont use the folder??
     
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Sure - please read the warning Unity prints when you are using this folder :)
    It's a bad practice because it may cause resource conflicts with the other plugins.
     
  9. Apollo-Meijer

    Apollo-Meijer

    Joined:
    Mar 30, 2015
    Posts:
    31
  10. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @Apollo-Meijer your bug report even wasn't processed by the QAs because there is no repro project attached.
    Also, it should be fixed in 5.6.0p3, according to my notes.
     
  11. Apollo-Meijer

    Apollo-Meijer

    Joined:
    Mar 30, 2015
    Posts:
    31
    I must have missed it in the patch notes. Thanks!
     
    Yury-Habets likes this.
  12. Waqas-Anwar

    Waqas-Anwar

    Joined:
    Feb 2, 2015
    Posts:
    26
    I am having similar issue. I am using unity 5.6 gradle system. I relocated my "Assets/Plugins/Android/res" folder to "Assets/Plugins/Android/android-resources/" but the unity doesn't export this folder in the exported android studio project. I also added some jars in the "Assets/Plugins/Android/libs" folder that are not exported in the project. Any help regarding this ?
     

    Attached Files:

  13. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    1. Trying renaming it to something else. Maybe the name android-resources is already taken (long shot, but who knows)
    2. What does this folder contain? it should have at the bare minimum a project.properties, androidmanifest.xml and the res libs folder (probably optional).
     
    Yury-Habets likes this.
  14. DoPinG8383

    DoPinG8383

    Joined:
    Aug 4, 2015
    Posts:
    1
    This bug still exists even in 5.6.2p4 build. =( But I use just Default Build System instead of Gradle. While converting to dex I'm getting an error of too many refferenses and have a package with name "com.mycompany.myapp.resources" in addition to normal package "com.mycompany.myapp" with same refferenses count in both.
     
    Last edited: Jul 25, 2017
  15. stevencoull

    stevencoull

    Joined:
    Sep 15, 2016
    Posts:
    16
    We're using this folder to localize our app name, is there a better way to do this then?
     
  16. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @stevencoull ideally, you should provide your resources (even the localization strings) in a .aar file. It's an archive so could be even updated automatically. You could also create an Android Library (we do generate it from res/ folder when building for you).

    However, in your case, if providing resources in res/ works for you, - feel free to do it until we drop support for it completely.
     
  17. stevencoull

    stevencoull

    Joined:
    Sep 15, 2016
    Posts:
    16
    @Yury-Habets thanks for the reply. We're only using res/ for our localization strings, so it makes sense to move over to .aar before it's unsupported. I can't find any documentation on this so I hope you don't mind the silly questions, but if we stick our strings in a .aar file do we have to use the package name as our app? Our app recently hit the 65k limit so I tried exporting to Gradle, but using the res/ folder seems to be causing us some issues as I mentioned here:
    https://forum.unity3d.com/threads/multiple-dex-files-in-default-gradle-output.484396/
    If we use a .aar, will the Gradle build still pick up the localized strings?
     
  18. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @stevencoull those are valid questions. For internal build system, the name of the package instead of res/ folder can be whatever you like it. Gradle is more strict, so you have to define resources within the plugin/package you are accessing it. Gradle should resolve your 64k dex limit issue.

    So, for a valid solution to your tasks, you would have to spend some time. However, we are not going to drop res/ folder support in the foreseeable future - it's not even on the roadmap, so you could easily continue using it if a proper fix is taking too much of your time. But getting prepared for Gradle is definitely the way to go.
     
  19. flashmandv

    flashmandv

    Joined:
    Mar 26, 2015
    Posts:
    156
    @Yury-Habets In Unity 2017.1.2 I have almost the same problem when building apk with Gradle

    Code (CSharp):
    1.  
    2. > Duplicate files copied in APK AndroidManifest.xml
    3.     File1: I:\PROJECTS\Game\Temp\gradleOut\build\intermediates\res\resources-release.ap_
    4.     File2: I:\PROJECTS\Game\Temp\gradleOut\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar
    5.  
    It is caused by UTNotifications Plugin.
    According to Unity Manual -> Gradle troubleshooting, It should be Manifest merge issue..but it is not.
    I tried all possible merging scenarios. I tried renaming: Assets\Plugins\Android\UTNotificationsRes folder to only "res". Still no luck.

    The only thing that works is to exclude AndroidManifest.xml from the gradle..but then the generated apk cannot be installed.
    Please help
     
  20. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Full error message from the console would be most helpful.
     
  21. Num0n1

    Num0n1

    Joined:
    Aug 19, 2016
    Posts:
    8
  22. marcinzmijewski

    marcinzmijewski

    Joined:
    Feb 4, 2015
    Posts:
    11
    @flashmandv Did You solved Your problem? If yes - how?

    > Duplicate files copied in APK AndroidManifest.xml
    > File1: I:\PROJECTS\Game\Temp\gradleOut\build\intermediates\res\resources-release.ap_
    > File2: I:\PROJECTS\Game\Temp\gradleOut\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar