Giter Club home page Giter Club logo

dexpatcher-gradle's People

Contributors

lanchon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dexpatcher-gradle's Issues

"Resource compilation failed" when replacing library which has "declare-styleable" resources

I'm trying to upgrade some of the existing libraries in my app/project.

Started by just adding new dependencies to build.gradle with problematic transitive deps excluded.
The package-info.java method to declare the code overridden works fine there.
Some of the libraries work perfectly well with just this done.

With others, I start to get

Execution failed for task ':mergeReleaseResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  C:\Users\anl\.gradle\caches\transforms-2\files-2.1\cf88320d6b120360e17f4b697335e513\res\values\values.xml:153:5-155:25: AAPT: error: duplicate value for resource 'attr/navigationMode' with config ''.
  C:\Users\anl\.gradle\caches\transforms-2\files-2.1\cf88320d6b120360e17f4b697335e513\res\values\values.xml:153:5-155:25: AAPT: error: resource previously defined here.

and a number more like this.

Comparing the listed generated file to the ones extracted from the apk show the difference: these attr resources are coming from the library and are inside a declare-styleable block;

    <declare-styleable name="ActionBar">
        <!-- The type of navigation to use. -->
        <attr name="navigationMode">
            <!-- Normal static title text -->
            <enum name="normal" value="0"/>
            <!-- The action bar will use a selection list for navigation. -->
            <enum name="listMode" value="1"/>
            <!-- The action bar will use a series of horizontal tabs for navigation. -->
            <enum name="tabMode" value="2"/>
        </attr>
        ...
    </declare-styleable>

I've run into the same issue in the past when I extracted resources from apk and used them directly copied into android studio project, compiling with decompiled code and a jar of code extracted from same app; these declare-styleable blocks are used by source as a reference but are basically stripped out of the binaries so don't exist in the apk. I had to manually recreate them by trial and error in my resource files to get the project to build.

In my new dexpatcher based project, I'm guessing the aapt resource merger can't resolve the apk-derived flat attr's as being the correct ones to override by the new declare-styleable internal ones so throws this error.

Is there any possibility of handling this sort of issue in dexpatcher? I'm guessing it generally doesn't normally do much in the way of editing resources after the initial unpack.

Do you know if there's any way I could add an extra gradle task hook or similar to manually strip out resources I don't need included from the original apk? I'm going to try to do this manually with apktool now.

[BUG] AAPT2 fails with --no-proguard-location-reference

Hey there!

I'm currently trying to patch a application which has ressource issues. I therefore used your sample-project for broken ressources but i'm running in the following error while rebuilding ressources with aapt2 (the one bundeled with apktool 2.4.1):

AAPT: unknown option '--no-proguard-location-reference'.


aapt2 link [options] -o arg --manifest arg files...

... [aapt2 help is shown]

I'm currently running on

  • Gradle 4.0.2
  • Dexpatcher-Gradle 2.1.3
  • Dexpatcher 1.8.0-beta1
  • Apktool 2.4.1

I read though quite a lot of release notes and issues on your repositories but could not find a working solution. Trying to add android.enableJvmResourceCompiler=true to the gradle.properties resulted in a java.lang.IllegalStateException: TODO

Thank you in advance!

Edit: Tried out switching versions of apktool (from 2.3.4 - 2.4.2), aapt2 and so on. No success there. Also tried to switch to the applib-sample, there dex2jar throws a error as it is not capable of converting the dex file.

Adding an Android library causes resource merger to fail with a "has already been defined" conflict

Situation is as follows:

The source application contains the base of com.google.android.gms with some classes stripped out to reduce size of the app (for example the PlacePicker).

In the patched application i'd need the PlacePicker so i'm trying to add it as a gradle dependencie. While syncing with gradle the resources from the source library and the resources from the patched library are clashing, throwing me the error

"xxx" has already been defined

Is there some kind of workaround or should i just delete the assets from the source (these are 645 assets)?

Handling invalid resources (error: resource 'xxx' has invalid entry name 'xxx'. Invalid character 'xxx'.)

UPDATE:

Proper invalid resource support has been implemented in DexPatcher-gradle v2.0.0. The information below is now outdated. Please see the v2 release notes for details.


Invalid resources such as resources with invalid characters in their names (eg: $) can, for the time being, be worked-around as follows:

  1. Add this code section to the project's build.gradle.
  2. Add patched AAPT2 binaries inside an aapt2 directory to the project, as shown here.

