Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to react-native 0.56 breaks Fresco's proguard config #2181

Closed
luisnaranjo733 opened this issue Aug 9, 2018 · 5 comments
Closed
Labels

Comments

@luisnaranjo733
Copy link

We use GitHub Issues for bugs.

If you have a non-bug question, please ask on Stack Overflow: http://stackoverflow.com/questions/tagged/fresco

--- Please use this template, and delete everything above this line before submitting your issue ---

Description

I migrated from 0.55.4 to 0.56.0 and now ProGuard is failing my Android build. I think Fresco is getting one of its dependencies eliminated by ProGuard, so we need to write a keep line to prevent this. It would be nice to add this to the changelog of 0.56. Or alternatively, should react-native-upgrade do this automatically? I looked at your proguard template files, and they don't seem to have any lines that would fix this. I guess this may have just slipped under the radar.

10:16:29.581 [ERROR] [system.err] Warning: com.facebook.imagepipeline.nativecode.StaticWebpNativeLoader: can't find referenced class com.facebook.common.soloader.SoLoaderShim
10:16:29.581 [ERROR] [system.err] Warning: com.facebook.imagepipeline.nativecode.StaticWebpNativeLoader: can't find referenced class com.facebook.common.soloader.SoLoaderShim
10:16:31.897 [ERROR] [system.err] Warning: there were 2 unresolved references to classes or interfaces

Reproduction

Upgrade to rn 0.56, turn on proguard, and try to build the android project with Facebook's built in proguard template. Observe that the above class is not found by Fresco and fails the build.

Solution

Someone needs to write a keep rule for this and either document it or make Fresco automatically share its proguard config

@luisnaranjo733
Copy link
Author

luisnaranjo733 commented Aug 9, 2018

Worth noting I'm on implementation 'com.facebook.fresco:webpsupport:1.3.0'.

I just upgraded to 1.10.0 to see what would happen and now I'm getting more ProGuard errors.

