tony19 / logback-android

📄The reliable, generic, fast and flexible logging framework for Android
Apache License 2.0
1.2k stars 172 forks source link

Error dalvik from duplicate jar because of "logback-android-classic" #67

Closed SoulGoodMan closed 10 years ago

SoulGoodMan commented 10 years ago

I'm sorry to disturb you but I ran into a issue with the dependency "logback-android-classic" about duplication jar's and I don"t really know how to solve it. I'm working on Android version 4.4.2.

I got this message error : trouble processing "javax/xml/parsers/DocumentBuilder.class": and also this one : Conversion to Dalvik format failed with error 1

My pom.xml :

<dependencies>
        <dependency>
            <groupId>com.github.tony19</groupId>
            <artifactId>logback-android-core</artifactId>
            <version>1.1.1-2</version>
        </dependency>
        <dependency>
            <groupId>com.github.tony19</groupId>
            <artifactId>logback-android-classic</artifactId>
            <version>1.1.1-2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
        </dependency>
        <dependency>
            <groupId>com.mashape.unirest</groupId>
            <artifactId>unirest-java</artifactId>
            <version>1.3.8</version>
        </dependency>
</dependencies>

I tried to exclude the jars which cause this issue but this didn't solve it.

Thanks you and sorry for my bad english.

tony19 commented 10 years ago

I tried adding those dependencies to a sample project, but I couldn't reproduce the error (see below). Please provide a sample project that demonstrates the problem (you can copy and paste here if needed).

My test pom:

<!-- project generated from android-archetypes -->

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>your.company</groupId>
        <artifactId>my-android-application</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>apk</packaging>
        <name>my-android-application</name>

        <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <platform.version>4.1.1.4 </platform.version>
                <android.plugin.version>3.8.2</android.plugin.version>
        </properties>

        <dependencies>
                <dependency>
                        <groupId>com.google.android</groupId>
                        <artifactId>android</artifactId>
                        <version>${platform.version}</version>
                        <scope>provided</scope>
                </dependency>

        <dependency>
            <groupId>com.github.tony19</groupId>
            <artifactId>logback-android-core</artifactId>
            <version>1.1.1-2</version>
        </dependency>
        <dependency>
            <groupId>com.github.tony19</groupId>
            <artifactId>logback-android-classic</artifactId>
            <version>1.1.1-2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
        </dependency>
        <dependency>
            <groupId>com.mashape.unirest</groupId>
            <artifactId>unirest-java</artifactId>
            <version>1.3.8</version>
        </dependency>

        </dependencies>
        <build>
                <finalName>${project.artifactId}</finalName>
                <pluginManagement>
                        <plugins>
                                <plugin>
                                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                                        <artifactId>android-maven-plugin</artifactId>
                                        <version>${android.plugin.version}</version>
                                        <extensions>true</extensions>
                                </plugin>
                        </plugins>
                </pluginManagement>
                <plugins>
                        <plugin>
                                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                                <artifactId>android-maven-plugin</artifactId>
                                <configuration>
                                        <sdk>
                                                <platform>16</platform>
                                        </sdk>
                                                                        </configuration>
                        </plugin>
                </plugins>
        </build>
</project>

Build output:

