2015-03-30 26 views
6

Tôi đang làm việc với Ứng dụng nơi tôi đã bật runProguard đúng trong tệp build.gradle của ứng dụng của tôi. Khi tôi đi xây dựng apk đã ký, tôi nhận được cảnh báo và quá trình tạo không thành công.Phát hành tệp APK xây dựng

Log File:

Warning:com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Ascii: can't find referenced class javax.annotation.CheckReturnValue 
Warning:com.google.common.base.CaseFormat$StringConverter: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.CharMatcher: can't find referenced class javax.annotation.CheckReturnValue 
Warning:com.google.common.base.Converter: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Converter$ConverterComposition: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Converter$FunctionBasedConverter: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Converter$ReverseConverter: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Defaults: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Enums$StringConverter: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Equivalence: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Equivalence$EquivalentToPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Equivalence$Wrapper: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.FinalizableReferenceQueue$FinalizerLoader: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Function: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.FunctionalEquivalence: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$ConstantFunction: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$ForMapWithDefault: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$FunctionComposition: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$FunctionForMapNoDefault: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$IdentityFunction: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$PredicateFunction: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Functions$SupplierFunction: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Joiner: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Joiner: can't find referenced class javax.annotation.CheckReturnValue 
Warning:com.google.common.base.Joiner$1: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Joiner$MapJoiner: can't find referenced class javax.annotation.CheckReturnValue 
Warning:com.google.common.base.MoreObjects: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.MoreObjects$ToStringHelper: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Objects: can't find referenced class javax.annotation.CheckReturnValue 
Warning:com.google.common.base.Objects: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Objects$ToStringHelper: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Optional: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.PairwiseEquivalence: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Preconditions: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$AndPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$AssignableFromPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$CompositionPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$ContainsPatternPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$InPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$InstanceOfPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$IsEqualToPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$NotPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$ObjectPredicate$1: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$ObjectPredicate$2: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$ObjectPredicate$3: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$ObjectPredicate$4: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Predicates$OrPredicate: can't find referenced class javax.annotation.Nullable 
Warning:com.google.common.base.Present: can't find referenced class javax.annotation.Nullable 

build.gradle

apply plugin: 'com.android.application' 

android { 

    signingConfigs { 

    } 
    compileSdkVersion 21 

    buildToolsVersion '20.0.0' 

    defaultConfig { 

     minSdkVersion 15 

     targetSdkVersion 21 

     versionCode 1 

     versionName '1.0' 

    } 
    buildTypes { 

     release { 

      runProguard true 

      proguardFiles getDefaultProguardFile('proguard-android.txt'), 

'proguard-rules.pro' 
     } 

    } 
    productFlavors { 

    } 
     packagingOptions { 

      exclude 'META-INF/LICENSE.txt' 

      exclude 'META-INF/NOTICE.txt' 
     } 

} 

dependencies { 

    compile fileTree(dir: 'libs', include: ['*.jar']) 

    compile 'com.google.guava:guava:18.0' 

    compile 'com.google.code.gson:gson:2.3' 

    compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.2-beta+' 

    compile (group: 'com.microsoft.azure', name: 'azure-notifications-handler', version: '1.0.1', ext: 'jar') 

    compile project(':library') 

    compile project(':StyleableDateTimePicker-master') 

    compile 'com.facebook.android:facebook-android-sdk:3.23.+' 

    compile 'com.android.support:support-v4:22.0.0+' 

    compile 'com.android.support:appcompat-v7:22.0.0' 

    compile 'com.google.android.gms:play-services:6.5.87' 

    compile 'com.github.navasmdc:MaterialDesign:[email protected]' 

    compile 'com.android.support:recyclerview-v7:21.0.0' 

    compile 'com.android.support:cardview-v7:21.0.+' 

    compile 'com.melnykov:floatingactionbutton:1.1.0' 

    compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:[email protected]' 

    compile 'de.hdodenhof:circleimageview:1.2.2' 

    compile 'com.github.alamkanak:android-week-view:1.2.1' 

    compile('ch.acra:acra:4.5.0') { 

     exclude group: 'org.json' 
    } 

    compile 'com.github.machinarius:preferencefragment:0.1.1' 

} 
+0

Đăng build.gradle –

+1

Tôi đã giải quyết vấn đề này. – vickyVick

+1

Điều đó tuyệt vời :) bạn có thể xóa bài đăng hoặc câu trả lời công khai của mình cho người khác –

Trả lời

-9

Bạn không thể sử dụng Proguard nữa, bạn cần sử dụng

minifyEnabled false 
+2

Tôi giải quyết vấn đề này bằng cách sử dụng runProgurad đúng, không cần phải sử dụng minifyEnabled đúng – vickyVick

+0

ok, tôi đã thấy trong tài liệu, whe sử dụng gradle 1. +, sử dụng minifyEnable, thas giải quyết vấn đề trong phiên bản hiện tại android studio – gmendes

+0

vô hiệu hóa proguard không phải là một giải pháp –

6

Tôi nghĩ rằng cuối cùng tôi figured này một ra!

phụ thuộc gradle:

dependencies { 
    ... 
    compile 'com.google.guava:guava:18.0' 
    /* Required for using guava with proguard */ 
    compile 'javax.annotation:jsr250-api:1.0' 
} 

Xây thêm cho cấu hình Proguard tôi:

##-------------Begin Settings For Guava ------------------------------------------------------------ 
#https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-guava.pro 
# Configuration for Guava 
# 
# disagrees with instructions provided by Guava project: https://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava 
# 
# works if you add the following line to the Gradle dependencies 
# 
# provided 'javax.annotation:jsr250-api:1.0' 
-keep class com.google.common.io.Resources { 
    public static <methods>; 
} 
-keep class com.google.common.collect.Lists { 
    public static ** reverse(**); 
} 
-keep class com.google.common.base.Charsets { 
    public static <fields>; 
} 

-keep class com.google.common.base.Joiner { 
    public static Joiner on(String); 
    public ** join(...); 
} 

-keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry 
-keep class com.google.common.cache.LocalCache$ReferenceEntry 

-dontwarn sun.misc.Unsafe 
-dontwarn javax.annotation.** 

##-------------End Settings For Guava -------------------------------------------------------------- 

Liên kết đó đã giúp tôi

Các vấn đề liên quan