Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG] Just decompile and compile error: attribute state_liftable (aka xxxx:state_liftable) not found

Open phoenixsky opened this issue 2 years ago • 3 comments

Information

  1. Apktool Version (apktool -version) - 2.5.0
  2. Operating System (Mac, Linux, Windows) - mac
  3. APK From? (Playstore, ROM, Other) -

Stacktrace/Logcat

I: Using Apktool 2.5.0 on source.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: ~/Library/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes5.dex file...
I: Copying raw assets/39285EFA.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...


java -jar tools/apktool/apktool.jar b force/source -o force/target.apk --use-aapt2

Using Apktool 2.5.0
I: Copying force/source classes.dex file...
I: Checking whether resources has changed...
I: Building resources...
W: force/source/res/animator/arg.xml:4: error: attribute state_liftable (aka com.linglong.weather.clear:state_liftable) not found.
W: force/source/res/animator/arg.xml:4: error: attribute state_lifted (aka com.linglong.weather.clear:state_lifted) not found.
W: force/source/res/animator/arg_APKTOOL_DUPLICATENAME_0x7f020006.xml:4: error: attribute state_dragged (aka com.linglong.weather.clear:state_dragged) not found.
W: force/source/res/color/arg_APKTOOL_DUPLICATENAME_0x7f05015b.xml:5: error: attribute state_dragged (aka com.linglong.weather.clear:state_dragged) not found.
W: force/source/res/color/arg_APKTOOL_DUPLICATENAME_0x7f05015b.xml:6: error: attribute state_dragged (aka com.linglong.weather.clear:state_dragged) not found.
W: force/source/res/color/arg_APKTOOL_DUPLICATENAME_0x7f05015c.xml:5: error: attribute state_dragged (aka com.linglong.weather.clear:state_dragged) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b0003.xml:2: error: attribute divider (aka com.linglong.weather.clear:divider) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b0003.xml:2: error: attribute dividerPadding (aka com.linglong.weather.clear:dividerPadding) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b0005.xml:2: error: attribute srcCompat (aka com.linglong.weather.clear:srcCompat) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b0017.xml:6: error: attribute navigationContentDescription (aka com.linglong.weather.clear:navigationContentDescription) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001a.xml:2: error: attribute paddingBottomNoButtons (aka com.linglong.weather.clear:paddingBottomNoButtons) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001a.xml:2: error: attribute paddingTopNoTitle (aka com.linglong.weather.clear:paddingTopNoTitle) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001e.xml:4: error: attribute navigationIcon (aka com.linglong.weather.clear:navigationIcon) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001e.xml:4: error: attribute title (aka com.linglong.weather.clear:title) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001e.xml:4: error: attribute titleTextColor (aka com.linglong.weather.clear:titleTextColor) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001f.xml:4: error: attribute contentInsetStart (aka com.linglong.weather.clear:contentInsetStart) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001f.xml:4: error: attribute navigationIcon (aka com.linglong.weather.clear:navigationIcon) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001f.xml:4: error: attribute title (aka com.linglong.weather.clear:title) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001f.xml:5: error: attribute tabIndicatorFullWidth (aka com.linglong.weather.clear:tabIndicatorFullWidth) not found.
W: force/source/res/layout/arg_APKTOOL_DUPLICATENAME_0x7f0b001f.xml:5: error: attribute tabIndicatorHeight (aka com.linglong.weather.clear:tabIndicatorHeight) not found.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/lj/882d498j02g8ncmjqwvxkvt40000gn/T/brut_util_Jar_33868995866635642102732509488293101559.tmp, link, -o, /var/folders/lj/882d498j02g8ncmjqwvxkvt40000gn/T/APKTOOL6911472127140674883.tmp, --package-id, 127, --min-sdk-version, 21, --target-sdk-version, 26, --version-code, 263, --version-name, 3.2.6.r656, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, -e, /var/folders/lj/882d498j02g8ncmjqwvxkvt40000gn/T/APKTOOL8824718918896658626.tmp, -0, arsc, -I, ~/Library/apktool/framework/1.apk, --manifest, ~/Dev/Code/Android/Shell/dex-shell/shell_util/force/source/AndroidManifest.xml, ~/Dev/Code/Android/Shell/dex-shell/shell_util/force/source/build/resources.zip]

Steps to Reproduce

  1. java -jar tools/apktool/apktool.jar -s d force/source.apk -o force/source
  2. java -jar tools/apktool/apktool.jar b force/source -o force/target.apk --use-aapt2

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files (.apks that live in /system/framework or /system/priv-app) no

APK

If this APK can be freely shared, please upload/attach a link to it. source.zip change .zip to .apk

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? yeal
  2. If you are trying to install a modified apk, did you resign it? yes
  3. Are you using the latest apktool version? yes

phoenixsky avatar Jul 16 '21 16:07 phoenixsky

the issues here is that the apk is obfuscated, and when the apk is obfuscated the attribute will be missing and stripped, you can bypass the error by just adding the attribute in file:/res/values/attrs.xml and add this line: the same for the other attributes, just add them with according type:format="reference", format="string"format="float", format="dimension", format="color"

ninovalboskoni avatar Jul 18 '21 14:07 ninovalboskoni

Is it possible for each error: attribute XXX(aka com.company:XXX) not found. to automatically add <attr name="XXX" format="reference|string|integer|boolean|color|float|dimension|fraction" /> to .../res/values/attrs.xml file?

Is it will work? @iBotPeaches

AlttiRi avatar Nov 13 '21 03:11 AlttiRi

Have experienced the same thing happening while recompiling Phonesky/PlayStore from here, making no changes.

New stripped attribute errors were discovered everytime I fixed the existing errors, so I handled it programmatically with a loop:

err='^W: .*:.*: error: attribute .* \(aka .*:.*\) not found\.$'
fmt='    <attr name="%s" format="reference|string|integer|boolean|color|float|dimension|fraction" />\n'
while ! apktool b --use-aapt2 2>./.tmpa; do
    cat ./.tmpa;
    cat ./.tmpa | grep -qE "$err" || break;
    echo "-> adding more attrs";
    cat ./.tmpa | awk "/$err/"'{ print $(NF-4) }' | sort -u | xargs printf "$fmt" > ./.tmpb;
    sed -i '2r ./.tmpb' ./res/values/attrs.xml;
done;
rm ./.tmpa ./.tmpb;

But it would be nice if the tool itself handled this.

Phonesky build successfully after this (had to use nightly CI jar for apktool).

im seeing this issue using apk.sh which is using apktool 2.7.0

le91688 avatar Apr 25 '23 14:04 le91688