ELF Problems - Android Builders Collective

Perhaps it's the time of year for elves, but this one is giving me fits. Building Evolution X and can't get past this issue during the build process. ANyone seen this one before or know what I'm doing wrong??
/home/erik/snow/out/target/product/pdx203/system/system_ext/bin/dpmd: error: found ELF prebuilt in PRODUCT_COPY_FILES, us
e cc_prebuilt_binary / cc_prebuilt_library_shared instead.
/home/erik/snow/out/target/product/pdx203/system/system_ext/bin/dpmd: error: found ELF file: vendor/sony/pdx203/proprieta
ry/system_ext/bin/dpmd
19:19:54 ninja failed with: exit status 1
#### failed to build some targets (03:43 (mm:ss)) ####

To answer my own question since there's literally zero info on this out on the internet, here's the fix.
Open your device's boardconfig.mk file and paste in the following text:
BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES := true
Re-run make, and you're all set to start working on the next error.

hi!
I got the same error.
yes, we can add this flag to BoardConfig.mk, but it is not a clean solution since Google encourages the use of Android.bp files instead of Makefiles. Thant's what the soong suggested the use of these modules (cc_prebuilt_binary / cc_prebuilt_library_shared). in my case, solved this problem by creating Android.bp file in the repo where I put my prebuilt libraries, then I added them as product packages in the product mk file. this is an example :
Android.bp :
cc_prebuilt_library {
name: "product_package_name_in_MK_file",
relative_install_path: "sub_lib/sub_sub_lib",
stem: "output_file_name", // .so will be added automatically to out file name.
compile_multilib: "both",
multilib: {
lib32: {
srcs: ["path for src 32bit lib"],
},
lib64: {
srcs: ["path for src 64bit lib"],
},
},
strip: {
none:true,
},
allow_undefined_symbols: true,
check_elf_files: false,
vendor: true,
enabled: true,
}
product_mk file :
...
PRODUCT_PACKAGES += product_package_name_in_MK_file
...

Related

[Q] External module: insmod load error

