ANT
I'm using the following solution now:
I created a custom_rules.xml with the followin targets to copy files in META-INF/services into the unaligned and unsigned apk.
<target name="-post-package" depends="-custom-copy" />
<target name="-copy-custom">
<zip destfile="${out.packaged.file}"
update="true"
basedir="${source.absolute.dir}"
includes="${custom.copy}" />
</target>
And in ant.properties I added the line
custom.copy=META-INF/services/**
Now I just have to copy relevant files from libraries to the META-INF/services-folder of my own project to include them in the apk. This gives me full control over which classes to be loaded by ServiceLoader.
Remark: Currently I only load implementations that are included in external Java-SE-jars this way. Obfuscation may have to be configured if the implementations are in an android-project.
ECLIPSE-PLUGIN
Using the eclipse-plugin, there's no workaround like in ANT. The problem is the ExportHelper (line 405) which just igores everything in META-INF
folders.
Android-Studio/GRADLE
According to this Bug you may define a META-INF
-directory in your main project and this will be packaged into your apk. META-INF
-folders of libraries are excluded, so that you are forced to specify the implementations you want to use in your own project (I think this is the intention of it).