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