10:40:52.785 [ERROR] [system.err] Note: there were 23 duplicate class definitions.
10:40:52.785 [ERROR] [system.err] (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
10:40:52.955 [ERROR] [system.err] Warning: com.facebook.imagepipeline.bitmaps.HoneycombBitmapCreator: can't find referenced method 'void read(int,byte[],int,int)' in program class com.facebook.common.memory.PooledByteBuffer
10:40:52.957 [ERROR] [system.err] Warning: com.facebook.imagepipeline.cache.EncodedCountingMemoryCacheFactory: can't find referenced method 'CountingMemoryCache(com.facebook.imagepipeline.cache.ValueDescriptor,com.facebook.imagepipeline.cache.CountingMemoryCache$CacheTrimStrategy,com.facebook.common.internal.Supplier,com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory,boolean)' in program class com.facebook.imagepipeline.cache.CountingMemoryCache
10:40:52.957 [ERROR] [system.err] Warning: com.facebook.imagepipeline.cache.InstrumentedMemoryCache: can't find referenced method 'int removeAll(com.android.internal.util.Predicate)' in program class com.facebook.imagepipeline.cache.MemoryCache
10:40:52.957 [ERROR] [system.err] Warning: com.facebook.imagepipeline.cache.InstrumentedMemoryCache: can't find referenced method 'boolean contains(com.android.internal.util.Predicate)' in program class com.facebook.imagepipeline.cache.MemoryCache
10:40:52.958 [ERROR] [system.err] Warning: com.facebook.imagepipeline.core.ImagePipeline: can't find referenced method 'int removeAll(com.android.internal.util.Predicate)' in program class com.facebook.imagepipeline.cache.MemoryCache
10:40:52.958 [ERROR] [system.err] Warning: com.facebook.imagepipeline.core.ImagePipeline: can't find referenced method 'boolean contains(com.android.internal.util.Predicate)' in program class com.facebook.imagepipeline.cache.MemoryCache
10:40:52.959 [ERROR] [system.err] Warning: com.facebook.imagepipeline.core.ImagePipelineFactory: can't find referenced method 'com.android.internal.util.Predicate True()' in program class com.facebook.common.internal.AndroidPredicates
10:40:52.959 [ERROR] [system.err] Warning: com.facebook.imagepipeline.core.ImagePipelineFactory: can't find referenced method 'int removeAll(com.android.internal.util.Predicate)' in program class com.facebook.imagepipeline.cache.MemoryCache
10:40:52.959 [ERROR] [system.err] Warning: com.facebook.imagepipeline.core.ImagePipelineFactory: can't find referenced method 'com.facebook.imagepipeline.cache.CountingMemoryCache get(com.facebook.common.internal.Supplier,com.facebook.common.memory.MemoryTrimmableRegistry,com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory,boolean,com.facebook.imagepipeline.cache.CountingMemoryCache$CacheTrimStrategy)' in program class com.facebook.imagepipeline.cache.BitmapCountingMemoryCacheFactory
10:40:52.962 [ERROR] [system.err] Warning: com.facebook.imagepipeline.nativecode.ImagePipelineNativeLoader: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:52.962 [ERROR] [system.err] Warning: com.facebook.imagepipeline.platform.KitKatPurgeableDecoder: can't find referenced method 'void read(int,byte[],int,int)' in program class com.facebook.common.memory.PooledByteBuffer
10:40:52.968 [ERROR] [system.err] Warning: com.facebook.jni.Countable: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:52.968 [ERROR] [system.err] Warning: com.facebook.jni.CpuCapabilitiesJni: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:52.968 [ERROR] [system.err] Warning: com.facebook.jni.HybridData: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:52.968 [ERROR] [system.err] Warning: com.facebook.jni.ThreadScopeSupport: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:53.081 [ERROR] [system.err] Warning: com.facebook.yoga.YogaConfig: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:53.082 [ERROR] [system.err] Warning: com.facebook.yoga.YogaNode: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
10:40:55.173 [ERROR] [system.err] Warning: there were 17 unresolved references to program class members.
10:40:55.173 [ERROR] [system.err] Your input classes appear to be inconsistent.
10:40:55.173 [ERROR] [system.err] You may need to recompile the code.
10:40:55.173 [ERROR] [system.err] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:transformClassesAndResourcesWithProguardForInternalbetaDebug'.
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Job failed, see logs for details
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
10:40:55.177 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
10:40:55.178 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
10:40:55.178 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 57s

According to the Fresco docs, 1.9.0 and up ship with a built in proguard config that will be automatically applied. Is there something else I have to do in order to get the latest ProGuard config?

@luisnaranjo733
Copy link
Author

luisnaranjo733 commented Aug 10, 2018

So, I've realized this is partially my own fault:

I only had this line in my build.gradle

    implementation 'com.facebook.fresco:webpsupport:1.3.0'

and now I have

    implementation 'com.facebook.fresco:fresco:1.10.0'
    implementation 'com.facebook.fresco:webpsupport:1.10.0'

However, the issue is still present, just now there are only 6 warnings from proguard regarding SoLoader that aren't covered by the built in proguard config fresco is shipping automatically.

C:\project>gradlew assembleDebug --debug > output.txt
14:06:22.903 [ERROR] [system.err] Note: there were 23 duplicate class definitions.
14:06:22.903 [ERROR] [system.err]       (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
14:06:23.058 [ERROR] [system.err] Warning: com.facebook.jni.Countable: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
14:06:23.058 [ERROR] [system.err] Warning: com.facebook.jni.CpuCapabilitiesJni: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
14:06:23.058 [ERROR] [system.err] Warning: com.facebook.jni.HybridData: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
14:06:23.058 [ERROR] [system.err] Warning: com.facebook.jni.ThreadScopeSupport: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
14:06:23.097 [ERROR] [system.err] Warning: com.facebook.yoga.YogaConfig: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
14:06:23.097 [ERROR] [system.err] Warning: com.facebook.yoga.YogaNode: can't find referenced method 'void loadLibrary(java.lang.String)' in program class com.facebook.soloader.SoLoader
14:06:24.884 [ERROR] [system.err] Warning: there were 6 unresolved references to program class members.
14:06:24.884 [ERROR] [system.err]          Your input classes appear to be inconsistent.
14:06:24.885 [ERROR] [system.err]          You may need to recompile the code.
14:06:24.885 [ERROR] [system.err]          (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

@oprisnik
Copy link
Contributor

It looks like you're including SoLoader in both Fresco and React Native. I guess you have to exclude the dependency (com.facebook.soloader:soloader:...)

@luisnaranjo733
Copy link
Author

I ended up solving this by downgrading to Fresco 1.9

@oprisnik
Copy link
Contributor

Yes, you always have to use the same version as React Native as well. Glad you fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants