yashsingh1/xdaforums huggingface dataset:
[Android Software Development] Lanchon:
there's really nothing wrong with mt-mdex, only you'll get more dex files than needed in exchange for patch performance. you can even use it to debug mono dex apps (as long as you are debugging them on a device running ART, ie, android 5 or later).

when releasing, you do want to not use it though. not only it will produce "nicer" output to soothe the OCD-afflicted developer, but most importantly, it will eliminate stochastic variations in the output. so mt-mdex being disabled is a requirement for reproducible builds, which are all trendy and stuff now, and you know you're an old computer fart if you're not doing them.
[Android Software Development] rauleeros:
hello there! I wish too I had known about this tool a long time ago... I had been using smali editing for my patches, and let´s just say it is nice not to have to look at smali code with what [MENTION=4141005]Lanchon[/MENTION] has created. Serious talk, I couldn't be more thankful for this tool and I am sure a lot of people don't post here but have the same opinion as I do.

I have been looking at the samples posted on github with the V2 and I'm still in the process of learning the structure. Is there a specific Android Studio build, API level and so on that should be used in order to get the samples working without issues?
[Android Software Development] Lanchon:
> Is there a specific Android Studio build

any recent AS will do.

use v2.0.0 samples (and, thus, plugin).

DO NOT modify the samples gratuitously: do not let AS update any plugin versions!
[Android Software Development] lakkimsetty.baba:
New to dexpatcher, qq: I am following the patched-app example in the samples repo. Is there a way to pull com.github.lanchon.dexpatcher:dexpatcher-gradle:2.1.3 from some artifactory?

Currently, the latest version of plugin in gradle is 2.0.0

Thanks in advance :)
[Android Software Development] Lanchon:
no. i had a serious issue with the gradle team that manages the plugin portal. the result was a hiatus in development because they drained my energey. no further plugins will be published to the portal and the new plugins will require a new home. the "prerelease" versions you want to use will probably never be released and the version numbers will be skipped. avoid those tags.
[Android Software Development] stenlan:
Hey, I can't seem to replace/append/prepend etc a method that takes a parameter whose type is a top-level class (as in, it's in the "default package") because this is illegal in Java. I tried some parameters like `target` for the class and method as well, but it's not working. Is this possible?

EDIT: I figured it out. I can put the class itself in the default package, this allows me to reference other top-level classes. Then I specify an explicit target and set contentOnly to true for this class.
[Android Software Development] Lanchon:
hey, sorry for being late

the correct, general solution is to use the mapping facilities of the latest dxp-tool beta.

> I specify an explicit target and set contentOnly to true

that is dangerous. it can work for simple cases, but will trigger the bytecode verifier sooner or later for complex cases. explicit class targeting is not a general renaming mechanism and is mostly designed to replace existing classes with a class that still uses the original class. it is a mechanism for a complex task and has many caveats. again, dxp-tool now supports class mappings to cope with obfuscation and limitations of the java language.

EDIT:

> designed to replace existing classes with a class that still uses the original class [which is renamed].

in particular, this means that references from outside class will not be renamed (they have to reference the replacement class) while references within the class will (the this pointer for example must be renamed). some rules determine behavior, but it is **not** a general renaming solution as you maybe expect it to be.
[Android Software Development] stenlan:
Thanks for the response. TBH, I have 0 idea how to use that. I only know how to use the gradle stuff anyway... Is there any docs on this?
[Android Software Development] Lanchon:
yes, the beta release notes and build-time tests.
[Android Software Development] kasnder:
Hi! This is really a great tool, and I don’t understand why it’s not yet used by everyone instead of apktool. I was wondering whether there’s an easy way to modify app resources with this approach? At the moment, I rely on using apktool and this is very computationally intensive, and I’d like to avoid it.
[Android Software Development] Lanchon:
yes you can. you can add or replace individual resources, and you can edit the manifest. all this is done without replicating anything in the source. check the sample, it does all this.
[Android Software Development] xda1user:
Lanchon, thanks so much for this great tool, if you don't mind I'd like to ask how to build dexpatcher_26.dex ? If I run jar2dex I get this error

