Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shrinkResources true can't be used on Instant Apps Feature?

When I try to shrink my Feature APK size, I use shrinkResources true in my feature Build Gradle. However it complaints Error:Resource shrinker cannot be used for libraries.

This article ask us to use it https://medium.com/jet-stories/make-your-app-instant-33855ab5d02b

Did I do something wrong or is this really not supported by Instant Apps?

like image 734
Elye Avatar asked Sep 14 '17 13:09

Elye


2 Answers

From what I understand from the article (I've just read it quickly, still pending in my reading list), shrinkResources true is only needed to reduce APK size by removing unused resources, but it is not a formal requirement of Instant Apps. I guess the toolchain cannot decide if a resource will be unused in a library, as final APK is not built.

So, if there are no unused resources in your project, should not be a problem and could be removed.

Then, there is one thing that maybe is wrong in your project (without having tried Instant Apps by myself, just read and saw Google IO talks): from what I understand, all the modules of an instant app are APKs, not libraries. So, if you apply the shrinkResources true to the APKs, you should be good to go. If you have libraries in your project that are used to assemble the final APK modules, then remove shrinkResources true there, and just leave it in the modules.

like image 55
Xavier Rubio Jansana Avatar answered Sep 18 '22 20:09

Xavier Rubio Jansana


I think this is not and AndroidStudio bug, but a Gradle bug. I'm trying to build with Jenkins, with an updated version of Gradle (previousely used com.android.tools.build:gradle:2.2.3, upgraded it to com.android.tools.build:gradle:3.0.1) and I still get the error

"> Resource shrinker cannot be used for libraries."

like image 34
Santacrab Avatar answered Sep 18 '22 20:09

Santacrab