Answer the question
In order to leave comments, you need to log in
How to exclude classes from compiled dex file?
Good afternoon.
I will describe the situation.
It's no secret that Android has hidden classes that are not available from the Android SDK. Some of them are really better left untouched, and some can be very useful.
So. Let's say there is a hidden class com.android.internal.HiddenClass whose method signatures are different in API 14, API 16 and API 18.
This class can be accessed by playing around with the Android SDK, accessing the hidden classes (very long and tedious process).
I want to implement it differently - in the source code, make stub classes com.android.internal.HiddenClass, with the same method signature for different API levels, make HiddenClassWrapperVX, where X is the API level, and then remove com.android from the compiled file. internal.HiddenClass. I used to do it manually - I compiled the JAR for the module and removed the HiddenClass, after which all 3 files were included as libraries.
I have a project that has several modules - each module corresponds to an API level. Each of the modules has the mentioned com.android.internal.HiddenClass.
How can I compile the project so that the com.android.internal.HiddenClass classes are not processed by javac and dx? (although it can be excluded from dx only)
Because otherwise, an error occurs that there are several identical classes with a conflicting implementation.
Answer the question
In order to leave comments, you need to log in
After much thought, I came to this solution:
The project uses Gradle. In each module for different API levels (let's call them API modules), I created another submodule in which I took out this class. After that, I declared the API modules dependent on these modules (API 16 - the module depends on its internal module, API 18 - on its own, etc.), after which I declared these dependencies not as 'compile', but as 'provided' '. After that everything compiled smoothly.
An example can be viewed here (attention, do not use this library yet, it is not yet fully ready):
https://github.com/DrBreen/RemoteController
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question