Closed Unbrick closed 5 years ago
maybe the resource names were mangled by some obfuscator. check that the decompiled resources in the .apk.aar APK library produced by ':source' are valid. see: http://stackoverflow.com/questions/35240635/error-is-not-a-valid-resource-name-character
also, could this maybe be a bug in build tools? check this one: https://code.google.com/p/android/issues/detail?id=195443
Checked the source resource names for invalid characters like colons or spacing, they are all fine and valid. Additionally Gradle reports a space as invalid resource identifier which doesn't make any sense at all. Looks to me like a Gradle error.
i'm sorry i've no time to investigate, but sure looks intriguing. you can try downgrading build-tools maybe and see what happens.
Just thought a little bit about it...apktool is using a framework-res.apk do decompile resources afaik. Maybe we just could replace the one you are shipping and try another one. But i can't find it in your modified apktool version, could you give me a hand?
i'm not shipping a modded apktool. apktool provides its own framework which is based on AOSP and should work for all independent apps.
it is not enough when you want to process an app that came embedded in a OEM rom and uses the rom's private api extensions. for example: an OEM's stock FM radio app that uses a proprietary radio API designed and implemented by the OEM on their android.
dxp fully supports your frameworks:
the apktool tasks have framework propreties: https://github.com/DexPatcher/dexpatcher-gradle/blob/master/src/main/groovy/lanchon/dexpatcher/gradle/tasks/AbstractApktoolTask.groovy#L78-L80 the 'dir' variant just considers the path string as a dependency for auto rebuilding. the 'as input' considers the contents of the dir as a dependency. the 'as output' considers the contents of the dir to be produced/altered by the task. (apktool is quite nasty in its I/O definition of this dir.)
the apktool decode task has a framework tag: https://github.com/DexPatcher/dexpatcher-gradle/blob/master/src/main/groovy/lanchon/dexpatcher/gradle/tasks/DecodeApkTask.groovy#L45
the apktool task properties are defaulted from the apktool gradle extension object when they are created: https://github.com/DexPatcher/dexpatcher-gradle/blob/master/src/main/groovy/lanchon/dexpatcher/gradle/DexpatcherBasePlugin.groovy#L68-L73
the apktool gradle extension object can be accessed just like this but with the name 'apktool': https://github.com/DexPatcher/dexpatcher-gradle-samples/blob/master/patched-app/source/build.gradle#L21 several extension objects are not mentioned in the samples but are supported: https://github.com/DexPatcher/dexpatcher-gradle/tree/master/src/main/groovy/lanchon/dexpatcher/gradle/extensions
the properties of the apktool gradle extension object itself are defaulted from environment properties: https://github.com/DexPatcher/dexpatcher-gradle/blob/master/src/main/groovy/lanchon/dexpatcher/gradle/extensions/ApktoolExtension.groovy#L58-L60 one way to set the framework dir in the extension object is to set it by default from outside the VCS tree in 'local.properties' like this: https://github.com/DexPatcher/dexpatcher-gradle-samples/blob/master/patched-app/patched/build.gradle#L13-L15 except the entry is called 'dexpatcher.apktool.frameworkDir': https://github.com/DexPatcher/dexpatcher-gradle/blob/master/src/main/groovy/lanchon/dexpatcher/gradle/extensions/ApktoolExtension.groovy#L26
finally, this all happens for the base dexpatcher plugin. (you can use it to invoke it's subtools, such as apktool, without any of dexpatcher's opinionated ideas on build cycle.) when you use the 'apk-library' plugin, it creates and configures several tasks. the apktool decode task is configured to use a framework directory inside the build directory, so that builds are self- contained and don't depend on external state. this is done here:
https://github.com/DexPatcher/dexpatcher-gradle/blob/master/src/main/groovy/lanchon/dexpatcher/gradle/ApkLibraryPlugin.groovy#L81
you can simply clear that task property from your :source build script:
decodeApk.setFrameworkDirAsOutput = null
to use apktool's default framework dir. or set it back to the apktool extension's default value to make the previous default chain work. or set the task property directly to your chosen value.
Sorry to annoy you again but i encountered another issue: (in a different project than last time)
My Project setup is the following: I'm trying to patch a normal apk without any additional resources patched in, all resources are taken from the :source project.
While doing a gradle build, gradle throws me the following error:
:patched:mergeDebugResources C:\Users\Admin\StudioProjects\Patched\patched\build\intermediates\exploded-aar\Patched\source\unspecified\res\values\ids.xml: Error: ' ' is not a valid resource name character :patched:mergeDebugResources FAILED
(too long for here, migrated it to hastebin) https://hastebin.com/ovirexewek.vbs
Til now i tried several different gradle options but none of them worked. I'm inviting you to a private repo in case you want to try at the project itself.
Thanks for your efforts!