解决编译Android 4.1.2 Error 41错误

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<K,V> conforms to java.util.SortedMap<K,V>
found   : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,V>
    SortedMap<K, V> 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<K,V> conforms to java.util.SortedMap<K,V>
found   : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,V>
    SortedMap<K, V> 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<K,V> conforms to java.util.SortedMap<K,V>
found   : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,V>
    SortedMap<K, V> 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<K,V> conforms to java.util.SortedMap<K,com.google.common.collect.MapDifference.ValueDifference<V>>
found   : <K,V>java.util.TreeMap<K,V>
required: java.util.SortedMap<K,com.google.common.collect.MapDifference.ValueDifference<V>>
        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 <C, K extends C, V> TreeMap<K, V> newTreeMap(

Line 229      @Nullable Comparator<C> comparator) {

注释掉,换成

    public static <K, V> TreeMap<K, V> newTreeMap(

        @Nullable Comparator<? super K> comparator) {
参考:
https://groups.google.com/forum/?fromgroups=#!topic/android-building/BFr5bmQzhHw
https://github.com/CyanogenMod/android_external_guava/commit/c8b97210aa31c9b80b5fd136d8617ebe4e731e09

你可能感兴趣的:(android)