Developed and tested on Linux. Its a shell script that requires the Android SDK to be installed with the tools directory in the PATH variable.
INTRO
Android Binary Resource Compiler (abrc). This is a command-line
script to compile resources such as NinePatch PNGs and layout XML
files to Android binary format. The compiled resources named in the
command are extracted and saved out into a separate location. This
script was developed as an alternative to using Eclipse and "unzip" to
compile and extract NinePatch PNGs during the creation of custom
Android UI themes.
USAGE
abrc usage
abrc help
abrc [options] compile <project dir> <output dir> <resource file1> <resource file2> ...
abrc [options] setup <project dir>
OPTIONS:
-v Enable verbose output
-o Overwrite files without prompting
Click to expand...
Click to collapse
COMPILE
The compile operation compiles the resources in the <project dir>
location. This can be any Android Eclipse project directory which
contains the resources you wish to compile and extract. You can also
use this script's "setup" syntax to create a minimal project without
using Eclipse. See the SETUP section below for more information.
The named resource files <resource file1> <resource file2>, etc., are
then extracted into the <output directory>. Parent path components in
the resource file names are preserved and also determine the extracted
location within the output directory.
Example:
Consider the following path in "MyProject" which contains, among other
things, the statusbar_background.9.png file. This file is in the format
created by draw9patch program.
MyProject/res/drawable-mdpi/statusbar_background.9.png
The following command compiles the resources in MyProject and writes
the output to the MyTheme/framework-res directory using the leading
path components of the specified resource file(s). I.e., In this
example the resulting output file is
MyTheme/framework-res/res/drawable-mdpi/statusbar_background.9.png
abrc compile MyProject MyTheme/framework-res res/drawable-mdpi/statusbar_background.9.png
Click to expand...
Click to collapse
SETUP
The setup operation is completely optional. It creates a minimal
project skeleton for compiling resources. Eclipse projects can also
be used in the compile step above.
abrc setup MyProject
Click to expand...
Click to collapse
The above command creates the following directory structure/files:
MyProject/res/drawable
MyProject/res/drawable-mdpi
MyProject/res/drawable-hdpi
MyProject/res/layout
MyProject/AndroidManifest.xml
Click to expand...
Click to collapse
Copy your resources into the appropriate location within the project
and then use the compile operation to compile and extract the binary
files.
How does it work? It calls aapt and then unzip compiled resources? It's too small to do this directly.
Yes, that's what it does. It's just a shell script so you can look at it and see. There are some comments in the script that explains things.
It relies on the Android SDK which is assumed to already be installed.
Sent from my FroyoEris using XDA App
Nice! Makes a lot of things easier.
how can we use this script with windows 7?
h_zee13 said:
how can we use this script with windows 7?
Click to expand...
Click to collapse
There's a chance it might work using Cygwin (www.cygwin.com). Be sure to include the zip compression utilities package when installing.
this is great! i hated having to fire up eclipse for this. thanks!
This is a great tool. It was a little confusing at first, I don't think I had my path set up correctly. I've found the easiest way to use this, for me anyway, was to use the setup command and make a new folder with it, I deleted the m and ldpi folders because i'm not using them, copied my .9s into the drawable-hdpi folder, and from inside the "project" directory ran,
abrc compile . done res/drawable-hdpi/*
This compiles all the images in there and places them in the done folder.
Hope i'm not stepping on any toes, just what I found to be the easiest after placing aapt in /usr/tools/ and android.jar in /usr/ as I was kinda confused when I first downloaded it.
abrc for cygwin
h_zee13 said:
how can we use this script with windows 7?
Click to expand...
Click to collapse
I've edited this script and it works on cygwin. go here and download it. -> https ://plus.google.com/118270346235276777406/posts/EJGWifY5kTh
so im trying to get this to work but no luck if someone could help me
first i set paths
Code:
export PATH=${PATH}:/home/suphi/Documents/android-sdk-linux/tools:/home/suphi/Documents/android-sdk-linux/platform-tools:/home/suphi/Documents/android-sdk-linux/apktool
then i run this code
Code:
abrc compile before after res/drawable-hdpi/*
then i get this error
Code:
Using aapt to compile resources to /tmp/resources-82KEfVduDK.zip
W/asset ( 4429): Asset path /home/suphi/Documents/android-sdk-linux/android.jar is neither a directory nor file (type=1).
ERROR: Asset package include '/home/suphi/Documents/android-sdk-linux/android.jar' not found.
i also put the aapt from platform-tools into tools folder as i was getting errors before saying aapt was missing from tools folder
Splder said:
so im trying to get this to work but no luck if someone could help me
<snip>
i also put the aapt from platform-tools into tools folder as i was getting errors before saying aapt was missing from tools folder
Click to expand...
Click to collapse
There are several 'tools' folders. It belongs in the platforms/android-N/tools folder where the 'N' in android-N is a number (API level). Making copies might also cause problems, so I would try and figure out why its missing from the tools directory in the first place.
Ken
no need to use abrc to prepare compiled 9patch pngs, just using aapt in android-sdk is ok, the command line is like this: aapt.exe c -v -S /path/to/project -C /path/to/destination
Hi @kellinwood and ALL
Had being advised by your awesome work by @Modding.MyMind here, I've came to ask for your orientation.
At the moment, AFAIK, we are uncapable to compile xml's without providing all the resources addressed by them.
My objective here is try to compile modded XMLs only. While trying to accomplish this task, I've got to the following Python script that will generate all the /res/values/*.xml's that addresses local resources.
Code:
import os
import shutil
input_folder = '/home/Kdio/apk/Phone'
output_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "out")
if not os.path.isdir(output_folder):
os.mkdir(output_folder)
tokens = {}
xmlExist = {}
for root, dirs, files in os.walk(input_folder):
for f in files:
inputFile = os.path.join(root, f)
filename, ext = os.path.splitext(inputFile)
if (ext != '.xml'):
continue
xmlExist[os.path.basename(inputFile)] = 1
with open(inputFile, 'r') as f:
for line in f:
token = ''
read_token = False
for c in line:
if (c == '@'):
read_token = True
continue
if (read_token is True):
if (c == '"'):
read_token = False
tokens[token] = 1
token = ''
else:
token += c
f.close()
xmls = {}
for token in sorted(tokens):
if (token == 'null'):
continue
if (':' in token):
continue
#token = token.split(':')[-1]
head, tail = token.split('/')
if (head == 'anim'):
continue
if ((tail + '.xml') in xmlExist.keys()):
continue
if (not head in xmls.keys()):
xmls[head] = {}
xmls[head][tail] = 1
#for xml in xmls:
# for res in xmls[xml]:
# print(xml + ' -> ' + res)
for xml in xmls:
xmlText = '<?xml version="1.0" encoding="utf-8"?>\n<resources>\n'
for res in xmls[xml]:
if (xml == 'bool'):
xmlText += ' <bool name="' + res + '">false</bool>\n'
if ((xml == 'id') or (xml == 'drawable') or (xml == 'style') or (xml == 'layout')):
xmlText += ' <item type="' + xml + '" name="' + res + '">false</item>\n'
if (xml == 'array'):
xmlText += ' <string-array name="' + res + '">\n <item>array-dummy</item>\n </string-array>\n'
if (xml == 'attr'):
xmlText += ' <attr name="' + res + '" format="string" />\n'
if (xml == 'color'):
xmlText += ' <color name="'+ res + '">#00000000</color>\n'
if (xml == 'dimen'):
xmlText += ' <dimen name="' + res + '">1.0dip</dimen>\n'
if (xml == 'integer'):
xmlText += ' <integer name="' + res + '">1</integer>\n'
if (xml == 'plural'):
xmlText += ' <plurals name="' + res + '">\n <item quantity="other">a</item>\n <item quantity="one">b</item>\n </plurals>\n'
if (xml == 'string'):
xmlText += ' <string name="' + res + '">a</string>\n'
if (xml == 'fraction'):
xmlText += ' <fraction name="' + res + '">1%</fraction>\n'
xmlText += '</resources>\n'
f = open(os.path.join(output_folder, xml + 's.xml'), 'w')
f.write(xmlText)
f.close
Please edit 'input_folder' accordingly.
Then, issuing the below command:
Code:
aapt p -f -M onlyXMLs/AndroidManifest.xml -F onlyXMLs.zip -S onlyXMLs/res -I android.jar
What I get from it now are errors regarding external resources references not being found only.
This is exactly the point where my shallow knowledge ends ...
Could you (and all) someway point me the light (if there is any) how could we 'dummy' external resources as done with local ones?
Thank you all.
Nice regards.
.
I'm trying to edit framework-res.apk in APKManager. I'm decompiling the 9 pngs, editing, then resaving and then trying to compile the apk. It always gives me all these errors on my images. Am i missing a step before I compile? I'd appreciate if anyone could help!
desperate bump, if anyone could please help, either on here or on AIM, my screen name is "Grego" or even via messages, any help would be appreciated.
If u only want to change some png files, u can open the framework-res.apk with WinRAR oder Zip and replace the files u want. Compression set to "normal". U should notice, that the files have the same size.
bandit79 said:
If u only want to change some png files, u can open the framework-res.apk with WinRAR oder Zip and replace the files u want. Compression set to "normal". U should notice, that the files have the same size.
Click to expand...
Click to collapse
I pretty much replaced all of the png's in the framework-res along with the .9.pngs
C:\Users\greg\APK Manager\other\..\projects\framework-res.apk\res\values\public.
xml:3581: error: Public symbol drawable/textfield_disabled declared here is not
defined.
C:\Users\greg\APK Manager\other\..\projects\framework-res.apk\res\values\public.
xml:3582: error: Public symbol drawable/textfield_disabled_selected declared her
e is not defined.
C:\Users\greg\APK Manager\other\..\projects\framework-res.apk\res\values\public.
xml:3583: error: Public symbol drawable/textfield_pressed declared here is not d
efined.
C:\Users\greg\APK Manager\other\..\projects\framework-res.apk\res\values\public.
xml:2807: error: Public symbol drawable/textfield_search declared here is not de
fined.
C:\Users\greg\APK Manager\other\..\projects\framework-res.apk\res\values\public.
xml:3584: error: Public symbol drawable/textfield_search_default declared here i
s not defined.
C:\Users\greg\APK Manager\other\..\projects\framework-res.apk\res\values\public.
xml:2808: error: Public symbol drawable/textfield_search_empty declared here is
not defined.
there's a few examples of what i'm getting in the log.
yeah same here. i've got the same problem. using apk manager 4.8.
there might be a "solution" for it. didnt try it yet. but maybe it will help u.
http://forum.xda-developers.com/archive/index.php/t-933547.html
So I just upgraded an ADT project to Android Studios, I've spent the day learning about Gradle and converting all the old imported libraries to compile lines, however I seem to be stuck on one final issue. The class:
public abstract class MainActivity extends ActionBarActivity
Is resulting in 21 Errors. The first 4 are
Error: (14, 17) error: cannot access SupportParentable class file for android.support.v4.app.TaskStackBuilder$SupportParentable not found
Error: (31, 3) error: cannot find symbol variable super
Error: (42, 3) error: cannot find symbol variable super
Error: (47, 2) error: method does not override or implement a method from a supertype
(Rest available if anyone thinks they're relevant)
I have support-v4 and appcompat-v7 compiled:
compile "com.android.support:support-v4:22.2.1"
compile "com.android.support:appcompat-v7:22.2.1"
I've synced, cleaned and ran in all combinations. I'm not sure what step I'm missing here.
Yes I do know that ActionBarActivity has been depricated in place of AppCompatActivity, however switching to AppCompatActivity results in no noticeable changes. My focus right now is to get the project running as is and I'll look into modernizing after that.
bump
I am working on android studio and have installed Google Repository alongside the Play Services. I have already tried many solutions but none of them seem to work for me. I have this line in my build.gradle file under dependencies of Android:
compile "com.google.android.gms: play-services-ads:10.2.6"
I am trying to import MobileAds in my Main class:
import com.google.android.gms.ads.MobileAds;
But it gives me the error: error: package com.google.android.gms.ads does not exist. Where am I going wrong?
My build.gradle file: pastebin.com/DmnjCrwK
try using "compile 'com.google.firebase:firebase-ads:10.2.6'" in your gradle file
Hi everyone.
I'm trying to build a rom using the well known lineageos repo's.
But unfortunately I get this error:
Code:
hardware/ril-caf/rild/rild.c:60: error: undefined reference to 'joinRpcThreadpool'
It's called like this:
Code:
void rilc_thread_pool() {
joinRpcThreadpool();
}
(The call to joinRpcThreadpool is set by myself to prevent other error's. So you can't find it online in rild.c. It is a test...)
Ok. I know what this error means, but, I can't find how and where joinRpcThreadpool is defined.
I need help... :fingers-crossed: