After hitting the 64k method limit I tried to export my Unity project as a gradle build. After importing it to Android Studio, I got the error
Error: A library uses the same package as this project: com.myproject.name
After finding this question I added
enforceUniquePackageName = false
to my gradle project. Now I can run the project in Android Studio, but as noted in the answer to that question, I now get the following error when I try to build an APK
Multiple dex files define Lcom/myproject/myappname/BuildConfig;
My gradle file is as follows
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'ShortcutBadger-1.1.5', ext:'aar')
compile(name: 'animated-vector-drawable-23.4.0', ext:'aar')
compile(name: 'appcompat-v7-23.4.0', ext:'aar')
compile(name: 'cardview-v7-23.4.0', ext:'aar')
compile(name: 'customtabs-23.4.0', ext:'aar')
compile(name: 'facebook-android-sdk-4.17.0', ext:'aar')
compile(name: 'facebook-android-wrapper-7.9.4', ext:'aar')
compile(name: 'firebase-analytics-11.0.2', ext:'aar')
compile(name: 'firebase-analytics-impl-11.0.2', ext:'aar')
compile(name: 'firebase-app-unity-4.0.2', ext:'aar')
compile(name: 'firebase-common-11.0.2', ext:'aar')
compile(name: 'firebase-core-11.0.2', ext:'aar')
compile(name: 'firebase-iid-11.0.2', ext:'aar')
compile(name: 'firebase-messaging-11.0.2', ext:'aar')
compile(name: 'firebase-messaging-unity-4.0.2', ext:'aar')
compile(name: 'play-services-base-11.0.2', ext:'aar')
compile(name: 'play-services-basement-11.0.2', ext:'aar')
compile(name: 'play-services-gcm-11.0.2', ext:'aar')
compile(name: 'play-services-iid-11.0.2', ext:'aar')
compile(name: 'play-services-tasks-11.0.2', ext:'aar')
compile(name: 'support-compat-26.0.0-alpha1', ext:'aar')
compile(name: 'support-core-ui-26.0.0-alpha1', ext:'aar')
compile(name: 'support-core-utils-26.0.0-alpha1', ext:'aar')
compile(name: 'support-fragment-26.0.0-alpha1', ext:'aar')
compile(name: 'support-media-compat-26.0.0-alpha1', ext:'aar')
compile(name: 'support-v4-26.0.0-alpha1', ext:'aar')
compile(name: 'support-vector-drawable-23.4.0', ext:'aar')
compile(name: 'utnotifications', ext:'aar')
compile project(':Firebase')
compile project(':UTNotificationsRes')
compile fileTree(dir: 'fabric-init/libs', include: ['*.jar'])
compile fileTree(dir: 'crashlytics-wrapper/libs', include: ['*.jar'])
compile fileTree(dir: 'crashlytics/libs', include: ['*.jar'])
compile fileTree(dir: 'beta/libs', include: ['*.jar'])
compile fileTree(dir: 'answers/libs', include: ['*.jar'])
compile project(':fabric')
compile (project(':unity-android-resources'))
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.0'
enforceUniquePackageName = false
defaultConfig {
targetSdkVersion 25
}
lintOptions {
abortOnError false
disable 'MissingTranslation'
}
signingConfigs {
//omitted!
}
buildTypes {
debug {
jniDebuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
signingConfig signingConfigs.release
}
}
}
After removing different plugins and trying to build, it seems that I can build the project if I comment out the last plugin unity-android-resources, but of course my app doesn't run properly. Why would this error occur here, and how I can I resolve this issue?