在 APK reference.conf 中复制的重复文件 [英] Duplicate files copied in APK reference.conf

查看:20
本文介绍了在 APK reference.conf 中复制的重复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的 Android 应用程序用作 Kafka 的生产客户端".添加以下依赖项后:

I want to use my Android App as a "Producing client" for Kafka. After adding following dependecies:

// https://mvnrepository.com/artifact/org.apache.flink/flink-java
compile group: 'org.apache.flink', name: 'flink-java', version: '1.1.3'

// https://mvnrepository.com/artifact/org.apache.flink/flink-streaming-java_2.10
compile group: 'org.apache.flink', name: 'flink-streaming-java_2.10', version: '1.1.3'

// https://mvnrepository.com/artifact/org.apache.flink/flink-clients_2.10
compile group: 'org.apache.flink', name: 'flink-clients_2.10', version: '1.1.3'

// https://mvnrepository.com/artifact/org.apache.flink/flink-connector-kafka-0.8_2.10
compile group: 'org.apache.flink', name: 'flink-connector-kafka-0.8_2.10', version: '1.1.3'

我收到此错误消息:

出了什么问题:任务执行失败':app:transformResourcesWithMergeJavaResForDebug'.

What went wrong: Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:重复文件复制到 APK reference.conf File1 中:/home/lidox/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-remote_2.10/2.3.7/d5603ae49eefde410f5e75f41b4f60bee61b7bfd/akka.10.jar2.3文件2:/home/lidox/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.10/2.3.7/b20f18109689918f05238deea29e681946d30ef7/akka-actor_2.10/2.3.7.>

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK reference.conf File1: /home/lidox/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-remote_2.10/2.3.7/d5603ae49eefde410f5e75f41b4f60bee61b7bfd/akka-remote_2.10-2.3.7.jar File2: /home/lidox/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.10/2.3.7/b20f18109689918f05238deea29e681946d30ef7/akka-actor_2.10-2.3.7.jar

尝试:使用 --stacktrace 选项运行以获取堆栈跟踪.运行--info 或 --debug 选项以获得更多日志输出.

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

构建失败

我尝试排除其中一个 JAR,但没有成功:

I try to exclude one of the JARs, but no success:

packagingOptions {
    exclude 'META-INF/**'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/NOTICE'
    exclude('**/akka-remote_2.10-*.jar')
    exclude 'reference.conf/**'
}

更新 1:

我需要一些在 gradle 中完成这项工作的东西:

I need something what is doing this job in gradle:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
            <!-- Run shade goal on package phase -->
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
                <configuration>
                    <artifactSet>
                        <excludes>
                            <!-- This list contains all dependencies of flink-dist
                            Everything else will be packaged into the fat-jar
                            -->
                            <exclude>org.apache.flink:flink-annotations</exclude>
                            <exclude>org.apache.flink:flink-shaded-hadoop1</exclude>
                            <exclude>org.apache.flink:flink-shaded-hadoop2</exclude>
                            <exclude>org.apache.flink:flink-shaded-curator-recipes</exclude>
                            <exclude>org.apache.flink:flink-core</exclude>
                            <exclude>org.apache.flink:flink-java</exclude>
                            <exclude>org.apache.flink:flink-scala_2.10</exclude>
                            <exclude>org.apache.flink:flink-runtime_2.10</exclude>
                            <exclude>org.apache.flink:flink-optimizer_2.10</exclude>
                            <exclude>org.apache.flink:flink-clients_2.10</exclude>
                            <exclude>org.apache.flink:flink-avro_2.10</exclude>
                            <exclude>org.apache.flink:flink-examples-batch_2.10</exclude>
                            <exclude>org.apache.flink:flink-examples-streaming_2.10</exclude>
                            <exclude>org.apache.flink:flink-streaming-java_2.10</exclude>

                            <!-- Also exclude very big transitive dependencies of Flink

                            WARNING: You have to remove these excludes if your code relies on other
                            versions of these dependencies.

                            -->
                            <exclude>org.scala-lang:scala-library</exclude>
                            <exclude>org.scala-lang:scala-compiler</exclude>
                            <exclude>org.scala-lang:scala-reflect</exclude>
                            <exclude>com.amazonaws:aws-java-sdk</exclude>
                            <exclude>com.typesafe.akka:akka-actor_*</exclude>
                            <exclude>com.typesafe.akka:akka-remote_*</exclude>
                            <exclude>com.typesafe.akka:akka-slf4j_*</exclude>
                            <exclude>io.netty:netty-all</exclude>
                            <exclude>io.netty:netty</exclude>
                            <exclude>commons-fileupload:commons-fileupload</exclude>
                            <exclude>org.apache.avro:avro</exclude>
                            <exclude>commons-collections:commons-collections</exclude>
                            <exclude>org.codehaus.jackson:jackson-core-asl</exclude>
                            <exclude>org.codehaus.jackson:jackson-mapper-asl</exclude>
                            <exclude>com.thoughtworks.paranamer:paranamer</exclude>
                            <exclude>org.xerial.snappy:snappy-java</exclude>
                            <exclude>org.apache.commons:commons-compress</exclude>
                            <exclude>org.tukaani:xz</exclude>
                            <exclude>com.esotericsoftware.kryo:kryo</exclude>
                            <exclude>com.esotericsoftware.minlog:minlog</exclude>
                            <exclude>org.objenesis:objenesis</exclude>
                            <exclude>com.twitter:chill_*</exclude>
                            <exclude>com.twitter:chill-java</exclude>
                            <exclude>com.twitter:chill-avro_*</exclude>
                            <exclude>com.twitter:chill-bijection_*</exclude>
                            <exclude>com.twitter:bijection-core_*</exclude>
                            <exclude>com.twitter:bijection-avro_*</exclude>
                            <exclude>commons-lang:commons-lang</exclude>
                            <exclude>junit:junit</exclude>
                            <exclude>de.javakaffee:kryo-serializers</exclude>
                            <exclude>joda-time:joda-time</exclude>
                            <exclude>org.apache.commons:commons-lang3</exclude>
                            <exclude>org.slf4j:slf4j-api</exclude>
                            <exclude>org.slf4j:slf4j-log4j12</exclude>
                            <exclude>log4j:log4j</exclude>
                            <exclude>org.apache.commons:commons-math</exclude>
                            <exclude>org.apache.sling:org.apache.sling.commons.json</exclude>
                            <exclude>commons-logging:commons-logging</exclude>
                            <exclude>commons-codec:commons-codec</exclude>
                            <exclude>com.fasterxml.jackson.core:jackson-core</exclude>
                            <exclude>com.fasterxml.jackson.core:jackson-databind</exclude>
                            <exclude>com.fasterxml.jackson.core:jackson-annotations</exclude>
                            <exclude>stax:stax-api</exclude>
                            <exclude>com.typesafe:config</exclude>
                            <exclude>org.uncommons.maths:uncommons-maths</exclude>
                            <exclude>com.github.scopt:scopt_*</exclude>
                            <exclude>commons-io:commons-io</exclude>
                            <exclude>commons-cli:commons-cli</exclude>
                        </excludes>
                    </artifactSet>
                    <filters>
                        <filter>
                            <artifact>org.apache.flink:*</artifact>
                            <excludes>
                                <!-- exclude shaded google but include shaded curator -->
                                <exclude>org/apache/flink/shaded/com/**</exclude>
                                <exclude>web-docs/**</exclude>
                            </excludes>
                        </filter>
                        <filter>
                            <!-- Do not copy the signatures in the META-INF folder.
                            Otherwise, this might cause SecurityExceptions when using the JAR. -->
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                    <transformers>
                        <!-- add Main-Class to manifest file -->
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>reactiontest.Job</mainClass>
                        </transformer>
                    </transformers>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
            </execution>
        </executions>
    </plugin>

或者,可以尝试使用 maven 构建 APK,也许它会奏效.pom 可以是 thispom 使用 Maven 构建 Android 应用程序

Alternativly one could try to build an APK using maven, maybe it will work. The pom could be a combination of this and the pom building Android Applications with Maven

推荐答案

首先看这个问题:Android 上的 Kafka Producer.似乎现在还无法在移动设备上使用 kafka.

First if all, look at this question: Kafka Producer on Android. It seems it's not yet possible to use kafka on mobile devices yet out of the box.

关于您的问题,您是否已经尝试排除文件的全名?

Regarding you question, did you already try to exclude the full name of the file?

exclude 'akka-actor_2.10-2.3.7.jar'

这篇关于在 APK reference.conf 中复制的重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