Skip to content

Android build is failed after set the enableProguardInReleaseBuilds to true #21638

@hamidhadi

Description

@hamidhadi

Environment

React Native Environment Info:
Binaries:
Node: 8.10.0
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.7.0
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3
API Levels: 17, 20, 21, 23, 25, 26, 27
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.1 => 0.57.1
npmGlobalPackages:
react-native-git-upgrade: 0.2.7

Description

I want to use ProGuard in my project so I enabled it by setting enableProguardInReleaseBuilds to true in build.gradle.
After trying to run assembleRelease task on AndroidStudio I get this error

Note: there were 11 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Initializing...
Note: the configuration refers to the unknown class 'com.facebook.react.ReactInstanceManagerImpl'
Note: the configuration refers to the unknown class 'com.facebook.react.XReactInstanceManagerImpl'
Note: the configuration refers to the unknown class 'com.google.android.gms.common.api.internal.BasePendingResult.ReleasableResultGuardian'
Note: the configuration refers to the unknown class 'com.facebook.react.uimanager.UIProp'
Note: the configuration refers to the unknown class 'sun.misc.Unsafe'
Note: the configuration refers to the unknown class 'com.google.android.gms.common.internal.safeparcel.SafeParcelable'
Warning: com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactoryImpl: can't find superclass or interface com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedImageFactoryImpl: can't find superclass or interface com.facebook.imagepipeline.animated.factory.AnimatedImageFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedImageFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedImageFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedImageFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedDrawableFactory
Warning: com.facebook.imagepipeline.animated.factory.AnimatedImageFactoryImpl: can't find referenced class com.facebook.imagepipeline.animated.factory.AnimatedImageFactory
Warning: com.facebook.imagepipeline.nativecode.StaticWebpNativeLoader: can't find referenced class com.facebook.common.soloader.SoLoaderShim
Warning: com.facebook.imagepipeline.nativecode.StaticWebpNativeLoader: can't find referenced class com.facebook.common.soloader.SoLoaderShim

and at the end I get this error

Note: there were 6 references to unknown classes.
      You should check your configuration for typos.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 1 references to unknown class members.
      You should check your configuration for typos.
Note: there were 817 unkept descriptor classes in kept class members.
      You should consider explicitly keeping the mentioned classes
      (using '-keep').
      (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 18 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 13 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
Thread(Tasks limiter_1): destruction
:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4m 46s
280 actionable tasks: 8 executed, 272 up-to-date
12:33:16: Task execution finished 'assembleRelease'.

Here is my proguard-rules:

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-dontwarn com.microsoft.appcenter.push.** 

Reproducible Demo

I just set enableProguardInReleaseBuilds to true and this issue appears.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions