DexPatcher / dexpatcher-gradle

Modify Android applications at source-level in Android Studio
https://dexpatcher.github.io/
GNU General Public License v3.0
83 stars 17 forks source link

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

Open mindrunner opened 5 years ago

mindrunner commented 5 years ago

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.
Lanchon commented 5 years ago

hi

first try a round trip with apktool. does that work?

mindrunner commented 5 years ago
[le@w530]: /tmp/apk>$ apktool d app.apk 
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=lcd -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
I: Using Apktool 2.4.0 on app.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
S: WARNING: Could not write to (/home/le/.local/share/apktool/framework), using /tmp instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
I: Loading resource table from file: /tmp/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
[le@w530]: /tmp/apk>$ apktool b app
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=lcd -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
I: Using Apktool 2.4.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
S: WARNING: Could not write to (/home/le/.local/share/apktool/framework), using /tmp instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
W: /tmp/apk/app/AndroidManifest.xml:9: Tag <application> attribute name has invalid character 'p'.
W: /tmp/apk/app/AndroidManifest.xml:32: Tag <activity> attribute name has invalid character '@'.
W: /tmp/apk/app/AndroidManifest.xml:48: Tag <activity> attribute name has invalid character 'U'.
W: /tmp/apk/app/AndroidManifest.xml:49: Tag <activity> attribute name has invalid character ')'.
W: /tmp/apk/app/AndroidManifest.xml:50: Tag <activity> attribute name has invalid character '�'.
W: /tmp/apk/app/AndroidManifest.xml:51: Tag <activity> attribute name has invalid character ' '.
W: /tmp/apk/app/AndroidManifest.xml:52: Tag <activity> attribute name has invalid character '�'.
W: /tmp/apk/app/AndroidManifest.xml:53: Tag <activity> attribute name has invalid character '�'.
W: /tmp/apk/app/AndroidManifest.xml:54: Tag <activity> attribute name has invalid character '�'.
W: /tmp/apk/app/AndroidManifest.xml:63: Tag <provider> attribute name has invalid character ''.
W: /tmp/apk/app/AndroidManifest.xml:64: Tag <provider> attribute name has invalid character '@'.
W: /tmp/apk/app/AndroidManifest.xml:65: Tag <provider> attribute name has invalid character 'W'.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_1404317778591561696.tmp, p, --forced-package-id, 127, --min-sdk-version, 14, --target-sdk-version, 27, --version-code, 4024404, --version-name, 4.24.4, --no-version-vectors, -F, /tmp/APKTOOL7608711109482947539.tmp, -0, arsc, -0, arsc, -I, /tmp/1.apk, -S, /tmp/apk/app/res, -M, /tmp/apk/app/AndroidManifest.xml]
mindrunner commented 5 years ago

i did an apktool roundtrip, excluding the resources. that worked fine. but I would like to inject java code instead of smali, thus would like to use dexpatcher. would probably save me some time ;)

Lanchon commented 5 years ago

please explain better. im away from computer. what do you mean by "excluding the resources"?

mindrunner commented 5 years ago

--no-res exports only source, and no resources. with that, the roundtrip works fine.

[le@w530]: ~/src/dexpatcher-test>$ apktool --help
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=lcd -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Unrecognized option: --help
Apktool v2.4.0 - a tool for reengineering Android apk files
with smali v2.2.6 and baksmali v2.2.6
Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
Updated by Connor Tumbleson <connor.tumbleson@gmail.com>

usage: apktool
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
 -p,--frame-path <dir>   Stores framework files into <dir>.
 -t,--tag <tag>          Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
 -f,--force              Force delete destination directory.
 -o,--output <dir>       The name of folder that gets written. Default is apk.out
 -p,--frame-path <dir>   Uses framework files located in <dir>.
 -r,--no-res             Do not decode resources.
 -s,--no-src             Do not decode sources.
 -t,--frame-tag <tag>    Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
 -f,--force-all          Skip changes detection and build all files.
 -o,--output <dir>       The name of apk that gets written. Default is dist/name.apk
 -p,--frame-path <dir>   Uses framework files located in <dir>.

For additional info, see: http://ibotpeaches.github.io/Apktool/ 
For smali/baksmali info, see: https://github.com/JesusFreke/smali
Lanchon commented 5 years ago

thanks. please report the problem to the apktool team. the dexpatcher gradle plugin does not have a solution to patch only code, but you can do it manually using dexpatcher-tool. also see that "patch-dex" sample. sorry i cant help you more.

mindrunner commented 5 years ago

What do you mean by dexpatcher-tool?

Lanchon commented 5 years ago

there is a repo called exactly that here.

mindrunner commented 5 years ago

cheers, thank you. I will have a look!