在达到64k方法限制后,我尝试将我的Unity项目导出为gradle构建。将其导入Android Studio后,我收到了错误
错误:库使用与此项目相同的包:com.myproject.name
找到question后我添加了
enforceUniquePackageName = false
到我的gradle项目。现在我可以在Android Studio中运行该项目,但正如该问题的答案所述,我现在在尝试构建APK时出现以下错误
多个dex文件定义Lcom / myproject / myappname / BuildConfig;
我的gradle文件如下
// 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
}
}
}
删除不同的插件并尝试构建后,似乎我可以构建项目,如果我注释掉最后一个插件unity-android-resources,但当然我的应用程序无法正常运行。为什么会出现此错误,以及如何解决此问题?
答案 0 :(得分:1)
您的上一个项目unity-android-resources在AndroidManifest.xml中与基本应用程序具有相同的packageName(在gradle参数applicationId中)。您可以编写任何其他packageName,例如 com.example.myapplication.resources 。