d2j-jar2dex.sh dexpatcher-1.8.0-beta1.jar
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
[Android Software Development] Lanchon:
(deleted)
[Android Software Development] Lanchon:
UPDATE: version 1.0.0-beta2 released!

Changelog in the previous link. Do you use DexPatcher? Say hi on this thread!
[Android Software Development] PerfectSlayer:
Hi ! ;)

I read a few about the tool and plan to try as soon as I have few time (I'm moving my home this month…).

I keep thinking this tool is really useful when you have a lot to patch in smali.. (which is a real pain comparing to java coding).

I also plan to port the scripts to windows (as the tool is cross platform).

Note: Any clue about DexPatcher usage with GitHub traffic analytics?
[Android Software Development] zezadas:
Hi

Awesome project.

Works great.

The only thing I have to point, is the pseudo java, sometimes it's all messed up and when you move it to src it won't compile.

Many thanks for this tool, good work.
[Android Software Development] Lanchon:
well 5 people forked it but no commits so far.

great, i can help u with the windows scripts if u want. im sure itd help people get started. you might want to look at these kinds of expasions: https://code.google.com/p/dex2jar/s.../src/main/bin_gen/d2j_invoke.bat?name=0.0.9.x
[Android Software Development] PerfectSlayer:
May be you could see with [MENTION=2295247]Diamondback[/MENTION] to get integration of your tool in a more known one like VTS?

And more userfrendly than a CLI! No offense, I'm fine with CLI but GUI often get more users…
[Android Software Development] Lanchon:
lol yes, and so does windows :) but im not in the business of pushing tools! :) i dont plan to do that because ive got more interesting things to do if i have the time IMHO. btw, i think eclipse integration is much more valuable than any adhoc gui. im using dexpatcher with eclipse (jdt) and its great. eclipse really helps with both analyzing the source app and writing the patch. i should do a write up on how to set it up. (it does need the scripts to set up things though.)

much better than win scripts would be an eclipse extension. i just dont have time to write that.
[Android Software Development] PerfectSlayer:
Better than the script to set up, you could have a "DexPatcher project" type in Eclipse :D

Otherwise, IDEA plugin could also be an "idea". I wonder how many devs have switch to IDEA since the devtools are officially base on Intellij software…
[Android Software Development] Lanchon:
but im using JDT in eclipse, not ADT.
[Android Software Development] Lanchon:
UPDATE: version 1.0.0-beta3 released!

Changelog in the previous link. This is a major update and feels feature complete, but I still need to accrue more experience in using it before a release. The sample in the OP has been updated to match and uses the latest features. Be sure to check it out if you haven't in a while, you can use the commit history to find the recent changes.

I've also published a supplemental tool called ExtractAR; can you guess what i'am after next?

As a side note, I've been using DexPatcher in a couple of real world projects and, after setting up symbols and scripts in Eclipse, i'm really pleased with the development experience and speed... not to blow my own horn :-p. it used to be 20% of the time to figure out what to change and 80% to actually do it. now 90% of the time is figuring out what i want to do and only 10% doing it, and i'm doing complex changes i wouldn't have dared to before!
[Android Software Development] PerfectSlayer:
Hi [MENTION=4141005]Lanchon[/MENTION]

Any news about a final release? Did you think about some improvement or new feature to add it?

Not for asking ETA, just to wake up some interest about the project ;)
[Android Software Development] Lanchon:
ive been working *a lot* on this! although it doesnt show :) so for DexPatcher...

the current version should be considered v1 feature complete. it is mostly there. there will be a new release that integrates dexlib 2.0.6 over current 2.0.5, which includes some api changes that i requested for dexlib that increase polymorphism and cleans the DexPatcher codebase all around. but there should be no user-facing changes, this is implementation detail. a final release is only pending testing, that's what the beta is for!

unfortunately i haven't tested dexpatcher as extensively as i would have wanted: instead of using dexpatcher, ive been busy crash-coursing on groovy, gradle, the android build system, and android studio itself. im working on deep integration of dexpatcher into the new android build system. had i knew the amount of work this would take first hand, i wouldnt have embarked on it! seriously! integration will finally take 5 to 10 times more work than the tool itself. but the good news is that a preview release is relatively near. and it will be... awesome! the scope far exceeds the dexptacher tool, but for now ill only say that i've embraced the sad fact that not everybody uses linux, and dexpatcher reloaded is completely multiplatform :)

the only real problem i have is an impending set of trips, to the US and europe, and if i dont finish the tooling in time and publish, i will completely forget all the complexity im dealing with now in my head. and when im back months later, i suspect i wont have inclination to continue. yes im learning *a lot*, thats true, but most of the stuff im doing is really *not* enjoyable.

regarding the future of the dexpatcher tool, the big missing piece of the puzzle is multidex support. it was consciously left out because 1) *i* dont need it for my projects, and 2) you have to control feature creep and release early! i don't know enough about multidex to even begin to tackle the problem in my head. multidex is a horrible hack. i suppose dexptacher will gain multidex support, but suspect that it will only support multidex enabled dalvik VMs, and not the old VMs on which multidex runs thanks to libraries packaged with each apk.

tl;dr trust me, you'll love the new dexpatcher :) hopefully it'll trigger wide acceptance of the tool. but for now it's nice to see some interest, so thanks for stopping by!
[Android Software Development] PerfectSlayer:
You're welcome and thanks for your hard work!

Keep learning and improving stuff. You will learn to enjoy it even if it's not fun at all :p
[Android Software Development] Lanchon:
luck you, you didn't have to wait that long :) after a lot of work i just finished what appears to be a fully working 0.1 release, phewww!!! there's still packing and publishing work pending, things that i know nothing about. and the damn docs!! i don't know if i will have time to publish before my trips, but the good news is that its finished so it will be published sooner or later :)
[Android Software Development] Lanchon:
THE ALL-NEW DEXPATCHER PREVIEW IS UP !!!

Come take a look ! :)

​
[Android Software Development] PerfectSlayer:
Integration to Android Studio! Nice!

Testing it goes straight to my todo list :D
[Android Software Development] dj25:
I need some help or directions about what to do :crying: I have been trying this tool to patch an APK file and its keep crashing. Probably not related to this tool but a help or direction would be appreciated. :confused:

I created a patch and successfully compiled and it was crashing at start. Then I removed the patched java file and recompiled it without any patches and It was still crashing. Checked the catlogs and I see exception is being thrown from some sqlite encryption adapter complaining about file is encrypted. App is also using AESObfuscator (might be related). So what I think is; after it gets repacked into a new apk something about encrypted sqlite file gets broken because of this AESObfuscator? If so should I remove this and how can I remove this? A link to a tutorial or something will be helpful. Would it be better to use something like Xposed in this situation? Thanks.
[Android Software Development] Lanchon:
by design, this tool creates a new apk, which means that the signature needs to change. some apps or libraries of those apps check their own signature and fail to run if something is unexpected. for example, the google map library requires a key for each app. if you resign the app the library will stop working, unless you get a new key for your signature.

for debugging non-working apps:

1) resign the app without any modifications. if there is a problem, it's the signature.

2) use apktool to decode and rebuild the app without mods. if there is a problem, it's an apktool bug (or misconfiguration; read the section on frameworks on the apktool docs).

3) now you know it's a problem with your patch or the DexPatcher toolchain.

for signature problems:

unless you want to patch the app to not check, then you need the system to report a fake signature to the app. this can potentially be done this way, though i haven't tested:

1) copy the signature files from the original apk to the modded one. (maybe one day there will be a toolchain extension for this.) now you have an app with an INVALID signature and won't install.

2) modify your system to accept invalid signatures. BUT... beware of the dangers of this!

you can probably do item 2) with the 'XInstaller' xposed module. check the help: http://pyler.wen.ru/XInstaller/Help.html

note that this is probably NOT what you are looking for:

Checking signatures: Disables signatures checking during installations so you can install app over same app even if the signatures don't match.​

that probably means that the system continues to verify the validity of signatures, but does not block an app upgrade if the signature changes.

instead this is what you are looking for:

Verifying signatures: Disables signatures verifying. Experimental feature (may or may not work on some device, can cause bugs), requires enabled Expert mode.​

ENABLE VERIFICATION RIGHT AFTER YOU INSTALL THE PATCHED APP!!!

so to move on, resign the app without any modifications and test this. please report back!
[Android Software Development] dj25:
Thanks for detailed explanation. I tried resigning APK without changing anything and yeah it crashed. So it is definitely a problem with sign.

I tried copying signatures from original APK to new APK and installer just crashes with this new APK. Tried with both aligned and unaligned zip files. Tried with disabled XInstaller and it still crashed.

I dug into code of the app, searched for keyword "signature" and found out it is generating some kind of string key from signature to use it on encrypting the sqlite file which is what I already thought. I think I can use Xposed to return that string and after that I can patch that function with DexPatcher to return this acquired string all the time. I am going to try this now.

Also XInstaller idea was good but it defeats the purpose about ability of using the apk on non-rooted devices.
[Android Software Development] Lanchon:
1.0.0-beta4 is out, no biggy, no user facing changes. this will probably end up being the release unless bugs are found.
[Android Software Development] CosmicDan:
This is too cool. Sad to hear that you don't plan on continuing development, I'm quite sick of manually injecting smali!

Sent via Tapatalk on my Xperia Z
[Android Software Development] Lanchon:
well you'd need to ask that project.

but you can probably build it using retrolamda/dx combo for old androids or simply d8 for newer androids.
[Android Software Development] chocofrypie:
I'm been using the latest release of the dexpatcher-gradle plugin, and in response to invalid resources, I have enabled the "disableResourceValidation" and "useAapt2BundledWithApktool" options in app build.gradle file.

However, an error arises in which the Android resource linking process fails, as a "queries" element is found in the manifest under build/intermediates. I'm not too sure how to fix this. I've changed the gradle version from 3.4.2 to 3.4.3, which was the patch from Google that was meant to fix this. (source: https://android-developers.googlebl...ild-for-package-visibility-in-android-11.html)
[Android Software Development] Lanchon:
the aapt2 bundled with apktool most likely is pre-android 11 and does not know about queries. your best bet then is to target android 10 instead of 11 and remove the queries element. or if you don't need the inter app functionality (maybe its against your privacy) you might get away with just removing said element. the app will incorrectly think other apps it looks for are not installed when they actually are.
[Android Software Development] arizzopm:
Hello there! Thanks @Lanchon for this tool!

I'm having problems with the android billing package. I'm trying to hook a function that has android billing has argument

import com.android.billingclient.api.BillingClient;

@DexReplace
private void handlePurchase(Purchase purchase) {
// ...
notifyPurchase(purchase.getSku(), purchase.getOriginalJson(), purchase.getSignature());
}

But the dependency doesn't exist so I tried to add it in build.gradle.

dependencies {
implementation("com.android.billingclient:billing:3.0.3")
}

And added it to AndroidManifest.xml

<meta-data android:name="com.google.android.play.billingclient.version" android:value="3.0.3"/>
<activity
android:name="com.android.billingclient.api.ProxyBillingActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />

And then a task fails

Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute activity#com.android.billingclient.api.ProxyBillingActivity@configChanges value=(keyboard|keyboardHidden|screenLayout|screenSize|orientation) from AndroidManifest.xml:21:13-96
is also present at [< App Components > :app-components:unspecified] AndroidManifest.xml:37:19-102 value=(keyboard|keyboardHidden|orientation|screenLayout|screenSize).
Suggestion: add 'tools:replace="android:configChanges"' to <activity> element at AndroidManifest.xml:19:9-22:75 to override.

So I added tools:replace="android:configChanges" as suggested but then another task failed

type 'com.android.billingclient.BuildConfig': (com.android.billingclient:billing@@3.0.3:0): already exists
(lot of similar errors)

I tried the following code:

dependencies {
implementation("com.android.billingclient:billing:3.0.3") {
exclude group: 'com.android.billingclient', module: 'billing'
}
}

but i had no luck

So i'm stuck here :/

Any ideas?

The app's AndroidManifest.xml has:

<meta-data android:name="com.google.android.play.billingclient.version" android:value="3.0.3"/>
<activity android:theme="@style/Theme.Translucent.NoTitleBar" android:name="com.android.billingclient.api.ProxyBillingActivity" android:exported="false" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

Thanks in advance!

Best regards
[Android Software Development] Lanchon:
sorry this is useless. what exactly does not exist? instead of "dependency doesn't exist" paste logs and errors. also paste the full java source, including containing class.

why? if the dep is already on the source app you shouldn't re-add it. (if you wanted it replaced with a different version there is more stuff you must do.)

this is correct. the merger step merges the original app manifest with yours. both have an <activity> named the same for which your manifest defines a configChanges attribute. but there already is such an attrib in the original activity, so you need to inform manifest merger what to do with the clash.

this is correct. the dependency is already in the app so the default class action DexAdd fails because classes already exist in the app. again, you shouldn't just add a dep that is already there.
[Android Software Development] rauleeros:
Is there anyone in here able to patch apps that use Android Hidden API 27? I'm having a bunch of errors while trying to do this and I'm sure the fix is something straight forward. :(
[Android Software Development] shirazC:
Do anybody know something about this

Some problems were found with the configuration of task ':app:decodeApk' (type 'DecodeApkTask').

- In plugin 'lanchon.dexpatcher.gradle.plugins.DexpatcherBasePlugin' type 'lanchon.dexpatcher.gradle.tasks.DecodeApkTask' property 'frameworkOutDir' is annotated with @PathSensitive but that is not allowed for 'OutputDirectory' properties.
[Android Software Development] Lanchon:
you are using an unsupported version of gradle. please see dxp-gradle release notes for compatibility info.
[Android Software Development] reverser69:
hi all

can someone please give a step-by-step guide on how to build the patching environment?

i want to patch a sample APK like this:

but what ever i do i get errors. im tring to integrate dexpatcher with android studio.

tried to build dexpatcher but it seems gradle cant find some files online.

it seems dexpatcher cant work with latest version of tools but i dont know which version to install.
[Android Software Development] Lanchon:
read the release notes of dxp-gradle releases on github for the last few versions.
[Android Software Development] kurtn:
@Lanchon can you please remove your signature spoofing checker from f-droid? Now that most spoofing implementations give a false negative, it does more harm han good in microG community.
[Android Software Development] Lanchon:
what do you mean "false negative"? i just downloaded and tried it on my phone, and it resulted in a true positive. your use of "most" needs qualification. are you referring to lineage4microg's builds?
[Android Software Development] kurtn:
I'm referring to lineageOS. It only allows original microg to spoof. And crDroid - spoofing only for system apps. The only major custom rom giving a true positive is /e/ . /e/ allowing arbitrary apps to spoof signatures is a useless feature maybe an attack vector.
[Android Software Development] Lanchon:
lineageOS?! they spent years opposing to any kind of sigspoof! that's whole reason for the lineage4microg project. now they've added some kind of support? call me a skeptic, but can you point me to the commit? or at least news about this?

crDroid does not implement sigspoof as defined and implemented by the microg project. the checker is correct in pointing out that sigspoof is not enabled on that OS: it is a true negative result.
[Android Software Development] kurtn:
https://review.lineageos.org/q/topic:%22microg-eval%22

For crDroid case, maybe a message would help. Like "

try microG gmscore self-check. Maybe an instalkation as system app is necessary "
[Android Software Development] Lanchon:
sorry i forgot to answer this.

sigspoof-checker is really not the right place to document shortcommings/design choices of a particular OS. i think it is cdDroid's job to document crDroid correctly including the fact that they don't support sigspoof except for system apps. (btw, last time i checked, microg did not need to be a system app and worked fine as a regular app, but that may have changed.)

similarly, it's not sigspoof-checker's place to hypothesize on why sigspoof might not working. nor is it inextricably linked to microg: as shown in my previous message, sigspoof has real uses outside of microg.