Open beshoo opened 4 years ago
this is in the general case impossible.
you cannot join code from 2 or more apks because each has its resource id mappings and they can clash. and the way javac works inlining static finals (what a piece of crap design decision this was!) you cannot renumber the ids in compiled code. (this same reason makes DexEditing static finals of simple types mostly useless.)
however what you could do is hook all API method calls in the imported code that take resource ids and map the numbers at runtime from the imported code's ids to the ones the resources got during the merged apk build.
note that dxp-tool will support method hooking in the future, but this usage you posit here will always be outside the scope of dxp-gradle and will never be directly supported.
happy new year!!!
Yes some ids has to be 16 bit, and that can clash. Well,
however what you could do is hook all API methods calls in the imported code that take resource ids and map the numbers at runtime from the imported code's ids to the ones the resources got during the merged apk build.
I did not follow up with you, but do you believe apk tools has to do this on its own? I am not sure how. I already asked same question on apktool project.
Apktool is the only one who can do this. How, i dont know, thank god i can do this manually, it take 30 min of time, but what a copy paste job, lol
all calls in imported code similar to:
get hooked to:
where translateId() translates ids from original APK ids to the ones the imported resources got during final apk rebuild. hooking method calls is a dexpatcher concern and it will be possible in the future. the functionality is already thoroughly designed. however this particular use case and the generation of the actual translateId() method will never be concerns of the dxp project.
@Lanchon , DexPatcher did not work with Instagram at all, so I am doing it via APKTOOL, and smali. I understand that you are not going to support this, that is why I titled this (Out of the scope) which is for learning purpose only.
There is an app called "appCloner" it is on google play, I can not believe how it can do this. This app can create a new layout over your app, like a calculator, add huge things over your app, and it generates a working APK.
I don't know how but there is a way to rename indexs but i don't know how to do it.
idk whats wrong with IG and dxp but i don't have time to look. for sure dxp will have a reduced, apktool-rebuild mode independent of the android build system that's going to be less capable but much easier to use.
@Lanchon, well, l dint understand why AAPT2 break apktool, while AAPT1 works great.
But you saide aapt will not help me which u don't understand why, if you can help me understand this.
Since working with smali is a nightmare, i will appreciate your approach if you can give a hand with this. By just trying one time with Instagram apk.
Any way i likes to ask if i want to add a resource via dexPatcher is it something in the scope?
Lets say i eant to add a new class, layout, well a complete activity, and this activity needs some library to be loaded. Is that something can be done?
I am not sure how, but if appcloner can work with any program... Imagine that it has a function which i can tap on any photo on the app and it can export it... How deep is this, l dont know.
What l am saying that there is a way to improve dexPatcher.
Regard
well, l dint understand why AAPT2 break apktool, while AAPT1 works great.
does it? i don't know for a fact. it is just an educated guess on my part.
you saide aapt will not help me which u don't understand why
you can use AAPT1 with dxp-gradle (see release notes). but do you remember that thing where my plugin is able to force the Android build system to use a non-standard AAPT2 binary? (either auto extracted from apktool or you can provide your own in the 'aapt2' configuration.) well i only implemented for AAPT2.
why?
now back to your problem. you can use AAPT1 with android plugin v3.2 and some extra configuration.
but the AAPT1 binary cannot overridden, so you'll have these issues again: https://github.com/DexPatcher/dexpatcher-gradle/issues/22 (why? because official AAPTs include checks and restrictions that make them fail when rebuilding some apps. for this reason, apktool has been bundling custom AAPTs for ages.)
but as described in that link, you can rename the resources manually and fix that issue.
or... you can replace the Android SDK 'aapt' binary with the moded aapt1 shipped by apktool. this will affect all your android builds!!! but it is a valid workaround. you can also clone your SDK dir and mod the clone, then use the clone only for this project of yours.
Any way i likes to ask if i want to add a resource via dexPatcher is it something in the scope?
yes, no problem for dxp-gradle.
Lets say i eant to add a new class, layout, well a complete activity, and this activity needs some library to be loaded. Is that something can be done?
yes, no problem.
I am not sure how, but if appcloner can work with any program... Imagine that it has a function which i can tap on any photo on the app and it can export it... How deep is this, l dont know.
i suppose that's non-free software. i don't work with non-free software.
Dear all, Happy New year everyone. I know this is not related questions to the dixpatcher but i am sure it will be useful for others.
Lets say i have android studio project, and i want to copy an activity form it to another apk.
What i did to achieve this: Mimic same directory structure of the target apk in the android studio. Build the apk APKTOOL d the apk. Copy the activity page. Copy the activity resource filed. Now the problem. I have to find all activity resource ids in the public.xml, then copy them to the target.
Update the hex values of each resource to match target pool values in the target apk by adding +1 to the latest hex value.
Then update the activity smali pages with the new hix values. And adding the activity layout hext to the public.xml
Update ids.xml with all new ids we have. And some time the attr.xml
It is a nightmare, specially if you want to do this each time you add a new resource.
But at the end of the day, it works on the targeted apk with out any problems.
The questions, is there any automat way to do this? It is nightmare to do thats steps each time.
I am sorry to adk non related questions, but this place full of professional people.
Thanks again. Best wishes for all of you.