ARSCLib icon indicating copy to clipboard operation
ARSCLib copied to clipboard

Build Error: illegal attribute name: :tint

Open AbhiTheModder opened this issue 5 months ago • 6 comments

Creating the issue here as I believe this issue is related to ARSCLib side.

[BUILD] Using: APKEditor version 1.4.3, ARSCLib version 1.3.6
            -t = xml                                                            
      -dex-lib = jf                                                             
            -i = /home/abhi/merged_app_decompile      
            -o = "/home/abhi/Amaha                    
               = (InnerHour)_3.111.3-patched.apk"                               
 ______________________________________________________________________________ 
00.019 I: [BUILD] Scanning XML directory ...
00.073 I: [BUILD] Scanning: merged_app_decompile
00.475 I: [BUILD] Initializing android framework ...
00.476 I: [BUILD] Loading android framework for version: 35
00.776 I: [BUILD] Initialized framework: android-35 (15)
00.777 I: [BUILD] Set main package id from manifest: @mipmap/ic_launcher
00.781 I: [BUILD] Main package id initialized: id = 0x7f, from: @mipmap/ic_launcher
00.781 I: [BUILD] Encoding attrs ...
00.911 I: [BUILD] Encoding values ...
02.558 I: [BUILD] Scan: package_1/res
02.739 I: [BUILD] Scanned 4548 files: package_1/res
03.147 I: [BUILD] Add manifest: AndroidManifest.xml
03.148 I: [BUILD] Building dex ...
03.477 I: [BUILD] (1/4) Smali<JF>: classes.dex
18.448 I: [BUILD] (2/4) Smali<JF>: classes2.dex
27.205 I: [BUILD] (3/4) Cached: classes3.dex
27.210 I: [BUILD] (4/4) Cached: classes4.dex
27.210 I: [BUILD] Scanning root directory ...
27.217 I: [BUILD] Restoring original file paths ...
27.249 I: [BUILD] Loading signatures ...
27.254 I: [BUILD] Sorting files ...
27.313 I: [BUILD] Refreshing resource table ...
27.443 I: [BUILD] TableBlock: packages = 1, size = 4510116 bytes
27.443 I: [BUILD] Applying: extractNativeLibs=true
27.443 I: [BUILD] Writing apk...
27.470 I: [BUILD] Buffering compress changed files ...

ERROR:
java.io.IOException: org.xmlpull.v1.XmlPullParserException: illegal attribute name: :tint (position: at /home/abhi/merged_app_decompile/resources/package_1/res/layout/fragment_screen_s13.xml [91:39]
START_TAG (empty) <ImageButton android:textColor='@color/seaSerpent' android:id='@id/imgTextAdd' android:background='@color/transparent' android:paddingTop='5.0dp' android:visibility='invisible' android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginRight='16.0dp' android:layout_marginBottom='16.0dp' android:layout_alignParentRight='true' android:layout_marginEnd='16.0dp' app:srcCompat='@drawable/ic_check_circle' app:tint='@color/template_grey_1' :tint='@color/sea'>) 
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.getArray(XMLEncodeSource.java:67)
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.write(XMLEncodeSource.java:41)
	at com.reandroid.archive.writer.OutputSource.writeBuffer(OutputSource.java:58)
	at com.reandroid.archive.writer.FileOutputSource.writeBuffer(FileOutputSource.java:46)
	at com.reandroid.archive.writer.FileOutputSource.makeBuffer(FileOutputSource.java:42)
	at com.reandroid.archive.writer.ApkFileWriter.writeBuffer(ApkFileWriter.java:81)
	at com.reandroid.archive.writer.ApkFileWriter.prepareOutputs(ApkFileWriter.java:43)
	at com.reandroid.archive.writer.ApkFileWriter.prepareOutputs(ApkFileWriter.java:27)
	at com.reandroid.archive.writer.ApkWriter.write(ApkWriter.java:51)
	at com.reandroid.apk.ApkModule.writeApk(ApkModule.java:504)
	at com.reandroid.apkeditor.compile.Builder.writeApk(Builder.java:138)
	at com.reandroid.apkeditor.compile.Builder.buildXml(Builder.java:108)
	at com.reandroid.apkeditor.compile.Builder.runCommand(Builder.java:46)
	at com.reandroid.apkeditor.Options.runCommand(Options.java:59)
	at com.reandroid.apkeditor.Main.run(Main.java:136)
	at com.reandroid.apkeditor.Main.execute(Main.java:72)
	at com.reandroid.apkeditor.Main.main(Main.java:57)
Caused by: org.xmlpull.v1.XmlPullParserException: illegal attribute name: :tint (position: at /home/abhi/merged_app_decompile/resources/package_1/res/layout/fragment_screen_s13.xml [91:39]
START_TAG (empty) <ImageButton android:textColor='@color/seaSerpent' android:id='@id/imgTextAdd' android:background='@color/transparent' android:paddingTop='5.0dp' android:visibility='invisible' android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginRight='16.0dp' android:layout_marginBottom='16.0dp' android:layout_alignParentRight='true' android:layout_marginEnd='16.0dp' app:srcCompat='@drawable/ic_check_circle' app:tint='@color/template_grey_1' :tint='@color/sea'>) 
	at com.reandroid.xml.kxml2.KXmlParser.adjustNsp(KXmlParser.java:254)
	at com.reandroid.xml.kxml2.KXmlParser.parseStartTag(KXmlParser.java:1158)
	at com.reandroid.xml.kxml2.KXmlParser.next(KXmlParser.java:376)
	at com.reandroid.xml.kxml2.KXmlParser.nextToken(KXmlParser.java:321)
	at com.reandroid.xml.CloseableParser.nextToken(CloseableParser.java:55)
	at com.reandroid.arsc.chunk.xml.ResXmlTextNode.parse(ResXmlTextNode.java:197)
	at com.reandroid.arsc.chunk.xml.ResXmlDocumentOrElement.parseInnerNodes(ResXmlDocumentOrElement.java:275)
	at com.reandroid.arsc.chunk.xml.ResXmlElement.parse(ResXmlElement.java:527)
	at com.reandroid.arsc.chunk.xml.ResXmlDocumentOrElement.parseInnerNodes(ResXmlDocumentOrElement.java:275)
	at com.reandroid.arsc.chunk.xml.ResXmlElement.parse(ResXmlElement.java:527)
	at com.reandroid.arsc.chunk.xml.ResXmlDocumentOrElement.parseInnerNodes(ResXmlDocumentOrElement.java:275)
	at com.reandroid.arsc.chunk.xml.ResXmlDocument.parse(ResXmlDocument.java:276)
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.encode(XMLEncodeSource.java:83)
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.getArray(XMLEncodeSource.java:65)
	... 16 more

Application: Amaha (InnerHour) 3.111.3-276 Play Store: https://play.google.com/store/apps/details?id=com.theinnerhour.b2b

AbhiTheModder avatar Jul 14 '25 16:07 AbhiTheModder

I assumed you are familiar with flag -t json. This is in json format of the troubled attributes:

{
  "name": "tint",
  "id": 2130970158,
  "uri": "http://schemas.android.com/apk/res-auto",
  "prefix": "app",
  "value_type": "REFERENCE",
  "data": 2131100782
},
{
  "name": ":tint",
  "id": 0,
  "value_type": "REFERENCE",
  "data": 2131100712
}

The colon : character is not allowed on xml attribute name, do you have suggestion to serialize such cases ?

REAndroid avatar Jul 14 '25 17:07 REAndroid

The colon : character is not allowed on xml attribute name, do you have suggestion to serialize such cases ?

From what I can understand, it looks like :tint is an invalid attribute as its ID 0 and it lacks any namespace prefix as well, so it’s best to exclude it. In this case, we already have app:tint defined, which is both valid and more compatible than alternatives like android:tint, so no need to consider them.

AbhiTheModder avatar Jul 15 '25 16:07 AbhiTheModder

Here the complainer is xml pull parser NOT android os binary parser. Assuming attribute as useless just bc no ID or no namespace is wrong. If an attribute has non zero name id, the name doesn't matter at all and you can set even blank (as progard do). However if name id is zero then the binary parser relies on literal string name. Thus from your set of attributes calling BinaryParser#getAttribute("tint") results the attribute with id==0, but if you remove this attribute the parser results null.

If you dig your dex am sure it is been implemented somewhere, as per my experience such cases are not accidental or mistake.

PS: This is one of the reason decoding to json was implemented.

Not sure if he still active on this area but @MuntashirAkon has done a lot of similar research and can explain better.

REAndroid avatar Jul 15 '25 22:07 REAndroid

@REAndroid Agreed, I don't have much experience with it (also this is my first time encountering such a case). My assumption was based on the presence of the app:tint attribute majorly than its ID & namespace, which led me to believe it was unnecessary. However, if it is a result of ProGuard or a similar tool, then your points are indeed valid, and the latter (ProGuard) is more likely the case than my initial assumption.

Found a similar related discussion(s) on apktool repo: https://github.com/iBotPeaches/Apktool/issues/1407 https://github.com/iBotPeaches/Apktool/issues/2420

AbhiTheModder avatar Jul 16 '25 06:07 AbhiTheModder

See xml specification NT-NameChar, we strictly follow universal xml specifications and can not force modify to parse illegal name characters like :. This is one of the weakness of XML, that is why we offered lossless json throughout all encode/decoding.

REAndroid avatar Jul 17 '25 12:07 REAndroid

See xml specification NT-NameChar

Thanks for the reference article, I had a good time reading this. Much appreciated.

AbhiTheModder avatar Jul 19 '25 08:07 AbhiTheModder