Hi,
I am trying to load a kernel module into my Android phone (HTC Ion, GDP2). The phone has a cyanogenmod rom with the kernel version 2.6.34.5-cyanogenmod .. shade at oxygene #2.
I am able to successfully cross-compile the LKM (a simple helloworld module) on my Ubuntu machine for the supersonic-2.6.34 kernel obtained from the cyanogen git repository. During make ARCH=arm and CROSSCOMPILE=<my-toolchain-path>/arm-eabi-4.2.1/bin/arm-eabi- menuconfig
I have enabled the loading of external modules and made sure than the version string of the kernel looks exactly the same as that of the phone-kernel (to avoid version match problem during insmod).
However, after I copy my helloworld.ko to /sdcard and try to insmod from there (i do have root privileges of course) I get the following error:
insmod: init_module 'helloworld.ko' failed (No such file or directory)
After dmesg:
<4>[54107.816314] select 1060 (ndroid.settings), adj 7, size 3942, to kill
<4>[54107.816741] send sigkill to 1060 (ndroid.settings), adj 7, size 3942
<4>[54112.699005] select 970 (android.browser), adj 8, size 7407, to kill
<4>[54112.699279] send sigkill to 970 (android.browser), adj 8, size 7407
<7>[54116.056854] tiwlan0: no IPv6 routers present
<6>[54181.677948] request_suspend_state: sleep (0->3) at 54123617131664 (2010-11-21 18:46:53.796054520 UTC)
<7>[54181.692169] deinit sharp panel
<7>[54182.325012] save exit: isCheckpointed 1
<4>[54657.268341] helloworld: Unknown symbol mcount
I am not able to understand the reason behind this. Can somebody help me out?
Thanks in advance!
Hrushi
For your reference following is the LKM code:
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual DSD/GPL");
static int hello_init(void){
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void){
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
For those who may face the same problem in future... I finally found a fix to the problem... This problem was happening because the kernel was not compiled properly... hence proper symbol table was not being generated... Android kernel does not compile well if gcc 4.4 is used, which was happening in my case. I downgraded to gcc 4.3 .. then the compilation was smooth and no error was seen again while insmoding..

[TOOL] aosp_buildcheck v0.1 (Jan 09, 2013)

I've found building AOSP and its various offshoots (AOKP, Cyanogenmod, Evervolv, ParanoidAndroid) sometimes a bit frustrating to figure out. Although the source code and tutorials are usually around, I've still had a lot of problem getting code to compile. I put together a little python script to help diagnose particular issues like missing libraries, header files, etc and dump that into readable JSON output. It's still very much a work in progress (WIP), but I figure it may help some people out.
What I plan on adding is comparison of the versions of local binaries with the latest versions, and complaining when things are out of date or just not working.
You can access the code here: https://github.com/shurane/aosp_buildcheck
Or if you trust me, you can run the code directly using this line:
Code:
wget -O - raw.github.com/shurane/aosp_buildcheck/master/aosp_buildcheck | python
This is the output you get, including errors:
Code:
errors:
Command '['/bin/bash', '-c', 'adb version 2>/dev/null']' returned non-zero exit status 127
Command '['/bin/bash', '-c', 'which fastboot']' returned non-zero exit status 1
Command '['/bin/bash', '-c', 'find ${PATH//:/ } -maxdepth 1 -name adb -print -quit 2>/dev/null']' returned non-zero exit status 1
Command '['/bin/bash', '-c', 'find ${PATH//:/ } -maxdepth 1 -name fastboot -print -quit 2>/dev/null']' returned non-zero exit status 1
Command '['/bin/bash', '-c', 'which pngout']' returned non-zero exit status 1
{
"aosp_dir": {
"devices": [
"mini_armv7a_neon-userdebug",
"mini_armv7a-userdebug",
"full_maguro-userdebug",
"cm_quincyatt-eng",
"full_vibrantmtd-eng",
"full_panda-userdebug",
"aokp_maguro-userdebug",
"aokp_toro-userdebug",
"aokp_toroplus-userdebug",
"aokp_crespo-userdebug",
"aokp_crespo4g-userdebug",
"aokp_grouper-userdebug",
"aokp_captivatemtd-userdebug",
"aokp_d2att-userdebug",
"aokp_d2tmo-userdebug",
"aokp_d2usc-userdebug",
"aokp_d2vzw-userdebug",
"aokp_evita-userdebug",
"aokp_fascinatemtd-userdebug",
"aokp_galaxysmtd-userdebug",
"aokp_hercules-userdebug",
"aokp_i9100-userdebug",
"aokp_i9100g-userdebug",
"aokp_i9300-userdebug",
"aokp_n7000-userdebug",
"aokp_p3100-userdebug",
"aokp_p3110-userdebug",
"aokp_p3113-userdebug",
"aokp_p5100-userdebug",
"aokp_p5110-userdebug",
"aokp_p5113-userdebug",
"aokp_quincyatt-userdebug",
"aokp_tf101-userdebug",
"aokp_vibrantmtd-userdebug"
],
"projects": {
"aokp": 89,
"aosp": 230,
"cm": 26
},
"projects_total": 345,
"remotes": [
"<remote fetch=\"https://android.googlesource.com/\" name=\"aosp\"/>",
"<remote fetch=\"https://github.com/\" name=\"aokp\" review=\"gerrit.sudoservers.com\"/>",
"<remote fetch=\"https://github.com/CyanogenMod/\" name=\"cm\" review=\"review.cyanogenmod.com\"/>"
]
},
"libGL.so": "/usr/lib/i386-linux-gnu/libGL.so: symbolic link to `/usr/lib/i386-linux-gnu/mesa/libGL.so.1'",
"linux": {
"lsb_release": "Distributor ID:\tUbuntu\nDescription:\tUbuntu 12.04.1 LTS\nRelease:\t12.04\nCodename:\tprecise"
},
"optional": {
"ionice": "ionice from util-linux 2.20.1",
"schedtool": "get/set scheduling policies - v1.3.0, GPL'd, NO WARRANTY"
},
"os": "Linux",
"pngtools": {
"optipng": "OptiPNG 0.6.4: Advanced PNG optimizer.\nUsing libpng version 1.2.46 and zlib version 1.2.3.4",
"pngcrush": "pngcrush 1.7.9, uses libpng 1.2.42 and zlib 1.2.3.3",
"pngout": ""
},
"repo": "repo version v1.12.0\n (from https://gerrit.googlesource.com/git-repo)\nrepo launcher version 1.19\n (from /home/kikin/bin/repo)\ngit version 1.7.9.5\nPython 2.7.3 (default, Aug 1 2012, 05:14:39) \n[GCC 4.6.3]",
"tools": {
"adb": "",
"fastboot": "",
"g++": "g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3",
"gcc": "gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3",
"java": "java version \"1.6.0_38\"\nJava(TM) SE Runtime Environment (build 1.6.0_38-b05)\nJava HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)"
},
"uname": "Linux un 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux"
}
Feel free to complain about any outstanding problems with the script and stuff. I would much rather prefer pull requests over github if you guys have the knowhow to implement features.

[Samsung] Unpacking 'Non-Standard' Boot.img Problems for 64 Bit Device

This is in relation to this and my post on xda.
The main reason I want to make a custom kernel is to gain root and once I successfully have then add other CPU governors, and since this is considered a low activity device on xda I will have to do this myself. Also I you are just gonna say use twrp to flash SuperSU, well I can't as it seems to not work with the device when its running Lollipop 5.1.1
Device Specifications:
Current Android Version: Android Lollipop 5.1.1
Chipset: Marvell Armada PXA1908 (Note: Due to this being a rarely used chip, the CF-Auto root won't work)
Custom Recovery Status: TWRP 3.0.2-0 (More on this later on)
Root Status (This is why I am here): Android KitKat 4.4.4 (Root) , Android Lollipop 5.1.1 (NO ROOT Yet)
ARMv8 64-bit
Now let's get into my steps up to the point and then my problem.
Note: In the kernel readme it states to use the toolchain 4.8 but when I use it, it complains of not being able to find gcc. Also in the read me it states "get Toolchain download and install arm-eabi-4.8 toolchain for ARM EABI.(64bit)" and when reading up on it, https://developer.android.com/ndk/guides/standalone_toolchain.html#syt , it says to use aarch64 for ARM 64 Bit devices.
Device Source Code can be found at Here
Code:
cd ~/android
export CROSS_COMPILE=~/android/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-
cd ~/android/kernel
make ARCH=arm64 pxa1908_xcover3lte_eur_defconfig
make ARCH=arm64
This outputs: Image, Image.gz, .dts and .dtb files.
Where's the kernel readme (I believe this hasn't been update since kitkat) says the output will be,
- Kernel : Kernel/arch/arm/boot/zImage
- module : Kernel/drivers/*/*.ko
Note: when trying to compile with the 32- bit ARM toolchain it fails, as the config is found in arm64, wheres other configs are found in arm.
So know I have a kernel (Image or Image.gz), and some .dts and .dtb files. Now to unpack boot.img, this is where problems occur. When trying to use tools like abootimg or the various different versions of unmkbootimg, they complain about non-standard boot.img.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
or
While also try saving it as a zImage when its meant to be a Image.gz, or they extract it without throwing any errors, but when looking at the extracted files with a hex editor, it is all 00 throughout the files, therefore a useless file.
So their for I tried manually unpacking with a hex editor and managed to get the kernel. Left is my Compiled and Right is the hex version.
Notice the difference in size, is this because the kernel in boot.img is stripped of its debugging items while mine isn't? If so I should look up on how to fix that.
But am having troubles trying to extract the ramdisk via hex.
So is anyone able to either:
a) Help me extract the boot.img properly (with tools like unmkbootimg or with a hex editor)
or
b) do this for me and explain how you achieved it so I myself is am able to do it when needed.
I have attached necessary files if you want to have a look at them yourself.
Any help is appreciated.
FIles(XDA attachments not working): https://drive.google.com/file/d/0B_5mtquWAP3MZjJQay1ERFprbnM/view?usp=sharing
After Numerous trial and error, I finally managed to output ramdisk.cpio.gz.
The start of a Gzip file in hex is, 1F 8B 08, therefor when using the search function in you had editor application you can narrow down your results to 1 or 2 files (2 Files for me as my kernel and ramdisk are both gzipped). You then follow it all the way down till you find a big bunch of zeros(seems like they are passing between files). When you reach the bunch of zeros include the first "00" at the end of the other hexidecial. E.G. End of one of my gzip files is "CE 24 00 00 00....00 (ZERO PADDING BETWEEN FILES), Threaded the end of my file is "CE 24 00".
Knowing this I was able to successfully extract and verify both my kernel and ramdisk files are correct.
Perl script for unpacking
Code:
#!/usr/bin/perl
######################################################################
#
# File : split_bootimg.pl
# Author(s) : William Enck <[email protected]>
# Description : Split appart an Android boot image created
# with mkbootimg. The format can be found in
# android-src/system/core/mkbootimg/bootimg.h
#
# Thanks to alansj on xda-developers.com for
# identifying the format in bootimg.h and
# describing initial instructions for splitting
# the boot.img file.
#
# Last Modified : Tue Dec 2 23:36:25 EST 2008
# By : William Enck <[email protected]>
#
# Copyright (c) 2008 William Enck
#
######################################################################
use strict;
use warnings;
# Turn on print flushing
$|++;
######################################################################
## Global Variables and Constants
my $SCRIPT = __FILE__;
my $IMAGE_FN = undef;
# Constants (from bootimg.h)
use constant BOOT_MAGIC => 'ANDROID!';
use constant BOOT_MAGIC_SIZE => 8;
use constant BOOT_NAME_SIZE => 16;
use constant BOOT_ARGS_SIZE => 512;
# Unsigned integers are 4 bytes
use constant UNSIGNED_SIZE => 4;
# Parsed Values
my $PAGE_SIZE = undef;
my $KERNEL_SIZE = undef;
my $RAMDISK_SIZE = undef;
my $SECOND_SIZE = undef;
my $DT_SIZE = undef;
######################################################################
## Main Code
&parse_cmdline();
&parse_header($IMAGE_FN);
=format (from bootimg.h)
** +-----------------+
** | boot header | 1 page
** +-----------------+
** | kernel | n pages
** +-----------------+
** | ramdisk | m pages
** +-----------------+
** | second stage | o pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
** o = (second_size + page_size - 1) / page_size
** p = (dt_size + page_size - 1) / page_size
**
** 0. all entities are page_size aligned in flash
** 1. kernel and ramdisk are required (size != 0)
** 2. second is optional (second_size == 0 -> no second)
** 3. load each element (kernel, ramdisk, second) at
** the specified physical address (kernel_addr, etc)
** 4. prepare tags at tag_addr. kernel_args[] is
** appended to the kernel commandline in the tags.
** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
** 6. if second_size != 0: jump to second_addr
** else: jump to kernel_addr*/
=cut
my $n = int(($KERNEL_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $m = int(($RAMDISK_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $o = int(($SECOND_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $p = int(($DT_SIZE + $PAGE_SIZE - 1) / $PAGE_SIZE);
my $k_offset = $PAGE_SIZE;
my $r_offset = $k_offset + ($n * $PAGE_SIZE);
my $s_offset = $r_offset + ($m * $PAGE_SIZE);
my $t_offset = $s_offset + ($o * $PAGE_SIZE);
(my $base = $IMAGE_FN) =~ s/.*\/(.*)$/$1/;
my $k_file = "kernel.gz";
my $r_file = "ramdisk.gz";
my $s_file = "second.gz";
my $t_file = "dt.img";
# The kernel is always there
print "Writing $k_file ...";
&dump_file($IMAGE_FN, $k_file, $k_offset, $KERNEL_SIZE);
print " complete.\n";
# The ramdisk is always there
print "Writing $r_file ...";
&dump_file($IMAGE_FN, $r_file, $r_offset, $RAMDISK_SIZE);
print " complete.\n";
# The Second stage bootloader is optional
unless ($SECOND_SIZE == 0) {
print "Writing $s_file ...";
&dump_file($IMAGE_FN, $s_file, $s_offset, $SECOND_SIZE);
print " complete.\n";
}
# The DT.img stage is optional
unless ($DT_SIZE == 0) {
print "Writing $t_file ...";
&dump_file($IMAGE_FN, $t_file, $t_offset, $DT_SIZE);
print " complete.\n";
}
######################################################################
## Supporting Subroutines
=header_format (from bootimg.h)
struct boot_img_hdr
{
unsigned char magic[BOOT_MAGIC_SIZE];
unsigned kernel_size; /* size in bytes */
unsigned kernel_addr; /* physical load addr */
unsigned ramdisk_size; /* size in bytes */
unsigned ramdisk_addr; /* physical load addr */
unsigned second_size; /* size in bytes */
unsigned second_addr; /* physical load addr */
uint32_t dt_size; /* device tree size in bytes */
uint32_t dt_addr; /* device tree address in bytes */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
unsigned char cmdline[BOOT_ARGS_SIZE];
unsigned id[8]; /* timestamp / checksum / sha1 / etc */
};
=cut
sub parse_header {
my ($fn) = @_;
my $buf = undef;
open INF, $fn or die "Could not open $fn: $!\n";
binmode INF;
# Read the Magic
read(INF, $buf, BOOT_MAGIC_SIZE);
unless ($buf eq BOOT_MAGIC) {
die "Android Magic not found in $fn. Giving up.\n";
}
# Read kernel size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($k_size, $k_addr) = unpack("VV", $buf);
# Read ramdisk size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($r_size, $r_addr) = unpack("VV", $buf);
# Read second size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($s_size, $s_addr) = unpack("VV", $buf);
# Read dt size and address (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE * 2);
my ($t_size, $t_addr) = unpack("VV", $buf);
# Ignore tags_addr
read(INF, $buf, UNSIGNED_SIZE);
# get the page size (assume little-endian)
read(INF, $buf, UNSIGNED_SIZE);
my ($p_size) = unpack("V", $buf);
# Read the name (board name)
read(INF, $buf, BOOT_NAME_SIZE);
my $name = $buf;
# Read the command line
read(INF, $buf, BOOT_ARGS_SIZE);
my $cmdline = $buf;
# Ignore the id
read(INF, $buf, UNSIGNED_SIZE * 8);
# Close the file
close INF;
# Print important values
printf "Page size: %d (0x%08x)\n", $p_size, $p_size;
printf "Kernel size: %d (0x%08x)\n", $k_size, $k_size;
printf "Ramdisk size: %d (0x%08x)\n", $r_size, $r_size;
printf "Second size: %d (0x%08x)\n", $s_size, $s_size;
printf "dt size: %d (0x%08x)\n", $t_size, $t_size;
printf "Board name: $name\n";
printf "Command line: $cmdline\n";
# Save the values
$PAGE_SIZE = $p_size;
$KERNEL_SIZE = $k_size;
$RAMDISK_SIZE = $r_size;
$SECOND_SIZE = $s_size;
$DT_SIZE = $t_size;
}
sub dump_file {
my ($infn, $outfn, $offset, $size) = @_;
my $buf = undef;
open INF, $infn or die "Could not open $infn: $!\n";
open OUTF, ">$outfn" or die "Could not open $outfn: $!\n";
binmode INF;
binmode OUTF;
seek(INF, $offset, 0) or die "Could not seek in $infn: $!\n";
read(INF, $buf, $size) or die "Could not read $infn: $!\n";
print OUTF $buf or die "Could not write $outfn: $!\n";
close INF;
close OUTF;
}
######################################################################
## Configuration Subroutines
sub parse_cmdline {
unless ($#ARGV == 0) {
die "Usage: $SCRIPT boot.img\n";
}
$IMAGE_FN = $ARGV[0];
}
The reason why none of tools support our image is because it has different header format. For example mkbootimg:
Code:
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
but we need for our kernel such a code
Code:
unsigned dt_size; /* device tree size in bytes */
unsigned dt_addr; /* device tree address in bytes */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
akuhak said:
Perl script for unpacking
The reason why none of tools support our image is because it has different header format. For example mkbootimg:but we need for our kernel such a code
Click to expand...
Click to collapse
Yes @akuhak I had realised that about a week ago (header sizes), also another thing is most of these tools deal with a zImage, where's I boot.img has a hOmage (which is a 64 byte uImage header followed by the kernel. I have succesfully unpacked this boot.img (the kernel, ramdisk and dt.img).
Now if this script works it will be good for other users, but for me my need has already been done.
I am just having trouble trying to get this booting up on my phone when I repack it (I haven't been paying to much attention to this project becuse of exam revision)
Edit: I have tested it and verified thatvit works by comparing the files produced by hand and the files produced by this script via the sha1sum command. I have uploaded it onto my xCover3 post linking back here and giving the credit to you for posting it here. Thanks for your help
It easier to found already existing tool. Our device (I am owning Xcover 3 too) has pxa1088 board. It is known that similar boards has similar structure. So i found these thread github(dot)com/kumajaya/degas-mkbootimg (he has also topic here in xda with his researchs)
It has the same board so these tools works fine for us The only difference I noticed - header unknown value is 0x03000000 for our device and 0x02000000 for Galaxy Tab 4. Maybe something wrong with dtb image - I didn't check these yet.
BTW our phone has same characteristics as Samsung SM-G531F Galaxy Grand Prime (same board, same cpu, same gpu, only screen a bit different) and grandprimevelte has 5.1.1 android onboard and working TWRP recovery (I was trying to flash it but was unsuccessful).
As for same board - For Example Xcover 3 Value Edition has completely different board (exynos3475 with mali-t760mp8 gpu). The same characteristics as for Samsung SM-J200 Galaxy J2. So we can use root methods from j2lte. This means - flash TWRP then install SuperSu zip archive - thats all.
But we cannot use TWRP from VE cause of very different hardwares.
Now Im working on improving degas utilities...
akuhak said:
It easier to found already existing tool. Our device (I am owning Xcover 3 too) has pxa1088 board. It is known that similar boards has similar structure. So i found these thread github(dot)com/kumajaya/degas-mkbootimg (he has also topic here in xda with his researchs)
It has the same board so these tools works fine for us The only difference I noticed - header unknown value is 0x03000000 for our device and 0x02000000 for Galaxy Tab 4. Maybe something wrong with dtb image - I didn't check these yet.
BTW our phone has same characteristics as Samsung SM-G531F Galaxy Grand Prime (same board, same cpu, same gpu, only screen a bit different) and grandprimevelte has 5.1.1 android onboard and working TWRP recovery (I was trying to flash it but was unsuccessful).
As for same board - For Example Xcover 3 Value Edition has completely different board (exynos3475 with mali-t760mp8 gpu). The same characteristics as for Samsung SM-J200 Galaxy J2. So we can use root methods from j2lte. This means - flash TWRP then install SuperSu zip archive - thats all.
But we cannot use TWRP from VE cause of very different hardwares.
Now Im working on improving degas utilities...
Click to expand...
Click to collapse
TWRP for xcover3 value editio came out about 7 says ago, and apparently one user has tried it and is working on their value edition version. (When I had a quick look at the source code yesterdau I happenend to notice it was a exynos board). I had previously tried the dagas scripts and they didn't work for our image at the time, yet your providerd version does. Great idea for searching up the board name (Marvell) as that is one of the only things I hadn't thought to Google.
Feel free to compile TWRP under android 5.1.1 branch. I can/will chime in with relevant info, as well as you can use info from TWRPs source code on the other twrp versions of our device. The only reason I haven't tried it as of yet is becuse i using my my mobile data 99% of the time and just don't have the data to so are downloading source code.
As for the dt.img, I veriefed the scripts output to my on manually extraction and it's the same for both files. (Sha1). But there is a little bit of trailing data (anything past SEANDROIDENFORCING) which is ignored, I am not sure id it's importance as of yet(other then SuperSu omits it from the boot.img when using SuperSu.zip.
Will pop back into here later today.
Ok I completed my tools collection for pxa1088
Source Code: github(dot)com/AKuHAK/pxa1088-mkbootimg
All necessary utilities can be achieved via my modified android_img_repack_tools repo: github(dot)com/AKuHAK/android_img_repack_tool
By just typing ./configure and make
If you are scared by traffic I released tools in one archive: github(dot)com/AKuHAK/android_img_repack_tools/releases/tag/1st.
How to use? I created README in github: github(dot)com/AKuHAK/pxa1088-mkbootimg/blob/master/README
Tools can extract and than pack back boot.img and recovery.img from XCover3. If you didn't extract uImage and dtb.img you can repack boot.img (recovery.img) without hash sum changes. If you extract zImage from uImage and than pack again in uImage your resulting uImage will be different cause uIimage header contain timestamp which will be taken from your PC settings. But resulting uImage still HAVE to be valid.
akuhak said:
Ok I completed my tools collection for pxa1088
Source Code: github(dot)com/AKuHAK/pxa1088-mkbootimg
All necessary utilities can be achieved via my modified android_img_repack_tools repo: github(dot)com/AKuHAK/android_img_repack_tool
By just typing ./configure and make
If you are scared by traffic I released tools in one archive: github(dot)com/AKuHAK/android_img_repack_tools/releases/tag/1st.
How to use? I created README in github: github(dot)com/AKuHAK/pxa1088-mkbootimg/blob/master/README
Tools can extract and than pack back boot.img and recovery.img from XCover3. If you didn't extract uImage and dtb.img you can repack boot.img (recovery.img) without hash sum changes. If you extract zImage from uImage and than pack again in uImage your resulting uImage will be different cause uIimage header contain timestamp which will be taken from your PC settings. But resulting uImage still HAVE to be valid.
Click to expand...
Click to collapse
Cool, will have a look tomorrow, it's hitting 1am for me now. Just one quick correction in the above post of yours. You mention zImage is extracted from the uImage. That is incorrect, is is in fact just a gzipped kernel image (Image.gz) not a zImage.
Yes I know both types of formats are compressed, but our device runs a armv8 cpu which is 64 bits (albeit our kernel is using a 32 but instruction set not a 64 bit instruction set and this means or OS is also 32 bits then). Apon reading the documentation found in the source code, you will realise that it can only handle a) the uncompressed kernel image (Image) or b) a compressed version of the image in gzip format (Image.gz). This is further proven when looking at the boot.img with a hex editor as you can clearly see 2 Files that start with the gzip header format (1F 8B 08) which are the gzipped kernel (also if you go back by 64 bytes then you will be at the start of the uImage header which holds or the appropriate info about the kernel.uImage file) and our ramdisk.
So hopefully you may have just made a mistake in the above post, but if not then you are outputting the incorrect file, which may confuse some users of they don't know much but just wanted to compile the kernel from source.
Sorry about the above rant, will now have a quick look at your github. Thanks for your work you have put into this phone.
Edit: when you mention the android img repack tools, did you use this, http://forum.xda-developers.com/showthread.php?t=2600364 , and if so what modification have you done since I already have the downloaded (used the last of my mobile data last month to get it)
EDIT2: Gonna have a mess around with them tomorrow. One question, sorry for sounding like a noon, but how does the compression differs between normal gzip and minigzip, how will these differences affect a repacked ramdisk and what got you onto that piece of info.
And I had a quick look at your github, seen all your ps2 back related source code.you using FMCB, a hardmod (a chip) or a internal hardrive via an Ethernet adapter. I see sp193, doctorxyz, have commuted to your repo, so sounds like your a ps2 dev, which is cool as ****
1) About zImage. Maybe I need to be more clear: Xcover 3 kernel has uImage onboard with gzip compression. You can extract kernel from that gzipped uImage - I just thought that zImage is name for extracted kernel Sorry if I made mistake in this case.
uImage can be created with use of u-boot tool (denx(dot)de/wiki/U-Boot/WebHome)
For example
Code:
mkimage -I boot.uImage
will provide such an information for our device
Code:
Image Name: pxa1928dkb linux
Created: Wed May 18 15:13:06 2016
Image Type: AArch64 Linux Kernel Image (gzip compressed)
Data Size: 6616640 Bytes = 6461.56 kB = 6.31 MB
Load Address: 01000000
Entry Point: 01000000
This information is extracted from uImage kernel (64 bytes). After header we will see our gzipped kernel - you are right. I just simply extracted it with 7zip from boot.img-uImage.
The difference is that your way didn't use uImage header at all - so you will be unable to pack it back without mistakes - or your gzipped kernel have to be completely the same in size which is almost impossible to achieve. With use of mkimage you can alter kernels (of course only if samsung doesnt check something else) and get correct uImage in output.
2) About difference between minigzip and gzip. In fact I don't know why its happened but I didn't found a reason why ramdisk have to be packed exactly with minigzip. I tried almost all flag combinations with gzip but I get the same result that was in output file only with minigzip
As about kernel it is packed with maximum compression without name with normal gzip.
So assuming minigzip for ramdisk, gzip -n -9 for kernel. But Im completely sure that we can use any combination of gzipers and image still will be valid (but of course will be different in hash). We need to use exactly this combination only if we need to get the same file.
3) Yes Im using exactly this kitchen - I just removed all branches except 5.1.1 added minigzip, my tools and u-boot mkimage tool generation.
4) Yes Im one of still alive ps2 developers I just realized that my phone isn't rooted and started to dig what I can do with it.
akuhak said:
1) About zImage. Maybe I need to be more clear: Xcover 3 kernel has uImage onboard with gzip compression. You can extract kernel from that gzipped uImage - I just thought that zImage is name for extracted kernel Sorry if I made mistake in this case.
uImage can be created with use of u-boot tool (denx(dot)de/wiki/U-Boot/WebHome)
For example will provide such an information for our device
This information is extracted from uImage kernel (64 bytes). After header we will see our gzipped kernel - you are right. I just simply extracted it with 7zip from boot.img-uImage.
The difference is that your way didn't use uImage header at all - so you will be unable to pack it back without mistakes - or your gzipped kernel have to be completely the same in size which is almost impossible to achieve. With use of mkimage you can alter kernels (of course only if samsung doesnt check something else) and get correct uImage in output.
2) About difference between minigzip and gzip. In fact I don't know why its happened but I didn't found a reason why ramdisk have to be packed exactly with minigzip. I tried almost all flag combinations with gzip but I get the same result that was in output file only with minigzip
As about kernel it is packed with maximum compression without name with normal gzip.
So assuming minigzip for ramdisk, gzip -n -9 for kernel. But Im completely sure that we can use any combination of gzipers and image still will be valid (but of course will be different in hash). We need to use exactly this combination only if we need to get the same file.
3) Yes Im using exactly this kitchen - I just removed all branches except 5.1.1 added minigzip, my tools and u-boot mkimage tool generation.
4) Yes Im one of still alive ps2 developers I just realized that my phone isn't rooted and started to dig what I can do with it.
Click to expand...
Click to collapse
1) yes a zImage is one type of you can get when compiling for ARM Devices, you Device is ARM64 so thierare differences. As for extracting the kernel I have always include the 64 byte header (since the middle of last week when I realised that it was there after running binwalk against the file). So yea your assumption was correct up untill a week ago.
2) Interesting. I will be sure to make changes accordingly.
3) cool I have 2 out of four so will download accordingly
4) cool, that the development scene is still going since the ps2 reached it 16 birthday this year.
5) as for root on this device chainfire has needed to go Systemless after/on 6.0 device or 5.1.1. Samsung devices, so to achive root on those devices it requires the modification of boot.img. what his SuperSu.zip does is patch the sepolicy file to allow 3 rules to run in permissive, modify other bits of the ramdisk accordingly to allow for it to run services and mount su.img at boot and it creates and place the necessary files inside su.img. I have completed all that by hand after reading his update-script numerous times. My only roadblock has been try to get the boot.img to boot.I was currently in the process, of try (I have tried alot of different ways including mkbootimg etc.) Manuallying replacing the ramdisk contents with the modified version, and then modify the bootmimg header to continue any modifed value (ramdisk size and dt offset) but am only partially done as I haven't had the chance the last few days to do it.
Awesome tool, unpack, repacked without a single modification and then ran "sha1sum" to both boot.img's and they are exactly the same. You are amazing . I have referenced your tools in this thread (http://forum.xda-developers.com/android/development/4-4-4-5-1-1-6-0-1-samsung-xcover3-t3465132 ) straight to your github. Now to try my modified ramdisk and see If my phone can boot it. Will post results soon.
======
Yes I can boot custom boot.img, without the SEANDORIDENFORCEING showing up. I can see my ramdisk changes, work, I can type adb root and I don't get the product in build message, but trying to do anything that requires root e.g. trying to push su.img to /data or /cache, gets me the error permission denied, but hey I am half way there to getting root.

[TUTORIAL/REFERENCE] Building the android kernel (Mac OS)

Many people have MacBooks and they MacBooks have a terminal. This terminal runs bash and other unix commands, so why can't we compile a kernel. That's what I thought at first... Then the errors started...
I will not be responsible if you bork, brick, or blow up your devices in the process​
Notes: This is using clang, gcc should also work using this procedure, just with a few alterations exactly like compiling on linux
This guide is intended to help people compile their kernel on OSX
Step 1: Getting the dependencies and setting up build environment
Installing package managers:
Xcode HAS to be installed for this to work! If you just want the command line tools, type "xcode-select --install". To set the OS to use the command line tools from the app, type "xcode-select --switch /Applications/Xcode.app/Contents/Developer"
Install homebrew here: http://brew.sh
Install macports here (Follow source instructions): http://https://guide.macports.org/chunked/installing.macports.html
Set up build environment:
The android developers website gives great instructions on how to do this, but they use macports, which I tend to stay away from. However, this guide will use macports until I can figure out the homebrew alternatives for these packages
MacPorts packages: gmake libsdl git gnupg bison (exclude the git packages if you already have them)
Reference site: https://source.android.com/setup/build/initializing
Case Sensitive disk image - Android anything won't build unless the filesystem is case sensitive (APFS isn't), so we need to create a sparseimage for it
Go into disk utility and hit file, new image, blank image or Command-N
Set (in this order) Image Format: sparse disk image, Format: Mac OS Extended (Journaled, case-sensitive), Size: 20GB, Name: Android
Create the new image
Edit your bash profile by entering "open -a TextEdit ~/.bash_profile" and make a mountAndroid function
mountandroid() { hdiutil attach ~/android.sparseimage -mountpoint /Volumes/android; }
Open a new terminal window and type mountandroid
Your new disk image is mounted at /Volumes/android
Setting the PATH:
Open your bash_profile
add this line:
export PATH="/usr/local/bin:$PATH"
export PATH="/opt/local/bin:$PATH"
Save and open a new window
Step 2 - Cloning the kernel: I don't know where you get your kernels from, but you should know the basics on how to clone a source, clone the source to /Volumes/android
Step 3 - Getting the Toolchain: For now, I use prebuilts via the NDK, However, Crosstool-ng is a viable option
Download the NDK here https://developer.android.com/ndk/downloads/
Make a standalone Toolchain inside your case sensitive image (For arm64 devices: use the guide for BOTH arm and arm64)
https://developer.android.com/ndk/guides/standalone_toolchain
Step 4 - Linking it all together:
Creating a script to use (inside kernel source folder)
make O=out ARCH=arm64 **Your_defconfig**
make -j4 O=out ARCH=arm64 CC='/Volumes/android/**Toolchain folder**/bin/clang' CLANG_TRIPLE=aarch64-linux-gnu CROSS_COMPILE_ARM32='/Volumes/android/**Toolchain arm folder**/bin/arm-linux-androideabi-' CROSS_COMPILE='/Volumes/android/**Toolchain arm folder**/bin/aarch64-linux-android-'
The arm64 devices have to use the CROSS_COMPILE_ARM32 line, if you don't have this, just omit the line
Then just type ./**Script Name**.sh (make sure to chmod +x or 755 it first) and you're good to go!
Step 5 - Errors... Those stupid errors!: There are a few known errors that can be easily fixed, but they're very annoying
elf.h error - Open the file /usr/local/include and make a new file, elf.h
Paste this in there:
#include "../opt/libelf/include/libelf/gelf.h"
#define R_386_NONE 0
#define R_386_32 1
#define R_386_PC32 2
#define R_ARM_NONE 0
#define R_ARM_PC24 1
#define R_ARM_ABS32 2
#define R_MIPS_NONE 0
#define R_MIPS_16 1
#define R_MIPS_32 2
#define R_MIPS_REL32 3
#define R_MIPS_26 4
#define R_MIPS_HI16 5
#define R_MIPS_LO16 6
#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */
#define R_PPC_ADDR32 1 /* 32bit absolute address */
#define R_PPC64_ADDR64 38 /* doubleword64 S + A */
#define R_SH_DIR32 1
#define R_SPARC_64 32 /* Direct 64 bit */
#define R_X86_64_64 1 /* Direct 64 bit */
#define R_390_32 4 /* Direct 32 bit. */
#define R_390_64 22 /* Direct 64 bit. */
#define R_MIPS_64 18
#define EF_ARM_EABIMASK 0XFF000000
#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
vdsomunge.c errors (all fixed with this simple file from torvalds himself)
Replace your arch/arm/vdso/vdsomunge.c file with this one
vdso_offset_sigtramp undeclared (shows signal.c in terminal)
change the file arch/arm64/vdso/gen_vdso_offsets.sh
Replace the last line to this - 's/^\([0-9a-fA-F]*\) . VDSO_\([a-zA-Z0-9_]*\)$/\#define vdso_offset_\2 0x\1/p'
This removes the "t" in the "2t0x" part
So, after this, your kernel should be built without any complications! I have some requests in the post below, so help me out and gimme a thanks!
Things I need help finding:
Building crosstool-ng on mac
building Dragon TC on mac or a clang 8.0 toolchain
Please put your solutions in the comments so I can include them in the main thread
thanks for the guide!
I'm having one problem though
Code:
Undefined symbols for architecture x86_64:
"_OPENSSL_init_crypto", referenced from:
_main in cc6WbheD.o
ld: symbol(s) not found for architecture x86_64
I posted a complete revision alongside a recent kernel, but below is a summary of the changes / updates for using this guide in 2021
StarKissed/StarKissed_I005_1
Contribute to StarKissed/StarKissed_I005_1 development by creating an account on GitHub.
github.com
Disclaimer: As of June 2021, Android no longer supports building on Mac
arch/arm64/vdso/gen_vdso_offsets.sh =>
arch/arm64/kernel/vdso/gen_vdso_offsets.sh
Code:
brew install gnu-sed
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
readlink: illegal option -- f
usage: readlink [-n] [file ...]
Code:
brew install coreutils
export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
find: -printf: unknown primary or operator
Code:
brew install findutils
export PATH=/usr/local/opt/findutils/libexec/gnubin:$PATH
Homebrew alternatives
Code:
brew install make
brew install sdl
brew install gnupg
brew install bison
Quick Homebrew Alternatives
Enter "homebrew [command name]" in google search
Enter command from https://formulae.brew.sh/formula/
juampapo546 said:
thanks for the guide!
I'm having one problem though
Code:
Undefined symbols for architecture x86_64:
"_OPENSSL_init_crypto", referenced from:
_main in cc6WbheD.o
ld: symbol(s) not found for architecture x86_64
Click to expand...
Click to collapse
Code:
brew install openssl
export PKG_CONFIG_PATH=/usr/local/opt/[email protected]/lib/pkgconfig:$PKG_CONFIG_PATH
You may also need to explicitly include in scripts/Makefile
Code:
HOST_EXTRACFLAGS += -I$(srctree)/tools/include
ifeq ($(shell uname),Darwin)
HOST_EXTRACFLAGS += -I/usr/local/opt/[email protected]/include -L/usr/local/opt/[email protected]/lib
endif

Obfuscated apk decompile/recompile tool

Obfuscated apk decompile/recompile tool​This tool is modified from "iBotPeaches/apktool" to handle resource obfuscated(by ResGuard or any) apps like Wechat, Tiktok, MT Manager ...
About​
Renaming
Illegal name like "r/e/a_.xml" -> "res/layout/layout_01ab.xml"
Names containing non latin characters
For stripped file extension names, it guesses from file magic and data patterns
Ignores unique un-obfuscated names
Decompiling
Handles apktool known issues of "Invalid chunk type ***"
Merges splitted apk files
Compiling
The builtin aapt/aapt2 can handle "illegal java class names" (for linux only)
How to use​
All commands are the same as apktool
For splitted apk files pass the directory path containing your apk files and rename the main apk to "base.apk"
example: java -jar kikfox.jar "d" "-p" "/home/user/framework" "-o" "/home/user/tiktok_decompiled" "/home/user/tiktok_splits"
Update 2.6.1​
Handles multiple packages
Smart refactoring the obfuscated names will be renamed to more meaningful names like:
☆Color, Integer, Strings ... renaming is based on value e.g. #FFC0CB -> @ color/pink_ffc0 , 《No connection tap again to retry》-> @ string/no_connection_tap_again
☆ Layout & xml names is based on the root tag name e.g. if you have xml with <LinearLayout ...> then the resource name will be @ layout/linearLayout_12ab , or <paths ...> to @ xml/xml_paths_123
☆Other known variables from apk info, e.g. in AndroidManifest.xml android:icon is for app icon so the corresponding resource name will be @ drawable/app_icon
Downloads​V 2.4.0
Attachement
Github
Mega.nz
V 2.6.1
Github
UPDATE-1 (2.5.0-BETA)
I just released a new version on github
Whats new?
Smart refactoring *
works great. Do you plan an upgrade to 2.50 ?
[email protected] said:
works great. Do you plan an upgrade to 2.50 ?
Click to expand...
Click to collapse
As of today I didn't find out any problem with the current version , I decompiled as many obfuscated apks as i can and works for all. Currently I am working to combine features of Apktool+JADX+Smali/Baksmali to deobfuscate the java code.
If you find any bugs or apk which this tool fails to decompile, please share with me.
Thanks
Nice work!
Might sounds weird question, but do you plan to do pull requests on official apktool so iBotPeaches can handle updates with these features? maybe this will be huge benefit for everyone and iBotPeaches will be able to understand deobfuscation and merging apk a lot more, as it seems like he is struggling with it
evildog1 said:
Nice work!
Might sounds weird question, but do you plan to do pull requests on official apktool so iBotPeaches can handle updates with these features? maybe this will be huge benefit for everyone and iBotPeaches will be able to understand deobfuscation and merging apk a lot more, as it seems like he is struggling with it
Click to expand...
Click to collapse
I tried but seems like they are not interested in deobfuscation part (maybe they are working on "obfuscation" too ? ). Every apktool update is going away from handling obfuscated apk. I don't know why but a massive crowd want to silence the techniques of deobfuscation.
kikfox said:
I tried but seems like they are not interested in deobfuscation part (maybe they are working on "obfuscation" too ? ). Every apktool update is going away from handling obfuscated apk. I don't know why but a massive crowd want to silence the techniques of deobfuscation.
Click to expand...
Click to collapse
Oh i see.
Now I remember someone told me iBot work with AndResGuard which is why there is no fix to apktool, but i'm still not sure if he said was true.
I think Apktool is simply the ground work, from there you can take it where you want :')
News
New java based resource builder is coming.
☆ This tool is totally independent of aapt and aapt2.
☆ Can parse standard xml files under "res" directory and convert to binary "ARSC" file
Good job
A new java based ARSCTool is released.
Converts android resources.arsc to xml and build back to .arsc file
https://github.com/kikfox/ARSCTool
NEW version 2.6.2 released
https://github.com/kikfox/kikfox/releases/tag/v2.6.2
kikfox said:
NEW version 2.6.2 released
https://github.com/kikfox/kikfox/releases/tag/v2.6.2
Click to expand...
Click to collapse
kikfox-2.6.2.jar works fine on Macbook, but unable to decompile the r (resguard?) folder on Windows 10 PC.
Code:
I: Decoding resources ...
I: Decoding file-resources packages count=1 ....
I: Decoding file-resources PKG=com.xiaojie.tv
I: 1/548 'app.apk : r/k/da.9.png' -> 'drawable-xhdpi\abc_scrubber_primary_mtrl_alpha'
S: Could not decode file, replacing by FALSE value: r/k/da.9.png
S: Could not decode file, replacing by FALSE value: r/w/at.xml
S: Could not decode file, replacing by FALSE value: r/p/a.xml
S: Could not decode file, replacing by FALSE value: r/h/c7.xml
S: Could not decode file, replacing by FALSE value: r/k/ci.png
I: 548/548 'app.apk : r/p/a.xml' -> 'animator-v21\lb_onboarding_logo_enter'
S: Could not decode file, replacing by FALSE value: r/p/a.xml
I: Decoding values */* XMLs...
I: Decoding [59] value files from: com.xiaojie.tv
I: 1/59 values-v25\styles.xml
I: 59/59 values-v22\styles.xml
I: DONE decoding resources
a452388 said:
kikfox-2.6.2.jar works fine on Macbook, but unable to decompile the r (resguard?) folder on Windows 10 PC.
Code:
I: Decoding resources ...
I: Decoding file-resources packages count=1 ....
I: Decoding file-resources PKG=com.xiaojie.tv
I: 1/548 'app.apk : r/k/da.9.png' -> 'drawable-xhdpi\abc_scrubber_primary_mtrl_alpha'
S: Could not decode file, replacing by FALSE value: r/k/da.9.png
S: Could not decode file, replacing by FALSE value: r/w/at.xml
S: Could not decode file, replacing by FALSE value: r/p/a.xml
S: Could not decode file, replacing by FALSE value: r/h/c7.xml
S: Could not decode file, replacing by FALSE value: r/k/ci.png
I: 548/548 'app.apk : r/p/a.xml' -> 'animator-v21\lb_onboarding_logo_enter'
S: Could not decode file, replacing by FALSE value: r/p/a.xml
I: Decoding values */* XMLs...
I: Decoding [59] value files from: com.xiaojie.tv
I: 1/59 values-v25\styles.xml
I: 59/59 values-v22\styles.xml
I: DONE decoding resources
Click to expand...
Click to collapse
Hello,
I didn't test it on windows pc, if you are sure works on mac the problem could be some where in the code, mis using file separator character. For linux&mac '/' for windows '\'.
I will fix it on the next version
kikfox said:
Hello,
I didn't test it on windows pc, if you are sure works on mac the problem could be some where in the code, mis using file separator character. For linux&mac '/' for windows '\'.
I will fix it on the next version
Click to expand...
Click to collapse
FileDirectory.java, fix file separator and ensure parent dirs. Now it works.
Java:
protected OutputStream getFileOutputLocal(String name) throws DirectoryException {
try {
return new FileOutputStream(fileEnsuredDirs(generatePath(name)));
} catch (FileNotFoundException e) {
throw new DirectoryException(e);
}
}
private File fileEnsuredDirs(String path) {
File file = new File(path);
File parent = file.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
return file;
}
private String generatePath(String name) {
return getmDir().getPath() + File.separator + name;
}
a452388 said:
FileDirectory.java, fix file separator and ensure parent dirs. Now it works.
Java:
protected OutputStream getFileOutputLocal(String name) throws DirectoryException {
try {
return new FileOutputStream(fileEnsuredDirs(generatePath(name)));
} catch (FileNotFoundException e) {
throw new DirectoryException(e);
}
}
private File fileEnsuredDirs(String path) {
File file = new File(path);
File parent = file.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
return file;
}
private String generatePath(String name) {
return getmDir().getPath() + File.separator + name;
}
Click to expand...
Click to collapse
Exactly,
Glad to hear from someone with good understanding
Maybe you will be much interested in : github.com/REAndroid/ARSCLib
a452388 said:
FileDirectory.java, fix file separator and ensure parent dirs. Now it works.
Java:
protected OutputStream getFileOutputLocal(String name) throws DirectoryException {
try {
return new FileOutputStream(fileEnsuredDirs(generatePath(name)));
} catch (FileNotFoundException e) {
throw new DirectoryException(e);
}
}
private File fileEnsuredDirs(String path) {
File file = new File(path);
File parent = file.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
return file;
}
private String generatePath(String name) {
return getmDir().getPath() + File.separator + name;
}
Click to expand...
Click to collapse
kikfox said:
Exactly,
Glad to hear from someone with good understanding
Maybe you will be much interested in : github.com/REAndroid/ARSCLib
Click to expand...
Click to collapse
And there's another bug, kikfox can not handle the '.jar' Android library. And the fix:
Code:
// ApkDecoder.java
// Do not do refactor if no resources
private void refactorResources() throws AndrolibException {
if (!this.mNoRefactor && (this.hasResources() || this.hasManifest())) {
ResTable resTable = this.getResTable();
ResRefactor resRefactor = new ResRefactor(this.mApkFileList, resTable, this.mRefactorFile);
resRefactor.refactorAll();
}
}
// Androlib.java
// resTable can be null
public void decodeUnknownFiles(ApkFile apkFile, File outDir, ResTable resTable) throws AndrolibException {
Set<ResResource> allFiles = resTable != null ? resTable.listSourceFiles(apkFile.getName()) : Collections.emptySet();
LOGGER.info("Copying unknown files '" + apkFile.getName() + "'");
File unknownOut = new File(outDir, "unknown");
...
}
// ApkFileList.java
// add '.jar' as ApkFile
private static boolean isApkFile(File file) {
if (file != null && file.isFile()) {
String name = file.getName();
name = name.toLowerCase();
return name.endsWith(".apk") || name.endsWith(".jar");
} else {
return false;
}
}
a452388 said:
And there's another bug, kikfox can not handle the '.jar' Android library. And the fix:
Code:
// ApkDecoder.java
// Do not do refactor if no resources
private void refactorResources() throws AndrolibException {
if (!this.mNoRefactor && (this.hasResources() || this.hasManifest())) {
ResTable resTable = this.getResTable();
ResRefactor resRefactor = new ResRefactor(this.mApkFileList, resTable, this.mRefactorFile);
resRefactor.refactorAll();
}
}
// Androlib.java
// resTable can be null
public void decodeUnknownFiles(ApkFile apkFile, File outDir, ResTable resTable) throws AndrolibException {
Set<ResResource> allFiles = resTable != null ? resTable.listSourceFiles(apkFile.getName()) : Collections.emptySet();
LOGGER.info("Copying unknown files '" + apkFile.getName() + "'");
File unknownOut = new File(outDir, "unknown");
...
}
// ApkFileList.java
// add '.jar' as ApkFile
private static boolean isApkFile(File file) {
if (file != null && file.isFile()) {
String name = file.getName();
name = name.toLowerCase();
return name.endsWith(".apk") || name.endsWith(".jar");
} else {
return false;
}
}
Click to expand...
Click to collapse
You are so good!
For
Code:
isApkFile
you are right it is a bug.
I am aware it will fail at no resource scenario, because my tool is aimed to handle "RESOURCE" obfuscated apks with some functionality which apktool lacks, NOT to replace apktool.
BTW:
I am going to abandon this tool working on a new tool :
1. Independent of apktool & aapt/aapt2
2. Integrated with smali/baksmali to refactor java classes
3. Proto <-> Binary resources (arsc)
Thank you again
GREAT

Categories

Resources