The patched AAPT2 binaries come from official Apktool releases and can be downloaded verbatim as artifact dexpatcher-repo.ibotpeaches.apktool:apktool-aapt2 from the DexPatcher repo. (Current version as of this posting comes from Apktool 2.4.0.)

There is a new 'invalid-resources' sample that demonstrates the workaround.

Build error: package doesn't exist

Hi
I made an experiment pathing some apk. Sometimes it's more suitable to do it using small (f.e. when you need to add some calls/ change some values inside method. but not to append or prepend). So I added some resources and edited some calls using smali and then build apk with Apktool manually. This apk is valid and successfully runs on my device. But then I wanted to edit result apk some more by adding some classes and there I choose dexpatcher-gradle. However after adding some classes when making build I see bunch of errors 'package XXX does not exist'. Though this package definitely exists in original version. When I make the same changes with dexpatcher to original apk the build process succeeds. Is it possible that during using Apktool apk was some kind of corrupted? Or maybe dexpatcher provides options to edit apk using smali not java?
Apk was loaded to dexpatcher-gradle-project unsigned.
Thanks

AAPT: error: invalid value for type 'anim'. Expected a reference.

Hi, I started off with the 'patched-app' example. This was compiling fine for me. Then I swapped the APK and adjusted package names, etc. I am not really trying to change anything yet. I just want to re-compile the application.

I am getting the following error and I have no idea, what that means.

Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:3:5-72: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:4:5-72: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:5:5-77: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:6:5-71: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:7:5-72: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:8:5-77: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:9:5-74: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:10:5-72: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:11:5-72: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:12:5-72: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:13:5-77: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/anims.xml:14:5-77: AAPT: error: invalid value for type 'anim'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:3:5-70: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:4:5-70: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:5:5-74: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:6:5-75: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:7:5-72: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:8:5-70: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:9:5-70: AAPT: error: invalid value for type 'layout'. Expected a reference.
      
  /home/le/.gradle/caches/transforms-2/files-2.1/0ddbbe2f9e0721a0642e85af897f0163/res/values/layouts.xml:10:5-75: AAPT: error: invalid value for type 'layout'. Expected a reference.

Support configurable package name for DexPatcher annotations.

Add a command line option to the tool to configure the package name for DexPatcher annotations at runtime, to deter rouge apps from intentionally clashing against DexPatcher annotation names. Support for this is already baked into the codebase, only the command line parsing needs to be implemented.

Resources merger fails while adding no resources

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!

How to reduce "app:patch DexDebug" task execution time

The project I'm working on takes a lot of time with each build.
Each time Dexpatcher will rewrite the dex in the directory '..\app\build\intermediates\dexpatcher\patched-dex\debug' and it took me almost 5 minutes for each such build.
Do you have any solution?

I am using:

  • Android Gradle plugin 3.4.3
  • Dexpatcher 2.1.0

apktool and dex2jar tasks should fail on no output

The apktool and dex2jar tasks should fail if for whatever reason no output is produced. This would stop gradle from caching those "results" as valid, if they are ever produced. I observed one instance (that I was not able to reproduce later) in which gradle cached a success of the dex2jar task as producing no output, and a manual reset of the gradle task result cache was required to fix the issue.

Android Studio preview layout not render in all layouts in design mode

This is my demo source code dependency
ic_source_dependency

and demo patch code dependency
ic_patch_dependency

When I try to preview layout in design mode, the view does not render in all layouts that use: androidx.constraintlayout.widget.ConstraintLayout give the following error the following classes could not be instantiated

I did clean and rebuild project, invalidates caches / restart, close and reopen Android Studio, but did not solve the problem.

ic_error_view

Handling annotation processors (Error: Annotation processors must be explicitly declared now)

Let me just start with wow, thanks, wow.
I've been maintaining & building on a app/android platform from a defunct company (navdy) for some time now, gradually decompiling bits and compiling them in a project against a the original apk (turned into jar) and it's always been such a fight to avoid bugs, as you clearly well know.
Don't know why it took me so long to find this project, but thank you!

This error report is low priority and can be easily worked around (for now at least).
I'm also just getting started with your tools and quite probably doing something wrong at my end too.

The original apk uses a few annotation processors in its build process (dagger, mortar etc) and I suspect they (in the automatically extracted dex/classes used by your plugin) are triggering the warning below.

Execution failed for task ':javaPreCompileDebug'.
> Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  Please add them to the annotationProcessor configuration.
    - classes.jar (< App Components > :app-components:unspecified)
  Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.
  See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

The override command suggested works, but as they say it might be removed at any time.

If you ever want to see it yourself, a copy of the original apk is available at https://gitlab.com/alelec/navdy/display-rom/blob/master/system/priv-app/Hud/Hud.apk

Resources merge error - Duplicate drawable

When i try to add images to the patch folder to override the original, the build failed with this error:
***\app\build\intermediates\res\debug\drawable-hdpi-v4\abc_ab_share_pack_mtrl_alpha.9.png: error: Duplicate file.
***
\app\build\intermediates\res\debug\drawable-hdpi\abc_ab_share_pack_mtrl_alpha.9.png: Original is here. The version qualifier may be implied.

How to use dexpatcher-gradle?

Hi @Lanchon,

I just checked the dexpatcher-gradle.
But I am not sure how to modify the apk at source code level.

Could you explain how to use the dexpatcher-gradle in detail?
I am using Android Studio.

Thanks

[QUESTION] Accessing R.id.x in separate APK

Hi @Lanchon,

we are trying to pack generated system tests (e.g. espresso tests) obtained from our test generator into a separate APK. This is similar to the APK you obtain when running ./gradlew assembleAndroidDebugTest. Assuming you have access to the source code, this is pretty easy, you simply copy the obtained tests into the androidTest folder and run the gradle task. But, in our case we assume no access to the source code, just to the APK. We thought about copying the tests into some kind of template repository that is minimal. Then, we need to adjust the package name such that it matches the AUT. Finally, we would like to run ./gradlew assembleAndroidDebugTest to build the APK and sign it afterwards. However, we would like to use within those tests the ids of the auto-generated R class, e.g. R.id.my_button. I know that we could look up the real ids within the APK of the AUT and replace R.id.my_button with 0xCAFE for instance. But is there any other option rather than using the raw ids or doing everything at the smali representation level?

Any help is appreciated. Thanks in advance!

APKTOOL_DUMMY_28

Hi,
I've decoded an apk and the following line is adding to the plurals.xml file

<item type="plurals" name="APKTOOL_DUMMY_28">false</item>

why this is happening?
please note that the apk file doesn't have this line in plurals.xml.

Patch classes starting from non-latin symbols

Hi. I've got an issue trying to patch classes after some obfuscation when those classes names start from non-latin symbols fe some unicode symbols or digits. Android Studio does not allow to create classes with such names so could you please give some advice how to do it?

dexpatcher-tool-scripts functionality

Dexpatcher-tool-scripts is deprecated, so i think that all of it functionality is awillable as gradle tasks. Is there any tasks wich emulate dxp-setup-for-apk functionality? I mean generating smali code, decompiled java code and also java stubs?

Question [out of the scope] Copy activity between apks

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.

How to delete the dependencies from Source Apk?

@Lanchon In patched/build.gradle while importing aar file you have mention -

Alternatively we could delete the copy brought in by the source
app using DexPatcher package annotations.

Can you let me know on how to use DexPatcher package annotations?
I have used Dexpatcher Add/Edit Annotations in java file but how to use it in gradle file I don't know and couldn't find anywhere in documentation

error: resource 'drawable/$avd_hide_password__0' has invalid entry name '$avd_hide_password__0'. Invalid character '$avd_hide_password__0'.

UPDATE: solution here

so far this is caused by the same 6 files in all apps i've seen. i suppose these malformed files come from a google library.

these files are part of two very similar and complementary animated vector drawables:

1) avd_show_password

==> res/drawable-v21/avd_show_password.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <animated-vector android:drawable="@drawable/$avd_show_password__0"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
        <target android:name="eye_mask" android:animation="@drawable/$avd_show_password__1" />
        <target android:name="strike_through" android:animation="@drawable/$avd_show_password__2" />
    </animated-vector>


==> res/drawable-v21/$avd_show_password__0.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <vector android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
        <path android:name="strike_through" android:pathData="@string/path_password_strike_through" android:strokeColor="@android:color/white" android:strokeWidth="1.8" android:strokeLineCap="square" />
        <group>
            <clip-path android:name="eye_mask" android:pathData="@string/path_password_eye_mask_strike_through" />
            <path android:name="eye" android:fillColor="@android:color/white" android:pathData="@string/path_password_eye" />
        </group>
    </vector>


==> res/drawable-v21/$avd_show_password__1.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <objectAnimator android:interpolator="@android:interpolator/fast_out_linear_in" android:duration="@integer/show_password_duration" android:valueFrom="@string/path_password_eye_mask_strike_through" android:valueTo="@string/path_password_eye_mask_visible" android:valueType="pathType" android:propertyName="pathData"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" />


==> res/drawable-v21/$avd_show_password__2.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <objectAnimator android:interpolator="@android:interpolator/fast_out_linear_in" android:duration="@integer/show_password_duration" android:valueFrom="1" android:valueTo="0" android:propertyName="trimPathEnd"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" />

2) avd_hide_password

==> res/drawable-v21/avd_hide_password.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <animated-vector android:drawable="@drawable/$avd_hide_password__0"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
        <target android:name="eye_mask" android:animation="@drawable/$avd_hide_password__1" />
        <target android:name="strike_through" android:animation="@drawable/$avd_hide_password__2" />
    </animated-vector>


==> res/drawable-v21/$avd_hide_password__0.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <vector android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
        <path android:name="strike_through" android:pathData="@string/path_password_strike_through" android:strokeColor="@android:color/white" android:strokeWidth="1.8" android:trimPathEnd="0.0" android:strokeLineCap="square" />
        <group>
            <clip-path android:name="eye_mask" android:pathData="@string/path_password_eye_mask_visible" />
            <path android:name="eye" android:fillColor="@android:color/white" android:pathData="@string/path_password_eye" />
        </group>
    </vector>


==> res/drawable-v21/$avd_hide_password__1.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <objectAnimator android:interpolator="@android:interpolator/fast_out_slow_in" android:duration="@integer/hide_password_duration" android:valueFrom="@string/path_password_eye_mask_visible" android:valueTo="@string/path_password_eye_mask_strike_through" android:valueType="pathType" android:propertyName="pathData"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" />


==> res/drawable-v21/$avd_hide_password__2.xml <==

    <?xml version="1.0" encoding="utf-8"?>
    <objectAnimator android:interpolator="@android:interpolator/fast_out_slow_in" android:duration="@integer/hide_password_duration" android:valueFrom="0" android:valueTo="1" android:propertyName="trimPathEnd"
      xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" />

the problematic $avd_(show|hide)_password__<n>.xml files of these composite resources are never referenced from code. they are only referenced from their corresponding main resource files avd_(show|hide)_password.xml.

this allows a simple workaround: you can manually rename the problematic files to make their names valid, along with their references in the main resource files. you can choose any names you want, but simply removing the dollar signs should be fine.

this workaround is a temporary stopgap measure. i'll be investigating ways to handle these corner cases in a more automated way.

Not able to download v2.1.0 from maven repo

Was wondering if dexpatcher repo has been updated.

A side question, will the patches continue to work on if I want to use the latest v2.1.1+ given they're in maven repo as well? I see the release notes say apk library won't work.

Issue when target sdk version 30

Hi Lanchon, long time no see. Currently I'm having a little problem when the target sdk version 30 makes some features not working. After some googling, I think the problem is here: iBotPeaches/Apktool#2421

And one more problem, kotlin folder in original apk is removed

ERROR: "Execution failed for task ':app:compileDebugJavaWithJavac'. Could not expand ZIP" (Issues with files named AUX,CON, PRN, CLOCK$, NUL, COM<#>, LPT<#> on Windows)

Hi

In my latest app edit, I've got the error "Execution failed for task ':app:compileDebugJavaWithJavac'. Could not expand ZIP".
Looking on the stacktrace show me that the error occurs when the file "aux.class" are behind copying.
After some research I've figurate that this (along with AUX,CON, PRN, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9) are not allowed as file name in windows.
Apktool solution is to add # at the end of the file name in this case (so it's will be "aux#.class")

The full stacktrace is:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
	at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
	at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
	at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
	at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
	at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
	at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
	at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
	at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153)
	at org.gradle.internal.Factories$1.create(Factories.java:22)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)
	at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
	at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
	at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
	at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
	at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)
	at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
	at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
	at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:237)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
	at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.GradleException: Could not expand ZIP 'C:\app\build\intermediates\dexpatcher\dedex\classes.jar'.
	at org.gradle.api.internal.file.archive.ZipFileTree.visit(ZipFileTree.java:98)
	at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:109)
	at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl.visit(AbstractFileTree.java:141)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotter.createSnapshot(DefaultJarSnapshotter.java:45)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotter.createSnapshot(DefaultJarSnapshotter.java:40)
	at org.gradle.api.internal.tasks.compile.incremental.jar.CachingJarSnapshotter$1.create(CachingJarSnapshotter.java:45)
	at org.gradle.api.internal.tasks.compile.incremental.jar.CachingJarSnapshotter$1.create(CachingJarSnapshotter.java:43)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotCache$2.create(DefaultJarSnapshotCache.java:59)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotCache$2.create(DefaultJarSnapshotCache.java:57)
	at org.gradle.api.internal.cache.MinimalPersistentCache.get(MinimalPersistentCache.java:66)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotCache.get(DefaultJarSnapshotCache.java:57)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotCache.get(DefaultJarSnapshotCache.java:33)
	at org.gradle.api.internal.tasks.compile.incremental.jar.CachingJarSnapshotter.createSnapshot(CachingJarSnapshotter.java:43)
	at org.gradle.api.internal.tasks.compile.incremental.jar.JarClasspathSnapshotFactory.createSnapshot(JarClasspathSnapshotFactory.java:42)
	at org.gradle.api.internal.tasks.compile.incremental.jar.JarClasspathSnapshotMaker.maybeInitialize(JarClasspathSnapshotMaker.java:62)
	at org.gradle.api.internal.tasks.compile.incremental.jar.JarClasspathSnapshotMaker.storeJarSnapshots(JarClasspathSnapshotMaker.java:43)
	at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:47)
	at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:24)
	at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:163)
	at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:127)
	at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
	... 70 more
Caused by: org.gradle.api.GradleException: Could not copy zip entry C:\app\build\intermediates\dexpatcher\dedex\classes.jar!com/testapp/aux.class to 'C:\app\build\tmp\expandedArchives\classes.jar_axg7rbngy6pzxyi7v1bgmd8wd\com\testapp\aux.class'.
	at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:79)
	at org.gradle.api.internal.file.archive.ZipFileTree$DetailsImpl.getFile(ZipFileTree.java:130)
	at org.gradle.api.internal.tasks.compile.incremental.analyzer.ClassFilesAnalyzer.visitFile(ClassFilesAnalyzer.java:49)
	at org.gradle.api.internal.tasks.compile.incremental.jar.DefaultJarSnapshotter$1.visitFile(DefaultJarSnapshotter.java:50)
	at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl$1.visitFile(AbstractFileTree.java:150)
	at org.gradle.api.internal.file.archive.ZipFileTree.visit(ZipFileTree.java:91)
	... 97 more
Caused by: java.io.FileNotFoundException: C:\app\build\tmp\expandedArchives\classes.jar_axg7rbngy6pzxyi7v1bgmd8wd\com\testapp\aux.class (The system cannot find the file specified)
	at org.gradle.api.internal.file.AbstractFileTreeElement.copyFile(AbstractFileTreeElement.java:91)
	at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:74)
	... 102 more

Package name clashes with class name

How can I modify a member of such package?
I'm trying to edit com.somedomain.a.a but there's also a class named com.somedomain.a.

Btw, DexPatcher is a great tool, thank you for developing it :-)

Validate android extension object values (API level, etc) against APK library.

In the 'patched-application' plugin, add a task that warns or fails if the values set on the android extension object (API level, etc) are incompatible with the values from the APK library being patched. Otherwise, make the 'apk-library' task annotate the APK library manifest with the minimum requirements. Both options require parsing the 'yml' file produced by apktool.

Add a new plugin that uses apktool instead of aapt to rebuild apps.

This plugin would be simpler to use and produce a more faithful app to the original than the current 'patched-application' plugin, but would not support android's build system and in particular its resource processing. All resource edits would need to be done in apktool's output, and adding android libraries, etc would not be possible. This plugin would be especially useful for cases in which you just want to edit code.

[dexpatcher-gradle] ?

Hi Lanchon, long time no see, DexPatcher is awesome and I still use it everyday. But I have a question, do you intend to continue developing for DexPatcher in the near future?

Replace the DexTag type with a parameter annotation.

This is an embarrassing mistake. I designed and implemented DexPatcher in a couple of days, and I had never really used Java annotations before.

Because in Java you cannot rename a constructor, if you want to invoke the original constructor from a replacement constructor, you need to add a tag parameter to overload it instead. DexPatcher 1.0.0 recognizes a tag parameter by detecting the specific hardcoded type 'lanchon.dexpatcher.annotation.DexTag', which is bundled in the annotations Jar, and must be included in final executable.

This idiom is typically used to patch a constructor:

@DexEdit
MyClass(String data, DexTag tag) {}

@DexAdd
MyClass(String data) {
    this(filterData(data), DexTag.TAG);
    doMoreStuff();
}

I used a tag type instead of a parameter annotation because I thought that parameter annotations were a Java 1.8 feature, when in fact they are supported in Java 1.7. The downside to this is that an app can easily detect that it has been patched by DexPatcher by checking for this tag type.

To avoid this problem, the tagging mechanism should be changed to a parameter annotation applicable to any type (including primitive types). A suggested name for the annotation is 'DexTagParameter'. Alternatively, the existing 'DexIgnore' annotation could be overloaded for this use.

The end result would look like this:

@DexEdit
MyClass(String data, @DexTagParameter int tag) {}

@DexAdd
MyClass(String data) {
    this(filterData(data), 0);
    doMoreStuff();
}

It might be better if the 'DexTag' name goes unused to guarantee compile time errors in old code. But most code would reference 'DexTag.TAG' anyway, and if not the resulting patch would fail to apply, so this is not hard requirement.

Invalid character for resource

Patching a 3rd party APK fails because of some "invalid" characters found in resource names. For example :

res/drawable-v21/$avd_show_password__2.xml

I've read the whole XDA post, and I understand that's an aapt limitation, but it's still not clear to me what's the official recommended workaround. I'm not interested in patching those resources (if any at all).

Any recommendation?

Every second build fails due to compiler not finding things changed with DexReplace

originally filed by: @andrewleech
moved to new issue by Lanchon


often every second build fails due to the compiler not finding a bunch of things I've changed with DexReplace. I hit build again and it always works though. Have you seen this? Thinking about it now, it might be from cases


the build issue I get, it's reliable for me with this project, this commit: https://gitlab.com/alelec/fossil_smartwatches_alelec_android/tree/9c8fecfea815dbf33c68e13b5c78498bce3773b8
It should just checkout and build, I'm currently on Android Studio 3.5.1 (though I've had this issue for a long time now)
Basically build, it works. build again, it's still fine (it doesn't re-compile anything). If I make one change (even just change formatting on a file, no functional change) the build fails, with the first failure being

> Task :compileDebugJavaWithJavac
C:\Users\corona\src\fossil_app\src\main\java\com\portfolio\platform\MigrationManager.java:761: error: constructor Device in class Device cannot be applied to given types;
                Device device = new Device(
                                ^
  required: String,String,String,String,int,Integer,boolean
  found: String,String,String,String,int,int,boolean,int,<null>

In this case, jadx decompiles a number of functions like this with a couple more args than the builtin decompilers comes up with. So I've got the jadx copy sitting there completely DexIgnored and that satisfies the compiler (every second time) and function calls I make to the long version seem to work fine in practice. But every other time, the compiler only sees the jar version and complains the signature's wrong. Not the end of the world, I just compile again, but a bit odd nonetheless.

Disable the workarounds for android build system bugs as they are fixed.

Disable the workarounds that I implemented in the plugins for android build system bugs as they are fixed in the source. Ideally done conditionally after checking the android build system version.

https://github.com/Lanchon/DexPatcher-gradle/blob/v0.1.1/src/main/groovy/lanchon/dexpatcher/gradle/PatcherPlugin.groovy#L290-L338

https://code.google.com/p/android/issues/detail?id=170153
https://code.google.com/p/android/issues/detail?id=172048

Can't run patched-app, "undeclared repository artifact"

The error

A problem occurred configuring root project 'patched-app'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.github.lanchon.dexpatcher:dexpatcher-gradle:2.1.3.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/github/lanchon/dexpatcher/dexpatcher-gradle/2.1.3/dexpatcher-gradle-2.1.3.pom
       - https://jcenter.bintray.com/com/github/lanchon/dexpatcher/dexpatcher-gradle/2.1.3/dexpatcher-gradle-2.1.3.pom
       - https://plugins.gradle.org/m2/com/github/lanchon/dexpatcher/dexpatcher-gradle/2.1.3/dexpatcher-gradle-2.1.3.pom
       - file:/C:/Users/0/Desktop/dexpatcher-gradle/build/libs/dexpatcher-gradle-2.1.3.jar
       - file:/C:/Users/0/Desktop/dexpatcher-gradle/build/libs/dexpatcher-gradle.jar
     Required by:
         project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Steps to reproduce

  1. Install latest Android Studio version (Windows 10)
  2. Clone https://github.com/DexPatcher/dexpatcher-gradle-samples
  3. Open "patched-app" project with Android Studio
  4. Running the app

What i've tried to fix this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.