草庐IT

项目依赖中jar的Android "has already been added to output"错误

coder 2023-11-19 原文

我有一个 Android 项目,它使用 gradle 和另一个项目作为依赖项。依赖项目有一个库 jar。当我尝试编译项目库时,编译了两次,但出现错误: 错误:Class no.nordicsemi.android.log.LogContract.Application 已经添加到输出中。请删除重复的副本。

这是包含相关文件的文件夹结构:

>ProjectRoot
  >dFULibrary
    >libs
      -nrf-logger-v2.0.jar
    -build.gradle
  >Logger
    -build.gradle

这是 dFULibrary 依赖的 build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "no.nordicsemi.android.dfu"
        minSdkVersion 18
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:+'
    compile files('libs/nrf-logger-v2.0.jar')
}

这是 Logger 的 build.gradle(主要项目):

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.4'
    }
}

apply plugin: 'com.android.application'

    android {

    compileSdkVersion 20
    buildToolsVersion '20'

    sourceSets {
        main {
            java.srcDirs "src/main/java"
            res.srcDirs "src/main/res"
            assets.srcDirs = ['assets']
        }
        androidTest.setRoot('tests')
        androidTest.java.srcDirs = ['tests/src']

    }
    dexOptions {
        preDexLibraries = false
    }
}

dependencies {
    compile 'com.android.support:support-v4:+'
    compile project':dFULibrary')
}

no.nordicsemi.android.log.LogContract.Application class is found of nrf-logger-v2.0.jar 为什么它被包含两次,我如何确保它没有被包含?

添加

这是 ../gradlew dependencies 返回的内容:

_debugApk - ## Internal use, do not manually configure ##
\--- project :dFULibrary

_debugCompile - ## Internal use, do not manually configure ##
+--- project :dFULibrary
\--- com.android.support:support-v4:+ -> 21.0.2
     \--- com.android.support:support-annotations:21.0.2

_releaseApk - ## Internal use, do not manually configure ##
\--- project :dFULibrary

_releaseCompile - ## Internal use, do not manually configure ##
+--- project :dFULibrary
\--- com.android.support:support-v4:+ -> 21.0.2
     \--- com.android.support:support-annotations:21.0.2

androidJacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.7.1.201405082137 FAILED

androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.7.1.201405082137 FAILED


compile - Classpath for compiling the main sources.
\--- project :dFULibrary


provided - Classpath for only compiling the main sources.
\--- com.android.support:support-v4:+ -> 21.0.2
     \--- com.android.support:support-annotations:21.0.2

我删除了所有没有依赖关系的行。

编辑 #2 来自 ./gradlew androidDependencies 的输出

:DFULibrary:androidDependencies
debug
\--- LOCAL: nrf-logger-v2.0.jar

debugTest
+--- LOCAL: nrf-logger-v2.0.jar
\--- debug
     \--- LOCAL: nrf-logger-v2.0.jar

release
\--- LOCAL: nrf-logger-v2.0.jar
:nRFToolbox:androidDependencies
debug
+--- LOCAL: achartengine-1.1.0.jar
\--- nrfToolbox:DFULibrary:unspecified
     \--- LOCAL: nrf-logger-v2.0.jar

debugTest
No dependencies

release
+--- LOCAL: achartengine-1.1.0.jar
\--- nrfToolbox:DFULibrary:unspecified
     \--- LOCAL: nrf-logger-v2.0.jar

BUILD SUCCESSFUL

最佳答案

宾果游戏,找到了。

只是很有趣,我试图找到 your project在互联网上。并开始我的调查.... :)。

问题隐藏在 nrf-logger-v2.0.jar 中。它包含.java.class 文件。 解决方案是从中删除所有 .java 文件。

我做了那个 Total Commander。步骤:

  • nrf-logger-v2.0.jar重命名为nrf-logger-v2.0.zip;
  • 进入并删除所有 .java 文件;
  • 将文件重命名回jar
  • gradlew clean buildBuild-Rebuild project at Android Studio

关于项目依赖中jar的Android "has already been added to output"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27242331/

有关项目依赖中jar的Android "has already been added to output"错误的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  4. ruby - 如何在 buildr 项目中使用 Ruby 代码? - 2

    如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby​​

  5. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  6. ruby-on-rails - 项目升级后 Pow 不会更改 ruby​​ 版本 - 2

    我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby​​版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby​​版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘

  7. ruby-on-rails - 新 Rails 项目 : 'bundle install' can't install rails in gemfile - 2

    我已经像这样安装了一个新的Rails项目:$railsnewsite它执行并到达:bundleinstall但是当它似乎尝试安装依赖项时我得到了这个错误Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcheckingforlibkern/OSAtomic.h...yescreatingMakefilemake"DESTDIR="cleanmake"DESTDIR="

  8. ruby-on-rails - 在 ruby​​ .gemspec 文件中,如何指定依赖项的多个版本? - 2

    我正在尝试修改当前依赖于定义为activeresource的gem:s.add_dependency"activeresource","~>3.0"为了让gem与Rails4一起工作,我需要扩展依赖关系以与activeresource的版本3或4一起工作。我不想简单地添加以下内容,因为它可能会在以后引起问题:s.add_dependency"activeresource",">=3.0"有没有办法指定可接受版本的列表?~>3.0还是~>4.0? 最佳答案 根据thedocumentation,如果你想要3到4之间的所有版本,你可以这

  9. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  10. ruby - RuntimeError(自动加载常量 Apps 多线程时检测到循环依赖 - 2

    我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("

随机推荐