$ mvn clean package
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my-android-application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-android-application ---
[INFO] Deleting /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target
[INFO] 
[INFO] --- android-maven-plugin:3.8.2:generate-sources (default-generate-sources) @ my-android-application ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[INFO] /Users/tony/Developer/tools/android-sdk-macosx/build-tools/19.0.0/aapt [package, -f, --no-crunch, -I, /Users/tony/Developer/tools/android-sdk-macosx/platforms/android-16/android.jar, -M, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/AndroidManifest.xml, -S, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/res, -A, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/generated-sources/combined-assets/assets, -m, -J, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/generated-sources/r, --output-text-symbols, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target, --auto-add-overlay]
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ my-android-application ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/src/main/resources
[INFO] skip non existing resourceDirectory /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] 
[INFO] --- android-maven-plugin:3.8.2:consume-aar (default-consume-aar) @ my-android-application ---
[INFO] Extracting classes for all aar dependencies
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ my-android-application ---
[INFO] Compiling 3 source files to /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/classes
[INFO] 
[INFO] --- android-maven-plugin:3.8.2:proguard (default-proguard) @ my-android-application ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ my-android-application ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ my-android-application ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12:test (default-test) @ my-android-application ---
[INFO] No tests to run.
[INFO] Surefire report directory: /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- android-maven-plugin:3.8.2:emma (default-emma) @ my-android-application ---
[INFO] 
[INFO] --- android-maven-plugin:3.8.2:dex (default-dex) @ my-android-application ---
[INFO] /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java [-Xmx1024M, -jar, /Users/tony/Developer/tools/android-sdk-macosx/build-tools/19.0.0/lib/dx.jar, --dex, --output=/Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/classes.dex, /Users/tony/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar, /Users/tony/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, /Users/tony/.m2/repository/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar, /Users/tony/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.3.2/httpcore-nio-4.3.2.jar, /Users/tony/.m2/repository/com/github/tony19/logback-android-classic/1.1.1-2/logback-android-classic-1.1.1-2.jar, /Users/tony/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.0.1/httpasyncclient-4.0.1.jar, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/classes, /Users/tony/.m2/repository/org/apache/httpcomponents/httpmime/4.3.2/httpmime-4.3.2.jar, /Users/tony/.m2/repository/com/mashape/unirest/unirest-java/1.3.8/unirest-java-1.3.8.jar, /Users/tony/.m2/repository/org/json/json/20080701/json-20080701.jar, /Users/tony/.m2/repository/com/github/tony19/logback-android-core/1.1.1-2/logback-android-core-1.1.1-2.jar, /Users/tony/.m2/repository/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar, /Users/tony/.m2/repository/com/github/tony19/apktool-lib/1.4.4-3/apktool-lib-1.4.4-3.jar, /Users/tony/.m2/repository/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar]
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$1) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$2) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$3) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$4) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$5) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class
[INFO] (org.apache.commons.logging.LogFactory$6) that doesn't come with an
[INFO] associated EnclosingMethod attribute. This class was probably produced by a
[INFO] compiler that did not target the modern .class file format. The recommended
[INFO] solution is to recompile the class from source, using an up-to-date compiler
[INFO] and without specifying any "-target" type options. The consequence of ignoring
[INFO] this warning is that reflective operations on this class will incorrectly
[INFO] indicate that it is *not* an inner class.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-android-application ---
[INFO] Building jar: /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/my-android-application.jar
[INFO] 
[INFO] --- android-maven-plugin:3.8.2:apk (default-apk) @ my-android-application ---
[INFO] Enabling debug build for apk.
[INFO] /Users/tony/Developer/tools/android-sdk-macosx/build-tools/19.0.0/aapt [package, -f, -M, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/AndroidManifest.xml, -S, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/res, --auto-add-overlay, -A, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/generated-sources/combined-assets/assets, -I, /Users/tony/Developer/tools/android-sdk-macosx/platforms/android-16/android.jar, -F, /Users/tony/Developer/src/logback-examples/basic-test/my-android-application/target/my-android-application.ap_, --debug-mode]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.125s
[INFO] Finished at: Thu Apr 10 22:53:39 CDT 2014
[INFO] Final Memory: 24M/439M
[INFO] ------------------------------------------------------------------------
SoulGoodMan commented 10 years ago

Thank you for your answer , I copied pasted your pom.xml but i ran into a another issue :

Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:consume-aar

And I solved it by change the android version of my projet from 4.4 to 2.3 and also change the maven version to 3.1.1. I couldn't find a right answer which can enlighten me about this second issue. Would you have an idea ?

Thank you for your help. ^^

tony19 commented 10 years ago

I don't believe this is a problem with logback-android but rather with the other plugins you're including in your project. For instance, the unirest-java plugin is causing the warnings emitted in the build.

The "lifecycle configuration" error is a problem with the m2e plugin for Eclipse. Unfortunately, I cannot help you without a sample project. What exactly are you trying to do?

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.