From fe6b86197f2c8768fb0c9839fb640a860a38cfbd Mon Sep 17 00:00:00 2001 From: REAndroid Date: Tue, 20 Dec 2022 05:34:24 -0500 Subject: [PATCH] V1.0.8 --- LICENSE | 2 +- README.md | 52 ++++++++++++++++++++++++++-------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/LICENSE b/LICENSE index 261eeb9..d245c32 100755 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright [2023] [github.com/REAndroid] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 7994935..32d1e15 100755 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # ARSCLib ## Android binary resources read/write java library This library is developed based on AOSP structure of androidfw/ResourceTypes.h , to totally replace aapt/aapt2 -### Read, write, modify and create +#### Read, write, modify and create * Resource table (resources.arsc) * Binary xml files (AndroidManifest.xml & resource xml) -### Convert from/to json string +#### Convert from/to json string * Decompiling resources to readable XML using traditional techniques is now becoming very challenging due to resource obfuscation (like Proguard & ResGuard) * Just like SMALI coding this library brings unbeatable coding style @@ -13,20 +13,20 @@ This library is developed based on AOSP structure of androidfw/ResourceTypes.h , ``` can be represented in json as ```json - { - "entry_name": "app_name", - "id": 16, - "value": { - "value_type": "STRING", - "data": "My Application" - } + { + "entry_name": "app_name", + "id": 16, + "value": { + "value_type": "STRING", + "data": "My Application" + } ``` -### Works on all java supported platforms (Android, Linux, Windows) +#### Works on all java supported platforms (Android, Linux, Windows) * Use the jar file as dependency -### Check this tool developed using this library +#### Check this tool developed using this library [https://github.com/REAndroid/APKEditor](https://github.com/REAndroid/APKEditor) -
See java example +
See java example ```java import com.reandroid.lib.arsc.chunk.TableBlock; @@ -35,7 +35,7 @@ import com.reandroid.lib.arsc.chunk.xml.AndroidManifestBlock; import com.reandroid.lib.arsc.chunk.xml.ResXmlElement; import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute; - public static void exampleManifest() throws IOException{ +public static void exampleManifest() throws IOException{ File inFile=new File("AndroidManifest.xml"); // *** Loading AndroidManifest *** @@ -45,7 +45,7 @@ import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute; List usesPermissionList = manifestBlock.getUsesPermissions(); for(String usesPermission:usesPermissionList){ - System.out.println("Uses permission: "+usesPermission); + System.out.println("Uses permission: "+usesPermission); } // *** Modifying AndroidManifest *** @@ -61,11 +61,11 @@ import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute; // Modify xml attribute List activityList = manifestBlock.listActivities(); for(ResXmlElement activityElement:activityList){ - ResXmlAttribute attributeName = activityElement.searchAttributeByResourceId(AndroidManifestBlock.ID_name); - System.out.println("Old activity name: "+attributeName.getValueAsString()); - attributeName.setValueAsString("com.app.MyActivity"); - System.out.println("New activity name: "+attributeName.getValueAsString()); - break; + ResXmlAttribute attributeName = activityElement.searchAttributeByResourceId(AndroidManifestBlock.ID_name); + System.out.println("Old activity name: "+attributeName.getValueAsString()); + attributeName.setValueAsString("com.app.MyActivity"); + System.out.println("New activity name: "+attributeName.getValueAsString()); + break; } // Refresh to re-calculate offsets @@ -75,7 +75,7 @@ import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute; manifestBlock.writeBytes(outFile); System.out.println("Saved: "+outFile); - } + } ``` @@ -91,16 +91,16 @@ import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute; Collection packageBlockList=tableBlock.listPackages(); System.out.println("Packages count = "+packageBlockList.size()); for(PackageBlock packageBlock:packageBlockList){ - System.out.println("Package id = "+packageBlock.getId() - +", name = "+packageBlock.getName()); + System.out.println("Package id = "+packageBlock.getId() + +", name = "+packageBlock.getName()); } // *** Modify resource table // Change package name for(PackageBlock packageBlock:packageBlockList){ - String name = packageBlock.getName(); - String newName = name + ".new-name"; - packageBlock.setName(newName); + String name = packageBlock.getName(); + String newName = name + ".new-name"; + packageBlock.setName(newName); } // Refresh to re-calculate offsets @@ -110,7 +110,7 @@ import com.reandroid.lib.arsc.chunk.xml.ResXmlAttribute; tableBlock.writeBytes(outFile); System.out.println("Saved: "+outFile); - } + } ```