Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ilovebread · Jul 26, 2017 at 02:01 PM · androidandroid buildjavabuild errorbuildpipeline

Any way to exclude BuildConfig.java from unity-android-resources project via Gradle?

Hi guys,

So I've recently upgraded my Unity to 5.6 in hopes of utilizing the Gradle build pipeline (to workaround the nasty dex limit).

After some days of configuring it, I ran into this head-cracking issue. Here is the error as displayed in the Unity Editor console:

 Execution failed for task ':transformClassesWithJarMergingForRelease'.
 > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: my/unity/game/BuildConfig.class

So it seems that some plugin/external project is including a BuildConfig class file with the exact same package name (as depicted by the file structure, and also why I had to set enforceUniquePackageName to false in the main project gradle ).

In Android Studio, when looking for the BuildConfig file, I noticed two different projects that had the same package name. One of the projects was definitely for the main Unity project, while the other was for an automatically generated/included project for unity-android-resources.

This is the BuildConfig.java for the unity-android-resources project:

 /**
     * Automatically generated file. DO NOT MODIFY
     */
 
package my.unity.game;
    
    
 public final class BuildConfig 
 {
      
           public static final boolean DEBUG = Boolean.parseBoolean("true");
      
           public static final String APPLICATION_ID = “my.unity.game”;
      
           public static final String BUILD_TYPE = "debug";
      
           public static final String FLAVOR = "";
      
           public static final int VERSION_CODE = 1;
      
           public static final String VERSION_NAME = "1.0";
    
 }



While this one is for the main project:

 /**
     * Automatically generated file. DO NOT MODIFY
     */
    
 package my.unity.game;
    
    
 public final class BuildConfig 
 {
      
           public static final boolean DEBUG = Boolean.parseBoolean("true");
      
           public static final String APPLICATION_ID = “my.unity.game”;
      
           public static final String BUILD_TYPE = "debug";
      
           public static final String FLAVOR = "";
      
           public static final int VERSION_CODE = 72;
      
           public static final String VERSION_NAME = "2.04.34";
    
 }



Is there a way I could somehow either:

  • Exclude the BuildConfig.java from the automatically generated unity-android-resources project via the main gradle file? or,

  • Is there someway I could alter the package name for the automatically generated BuildConfig.java file for unity-android-resources?

If it helps, here are the dependencies (and no, doesn't seem like I can just remove unity-android-resources dependency, as the build fails due to some missing icon resources):

 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile(name: 'GoogleAIDL', ext:'aar')
     compile(name: 'GooglePlay', ext:'aar')
     compile(name: 'appcompat-v7-23.4.0', ext:'aar')
     compile(name: 'cardview-v7-23.4.0', ext:'aar')
     compile(name: 'common', ext:'aar')
     compile(name: 'facebook-android-sdk-4.23.0', ext:'aar')
     compile(name: 'facebook-android-wrapper-7.10.0', ext:'aar')
     compile(name: 'play-services-ads-10.0.1', ext:'aar')
     compile(name: 'play-services-auth-10.0.1', ext:'aar')
     compile(name: 'play-services-auth-base-10.0.1', ext:'aar')
     compile(name: 'play-services-base-10.0.1', ext:'aar')
     compile(name: 'play-services-basement-10.0.1', ext:'aar')
     compile(name: 'play-services-drive-10.0.1', ext:'aar')
     compile(name: 'play-services-games-10.0.1', ext:'aar')
     compile(name: 'play-services-iid-10.0.1', ext:'aar')
     compile(name: 'play-services-nearby-10.0.1', ext:'aar')
     compile(name: 'play-services-tasks-10.0.1', ext:'aar')
     compile(name: 'support-v4-24.0.0', ext:'aar')
     compile project(':Etcetera_lib')
     compile project(':Flurry_lib')
     compile project(':MainLibProj')
     compile project(':PermissionCheckPlugin')
     compile project(':SwrvePush_lib')
     compile project(':fyber-unityads-1.5.6-r3')
     compile project(':unity-android-resources') // <- possible cause of error
 }


Thanks for any help guys.

Warm regards, Someone desperate

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ilovebread · Jul 16, 2017 at 11:18 AM 0
Share

Okay, so I think I solved this by specifying packageBuildConfig = false inside the android block in [Unity root]/PlaybackEngines/AndroidPlayer/Tools/GradleTemplate/libTemplate.gradle

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by zhanxi · Feb 26, 2018 at 02:34 AM

Use this to fix ! https://www.reddit.com/r/androiddev/comments/6ilx6h/tip_to_libraries_devs_exclude_buildconfig_from/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

174 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Some Functions Not Working After Android Build 0 Answers

Different Unity games cannot install on same Android device 4 Answers

Android App Bundle build failure: reserved file or directory error 0 Answers

Android Build with il2cpp failed: The specified executable is not a valid application for this OS platform. 1 Answer

I am not able to build android app in Unity3D. Error: CommandWithNoStdoutInvokationFailure: Gradle initialization failed. -1 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges