Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue building apk file

Tags:

android

gradle

I am working with an Application where I enabled runProguard true in my build.gradle file of my app. When I go for building signed apk I am getting warnings and build process failed.

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:1.+@aar'

    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:1.1.0@aar'

    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'

}
like image 644
vickyVick Avatar asked Mar 30 '15 09:03

vickyVick


People also ask

Why is my APK file not installing?

Why APK won't install on Android? First, make sure that your Android version supports the APK version you want to install. Also, remove the Play Store version of the app before installing an APK. Don't forget to check the storage space and permission to install apps from unknown sources.

How do I make an APK file?

To generate a signed APK file, open the Build menu from the toolbar and select Generate Signed Bundle/APK. This opens up a screen where you have to select between creating an Android App Bundle and creating an APK file. Check the APK radio button and proceed to the next window.

What is build APK?

The Android build system compiles app resources and source code, and packages them into APKs or Android App Bundles that you can test, deploy, sign, and distribute.


1 Answers

I think I finally figured this one out!

gradle dependency:

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

Additions to my proguard configuration:

##-------------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 --------------------------------------------------------------

Links Which Helped Me

  • https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-guava.pro
  • https://github.com/krschultz/android-proguard-snippets/issues/53
like image 139
Jon Avatar answered Nov 15 '22 10:11

Jon