buck icon indicating copy to clipboard operation
buck copied to clipboard

customize classes in secondary dex file

Open byronwind opened this issue 12 years ago • 6 comments

In the android_binary rule we can define use_split_dex = True and primary_dex_patterns.

Is there any way I can define the secondary dex patterns other than primary dex patterns?

byronwind avatar Sep 26 '14 14:09 byronwind

Can you explain why you want to do this?

dreiss avatar Sep 26 '14 17:09 dreiss

Thanks your reply @dreiss.

We have a very large project. At present, we build the whole project with ant. In the build.xml,we hacked the dex-helper macro for generating secondary dex file.

Now I am try build the project with Buck. We have many packages and classes,and also third-part libraries. So I want to define secondary dex patterns, because in the secondary dex file, there is less classes than primary dex file.

byronwind avatar Sep 27 '14 02:09 byronwind

@dreiss This feature is important for APPs which download some dex files from internet. It could make some seperated features in seperated dex file, and then download it from internet when customer actually use it.

simpleton avatar Sep 28 '14 17:09 simpleton

@byronwind, I think I understand. You want classes to be forced into the primary dex by default, and have patterns to specify what is allowed to go into the secondary dex?

I think that is possible, but I would not recommend it. Our only supported use case for secondary dex files right now is exopackage (see http://facebook.github.io/buck/article/exopackage.html). In exopackae builds, only the bare minimum of bootstrap code should be in the primary dex, and the vast bulk of your application should be in secondary dex files.

dreiss avatar Sep 29 '14 19:09 dreiss

@simpleton, in that case, you are probably better off using the techniques described in http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html

dreiss avatar Sep 29 '14 19:09 dreiss

@dreiss, I got it. I think I can customize it on my own. Thanks again.

byronwind avatar Sep 30 '14 11:09 byronwind