Error during compilation of the android project, as well as during the creation of the apk file using ProGuard

Installed in the Google play services lib application. Everything started and displayed, but after creating an apk for publishing to Intellij IDEA, I received an error that the file is not optimized. Googled, found that you need to use ProGuard. Put a daw during the creation of the file, and spilled errors.

Below are copy-pastes from the log.

Error:ProGuard: [MyApplication] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager Error:ProGuard: [MyApplication] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle Error:ProGuard: [MyApplication] Warning: com.google.android.gms.common.SupportErrorDialogFragment: can't find referenced method 'void setShowsDialog(boolean)' in class com.google.android.gms.common.SupportErrorDialogFragment Error:ProGuard: [MyApplication] Warning: com.google.android.gms.common.api.d: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class com.google.android.gms.common.api.d Error:ProGuard: [MyApplication] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'android.app.Fragment getParentFragment()' in class android.app.Fragment Error:ProGuard: [MyApplication] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'boolean getUserVisibleHint()' in class android.app.Fragment Error:ProGuard: [MyApplication] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'void setUserVisibleHint(boolean)' in class android.app.Fragment Error:ProGuard: [MyApplication] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View Error:ProGuard: [MyApplication] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'void removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener)' in class android.view.ViewTreeObserver Error:ProGuard: [MyApplication] Warning: com.google.android.gms.internal.ed: can't find referenced method 'boolean isActiveNetworkMetered()' in class android.net.ConnectivityManager Error:ProGuard: [MyApplication] Warning: com.google.android.gms.internal.es: can't find referenced method 'java.lang.String getDefaultUserAgent(android.content.Context)' in class android.webkit.WebSettings Error:ProGuard: [MyApplication] Warning: com.google.android.gms.internal.es: can't find referenced method 'void setMediaPlaybackRequiresUserGesture(boolean)' in class android.webkit.WebSettings Error:ProGuard: [MyApplication] You should check if you need to specify additional program jars. Error:ProGuard: [MyApplication] Warning: there were 9 unresolved references to classes or interfaces. Error:ProGuard: [MyApplication] You may need to specify additional library jars (using '-libraryjars'). Error:ProGuard: [MyApplication] Warning: there were 10 unresolved references to program class members. Error:ProGuard: [MyApplication] Your input classes appear to be inconsistent. Error:ProGuard: [MyApplication] You may need to recompile them and try again. Error:ProGuard: [MyApplication] Alternatively, you may have to specify the option Error:ProGuard: [MyApplication] '-dontskipnonpubliclibraryclassmembers'. Error:ProGuard: [MyApplication] java.io.IOException: Please correct the above warnings first. Error:ProGuard: [MyApplication] at proguard.Initializer.execute(Initializer.java:321) Error:ProGuard: [MyApplication] at proguard.ProGuard.initialize(ProGuard.java:211) Error:ProGuard: [MyApplication] at proguard.ProGuard.execute(ProGuard.java:86) Error:ProGuard: [MyApplication] at proguard.ProGuard.main(ProGuard.java:492) 

    2 answers 2

    no need to use proguard
    my telepathic abilities suggest that you have not compressed the agro-industrial complex zip-ohm.
    I had such a problem, IDEA showed a worning about this. Doesn't it show you?
    zipalign.exe should be located along the path <path_to_android_sdk> \ tools \ zipalign.exe

    • Showed a warning. yes, it was about zipalign. metalurgys, can you tell me in details about the process of adding a key, compressing and leveling with a proguard? align needed for alpha testing. Google Play does not accept without it. PS: Thank you for your previous response. I can’t put a finger up, because I have not enough points. But it seemed to reward. - web_alex 4:04 pm
    • Zipalign.exe found in the <Android> \ sdk \ build-tools \ 20.0.0 folder copied it to \ sdk \ tools \ tomorrow I will try to start the alignment of the arch file. I figured it out, but there is no description of proguard. - web_alex
    • why do you need ProGuard? This is not a necessary thing! If you do not know how to use it, then you do not need 99%! - Vladyslav Matviienko
    • Yeah, yes, the problem is in zipalign, which in the new SDK releases "sat" in the SDK/build-tools directory, and IDEA expects it in the SDK/tools - transfer it and it will work. - Barmaley

    First of all, IntelliJIDEA is, in fact, an outdated Android development environment. If only because Google has developed its own IDE based on it - Android Studio. By default, Google's IDE uses the Gradle project builder, with which ProGuard is fairly well integrated, which is not the case with the earlier ANT collector.

    In order to build a project and apply ProGuard to it, as mentioned above, it will really be necessary to assemble, sign (using JarSigner), optimize (using ZipAlign) and then apply ProGuard. Of course, all this is done automatically. If there are no problems with the first two operations (the output is an APK suitable for the market), then there may indeed be problems with ProGuard.

    To use it, a proguard-android.txt file is needed , filled with default configurations and located in the <Android SDK>/tools/proguard . Its contents can be found, for example, here . Without it, ProGuard just won't work. In the case of Gradle (and this is the best case), it also appears that you can add additional settings by placing them in the proguard-rules.pro file with the project. Usually, there are added settings that indicate which specific classes / methods to leave unchanged.

    Next, you will need to add configurations related to ProGuard in the Gradle build config file:

     android { ... defaultConfig { ... } buildTypes { release { runProguard true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } 
    • all clear. thank. I decided to turn off proGuard. - web_alex