---
title: "解决编译Android 4.1.2 Error 41错误"
author: "melord"
date: "2013-04-12T09:34:46Z"
tags: []
categories: ["移动开发"]
slug: "android-4-1-2-error-41"
draft: false
lastmod: "2013-04-12T09:34:46Z"
id: 1846158
url: "https://melord.iteye.com/blog/1846158"
---

2.3/3.0/3.1/3.2/4.0,  4.2都能编译通过就是4.1.2编译不通过,憋屈吗?

编译时的错误信息如下:

external/guava/guava/src/com/google/common/collect/Maps.java:542: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap&lt;K,V&gt; conforms to java.util.SortedMap&lt;K,V&gt;

found   : &lt;K,V&gt;java.util.TreeMap&lt;K,V&gt;

required: java.util.SortedMap&lt;K,V&gt;

    SortedMap&lt;K, V&gt; onlyOnLeft = Maps.newTreeMap(comparator);

                                                ^

external/guava/guava/src/com/google/common/collect/Maps.java:543: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap&lt;K,V&gt; conforms to java.util.SortedMap&lt;K,V&gt;

found   : &lt;K,V&gt;java.util.TreeMap&lt;K,V&gt;

required: java.util.SortedMap&lt;K,V&gt;

    SortedMap&lt;K, V&gt; onlyOnRight = Maps.newTreeMap(comparator);

                                                 ^

external/guava/guava/src/com/google/common/collect/Maps.java:545: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap&lt;K,V&gt; conforms to java.util.SortedMap&lt;K,V&gt;

found   : &lt;K,V&gt;java.util.TreeMap&lt;K,V&gt;

required: java.util.SortedMap&lt;K,V&gt;

    SortedMap&lt;K, V&gt; onBoth = Maps.newTreeMap(comparator);

                                            ^

external/guava/guava/src/com/google/common/collect/Maps.java:547: incompatible types; no instance(s) of type variable(s) K,V exist so that java.util.TreeMap&lt;K,V&gt; conforms to java.util.SortedMap&lt;K,com.google.common.collect.MapDifference.ValueDifference&lt;V&gt;&gt;

found   : &lt;K,V&gt;java.util.TreeMap&lt;K,V&gt;

required: java.util.SortedMap&lt;K,com.google.common.collect.MapDifference.ValueDifference&lt;V&gt;&gt;

        Maps.newTreeMap(comparator);

                       ^

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

4 errors

make: \*\** \[out/host/common/obj/JAVA\_LIBRARIES/guavalib\_intermediates/javalib.jar] Error 41

编译环境:

Ubuntu 11.10

java version "1.6.0\_26"  
Java(TM) SE Runtime Environment (build 1.6.0\_26-b03)  
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

解决方法:

 /home/melord/codebase/4.1.2/external/guava/guava/src/com/google/common/collect/Maps.java

将

Line 228 :public static &lt;C, K extends C, V&gt; TreeMap&lt;K, V&gt; newTreeMap(

Line 229      @Nullable Comparator&lt;C&gt; comparator) {

注释掉，换成

    public static &lt;K, V&gt; TreeMap&lt;K, V&gt; newTreeMap(

        @Nullable Comparator&lt;? super K&gt; comparator) {  
参考:

https://groups.google.com/forum/?fromgroups=#!topic/android-building/BFr5bmQzhHw

https://github.com/CyanogenMod/android\_external\_guava/commit/c8b97210aa31c9b80b5fd136d8617ebe4e731e09