gpt4 book ai didi

android - Google App Engine : DuplicateFileException

转载 作者:行者123 更新时间:2023-12-02 11:00:27 25 4
gpt4 key购买 nike

使用我的后端已经一年没有问题了。今天,我在一台新计算机上进行了部署,突然之间我收到了duplicatefileexception

完整错误:

Error:Execution failed for task ':android:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt
File1: C:\Users\\.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-api-1.0-sdk\1.9.42\c972bc847992e5512eb4338a38cc2392e56760f6\appengine-api-1.0-sdk-1.9.42.jar
File2: C:\Users\\.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-endpoints\1.9.42\5c25efed254f8f9846d04b156e68283055efd320\appengine-endpoints-1.9.42.jar

在Stack上有一个答案,说您要做的就是将它添加到gradle中:
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
compile 'com.google.appengine:appengine-endpoints:1.9.42'
compile ('com.google.appengine:appengine-endpoints-deps:1.9.42'){
exclude "sep_approx_spanish.txt" //added
}
compile 'javax.servlet:servlet-api:2.5'
compile files('src/main/webapp/WEB-INF/lib/objectify-5.1.12.jar')
compile files('src/main/webapp/WEB-INF/lib/guava-19.0.jar')
compile files('src/main/webapp/WEB-INF/lib/gcm-server-1.0.2.jar')
}

但这给了我另一个错误:
Error:Could not find method exclude() for arguments [sep_approx_spanish.txt] on DefaultExternalModuleDependency{group='com.google.appengine', name='appengine-endpoints-deps', version='1.9.42', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.

我已经查看了我的客户端gradle和服务器,找不到任何地方要两次调用同一个库或类似的库。不知道发生了什么事。

在下面添加Android客户端和后端Gradle:

Android:
android {
buildToolsVersion '25.0.0'
compileSdkVersion 23
defaultConfig {
multiDexEnabled = true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

instrumentTest.setRoot('tests')
}
}

dependencies {
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile project(path: ':backend', configuration: 'android-endpoints')
}

// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', '.android/AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}

jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}

classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}

project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]

iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}

后端:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
}
}

repositories {
jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
compile 'com.google.appengine:appengine-endpoints:1.9.42'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'
compile 'javax.servlet:servlet-api:2.5'
compile files('src/main/webapp/WEB-INF/lib/objectify-5.1.12.jar')
compile files('src/main/webapp/WEB-INF/lib/guava-19.0.jar')
compile files('src/main/webapp/WEB-INF/lib/gcm-server-1.0.2.jar')
}

appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}

最佳答案

尝试在您的“应用” build.gradle 文件中添加以下内容:

android {
...
packagingOptions {
...
exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt'
}
}

关于android - Google App Engine : DuplicateFileException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43066942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com