Related
Hi all,
I modifed an app so that it would run on my phone--I have a cyanogen ROM, and it doesn't play well. The app runs fine on my wife's stock G1. Anyway, I used baksmali and smali to make the necessary changes, and it recompiles fine. I also "decrypted" the AndroidManifest.xml (from binary to text), resigned the package, and I get the dreaded "file does not contain AndroidManifest.xml" error.
Apparently, the AndroidManifest.xml doesn't get built back to its binary mode during the package signing.
1. How do I get AndroidManifest.xml back into its proper binary format?
2. Is there anything else I am missing?
Thanks.
The XML files are converted during the process of building the .apk file, i.e. by "aapt". You can do this manually if you want.
http://developer.android.com/guide/developing/tools/aapt.html
derfolo said:
I also "decrypted" the AndroidManifest.xml (from binary to text)
Click to expand...
Click to collapse
By what means did you accomplish this? Did you use aapt or did you do it manually?
lbcoder,
There is a handy tool to do this called AXMLPrinter2.jar. It is available here:
http://code.google.com/p/android4me/downloads/detail?name=AXMLPrinter2.jar&can=2&q=
I am having problems using aapt to "binarize" only the AndroidManifest.xml file. I can't package the entire app, because the baksmali files are not recognizable by Eclipse as java files, and when I use smali, it is all converted back into classes.dex. Any ideas?
Just to be clear, I am doing:
Code:
./aapt package -z -u -A ./app.directory -F ./app.name.apk
An .apk file pops up with no errors, but: 1) AndroidManifest.xml is not converted to binary, and 2) the same error "does not contain AndroidManifest.xml" occurs.
Thanks for any help.
Hi, it seems some dear users have problems with Miui V5 framework and miui's applications decompiling proccess.
let's begin!
for this job, Im editing the APK Multitool, and all credits will goes to his developer. [raziel23x]
original thread
what's new on this?
changed the aapt to miui compatible, added miui frameworks to default list, added additional frameworks, also you can pull back the files from the phone via adb command.
i wrote it before, original thread
-------------------------------------------------------------------------------------------------------------------------------------------------------------
for version 11.0.1.2 and older!
Download the Attached file.
extract it.
copy these files
Code:
framework-res.apk
framework-miui-res.apk
twframework-res.apk
MiuiSystemUI.apk
from Miui Rom into other folder.
run, Setup.bat script.
Select option 2:
Code:
*
* 2. Installing Framework-Res
* This Will install one of the Framwork-Res Files for 1.x/2.x/3.x/4.x
* This Feature also will install any of the other Dependencies needed
* In order to use this feature make sure to drop all of the needed files
* into the other Folder or else this script will not find them *
*
in next window, install these frameworks by entering related numbers. install it as this order and sequence
Code:
Install framework-res.apk
Install twframework-res.apk
Install Additional Frameworks
Install framework-miui-res.apk
Install MiuiSystemUI.apk
after installing, enter the "9" to get back to main screen.
run setup by entering "3".
Code:
3. Setup Directories
This will setup the appropate directories needed by Apk Multi-Tools
(This script only needs to be ran for first time users do not use if your
Just updating from previous Version
now new folders will create on main folder of this apk multi tool.
Framework's Description
- 1 = framework-res.apk
- 2 = twframework-res.apk
- 3 = additional frameworks
- 4 = additional frameworks
- 5 = additional frameworks
- 6 = framework-miui-res.apk
- 127 = SystemUI.apk
Version 1.11.0.3 XIAOMI Phones.
1- Download Version 1.0.11.3 [[XIAOMI]MIUI_V5_APKMULTITOOL_1.0.11.3.zip] and extract it.
2- Copy MiuiSystemUI.apk, framework-res.apk and framework-miui-res.apk from your rom or phone into other folder.
3- Run Setup.bat file, choose option 2 and then select option 1 for automatically installing all frameworks.
or you can install frameworks manually
Code:
2. Install framework-res.apk
3. Install dummy frameworks
4. Install framework-miui-res.apk
4- from main menu, run option 3
Code:
3. Setup Directories
This will setup the appropate directories needed by Apk Multi-Tools
(This script only needs to be ran for first time users do not use if your
Just updating from previous Version)
best regards.
How to Edit framework-miui-res.apk?
copy framework-miui-res.apk into "place-apk-here-for-modding" folder, run "Script.bat" file.
choose your project , by entering the " 24 Set current project" [24].
the select your project with related number.
decompile apk.
Code:
9 Decompile apk
when the framework-miui-res.apk get decompiled, goto project folder and on the framework-miui-res.apk , open the "apktool.yml" file via notepadd++.
you will see like this one:
Code:
version: 1.5.2
apkFileName: framework-miui-res.apk
isFrameworkApk: true
usesFramework:
ids:
- 1
sdkInfo:
minSdkVersion: '16'
targetSdkVersion: '16'
packageInfo:
cur_package: miui
orig_package: miui
compressionType: true
add additional frameworks , just like below one
Code:
version: 1.5.2
apkFileName: framework-miui-res.apk
isFrameworkApk: true
usesFramework:
ids:
- 1
- 2
- 3
- 4
- 5
sdkInfo:
minSdkVersion: '16'
targetSdkVersion: '16'
packageInfo:
cur_package: miui
orig_package: miui
compressionType: true
save the file.
now go and edit this file, at final you can compile it.
for compile you can use "11 Compile System APK files" option.
if you have any problem, please upload the "APK-Multi-Tool.log" file and tell your problem.
Changelog:
version 1.0.11.1 initial release
version 1.0.11.2 , fixed framework installing.
Version 1.0.11.3 , specially for XIAOMI phones and updated apktool to version 1.5.3 snapshot.
+ fixed and removed some scripts
+ all in one framework installer [ option 1]
+ added miui JB frameworks [ ID 2 ~ ID5]
M_J_Nazari said:
if you have any problem, please upload the "APK-Multi-Tool.log" file and tell your problem.
Click to expand...
Click to collapse
Thank you Nazari!
I dont know if this script is only meant to work with SGS III files...
I followed your instructions using MI-2 files (without twframework-res.apk of course).
And after de-compiling the apk I can't compile it back.
I'm getting:
error occurred, please check the log (option 21)
Click to expand...
Click to collapse
Btw I notice that inside the apktool.yml
I got
compressiontype: false
Click to expand...
Click to collapse
This is my log:
--------------------------------------------------------------------------
|Sun 06/02/2013 -- 17:55:49.16|
--------------------------------------------------------------------------
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Sagi\apktool\framework\1.apk
I: Loaded.
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.err.CantFindFrameworkResException
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
at brut.androlib.Androlib.buildResources(Androlib.java:283)
at brut.androlib.Androlib.build(Androlib.java:206)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.err.CantFindFrameworkResException
at brut.androlib.res.AndrolibResources.getFrameworkApk(AndrolibResources.java:544)
at brut.androlib.Androlib.parseUsesFramework(Androlib.java:508)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
... 5 more
Click to expand...
Click to collapse
I'm guessing it is because of the 'twframework-res.apk' which i dont have...(MI-2 not Samsung).
SagiMedina said:
Thank you Nazari!
I dont know if this script is only meant to work with SGS III files...
I followed your instructions using MI-2 files (without twframework-res.apk of course).
And after de-compiling the apk I can't compile it back.
I'm getting:
Btw I notice that inside the apktool.yml
I got
This is my log:
I'm guessing it is because of the 'twframework-res.apk' which i dont have...(MI-2 not Samsung).
Click to expand...
Click to collapse
W: Could not find sources
so, don't change the "apktool.yml" file and then compile it. see the result. maybe your phone doesn't boot!!
oh,,, i forget to add framework 5 to package, download it and copy to "C:\Users\Sagi\apktool\framework\" folder. i will update the package as soon.
or you can use new package, i added new description and new fixed version.
M_J_Nazari said:
W: Could not find sources
so, don't change the "apktool.yml" file and then compile it. see the result. maybe your phone doesn't boot!!
oh,,, i forget to add framework 5 to package, download it and copy to "C:\Users\Sagi\apktool\framework\" folder. i will update the package as soon.
or you can use new package, i added new description and new fixed version.
Click to expand...
Click to collapse
After I used the new package I succeed to compile it back but the phone doesn't boot.
In apktool.yml I add only
-1
-3
-4
-5
-2 and -6 gave me errors.
I noticed that the new apk size is smaller then the original.
Sent from my MI 2
SagiMedina said:
After I used the new package I succeed to compile it back but the phone doesn't boot.
In apktool.yml I add only
-1
-3
-4
-5
-2 and -6 gave me errors.
I noticed that the new apk size is smaller then the original.
Sent from my MI 2
Click to expand...
Click to collapse
do a search into framework folder, if there is another apk file, i think you need to install this framework. i don't know about the xiaomi phones like mi2 or another.
and, are you sure that you did all steps perfectly?
could you please tell us what did you exactly for compiling process? i mean after entering option "11".
M_J_Nazari said:
and, are you sure that you did all steps perfectly?
could you please tell us what did you exactly for compiling process? i mean after entering option "11".
Click to expand...
Click to collapse
I followed the steps as you wrote except with the twframework, then I edit the apktool.yml
But instead of adding:
-1 to -6
I only add
-1, -3,-4,-5
I edit the style following your guide,
Then I compiled back by entering option 11, copied the 'unsignedframework-miui-res.apk' to my phone and renamed it to 'framework-miui-res.apk' and past it in system/framework. The phone rebooted but got stuck after the bootanimation.
Sent from my MI 2
SagiMedina said:
I followed the steps as you wrote except with the twframework, then I edit the apktool.yml
But instead of adding:
-1 to -6
I only add
-1, -3,-4,-5
I edit the style following your guide,
Then I compiled back by entering option 11, copied the 'unsignedframework-miui-res.apk' to my phone and renamed it to 'framework-miui-res.apk' and past it in system/framework. The phone rebooted but got stuck after the bootanimation.
Sent from my MI 2
Click to expand...
Click to collapse
what's about the keep folder?
M_J_Nazari said:
what's about the keep folder?
Click to expand...
Click to collapse
What is the keep folder?
Sent from my MI 2
SagiMedina said:
What is the keep folder?
Sent from my MI 2
Click to expand...
Click to collapse
ok, i think it is need to know how to work with apk multi tool.
1- decompie
2- edit your framework
3- enter option 11 to compile
4- programs will ask you about the modification , just like this:
Code:
Building Apk
Aside from the signatures, would you like to copy
over any additional files that you didn't modify
from the original apk in order to ensure least
# of errors (y/n)
Type input:
5- enter " y ' and then press enter.
6- wait for programs, to show you this message
Code:
Everything is Ok
Files: x
Size: xxxxx
Compressed: xxxxx
In the APK Multi-Tools folder u'll find
a keep folder. Within it, delete
everything you have modified and leave
files that you haven't. IF you have modified
any xml, then delete resources.arsc from that
folder as well. Once done then press enter
on this script.
Press any key to continue . . .
7- don't touch anything, minimize Apk Multitool program window ,
8-Go back to the main folder of apk multi tool , you will find the "keep" folder.
goto keep folder and delete thisfile "resources.arsc"
9- get back to Apk Multitool program and hit any key to create a new framework-miui-res.apk file with this name
"unsignedframework-miui-res.apk" file.
10- rename it and copy to your phone, do a permission
you can do it via root Explorer
or terminal command
Code:
chmod 0644 /system/framework/framewok-miui-res.apk
or adb commnad
Code:
adb shell chmod 0644 /system/framework/framewok-miui-res.apk
M_J_Nazari said:
...
Click to expand...
Click to collapse
Still no luck Nazari, did everything like you said...
I cant get pass the boot animation once i replace the framework,
why is the new apk is smaller? is it normal?
SagiMedina said:
Still no luck Nazari, did everything like you said...
I cant get pass the boot animation once i replace the framework,
why is the new apk is smaller? is it normal?
Click to expand...
Click to collapse
its normal, you can select compression level by hitting option "21".
but upload your framework-miui-res.apk here to check it and i will make changes to that.
M_J_Nazari said:
its normal, you can select compression level by hitting option "21".
but upload your framework-miui-res.apk here to check it and i will make changes to that.
Click to expand...
Click to collapse
Thanks Nazari!!!
SagiMedina said:
Thanks Nazari!!!
Click to expand...
Click to collapse
it seems xiaomi uses different framework and aapt version, you need to ask them.
M_J_Nazari said:
it seems xiaomi uses different framework and aapt version, you need to ask them.
Click to expand...
Click to collapse
If ill get these different framework and aapt version, I only need to replace them with the those in the 'other' folder?
Guys, you don't have a clue what that other frameworks are for, do you? You can't miss nr 1 or 6 or 2 framework in apktool.yml because that will never work! Apktool.yml is fine and should look like in the first post.
I think your main issue is that you don't know frameworks IDs?
This:
Code:
1. Install framework-miui-res.apk
2. Install framework-res.apk
3. Install twframework-res.apk
6. Install MiuiSystemUI.apk
7. Install Additional Frameworks
Is wrong!
How to tell what ID framework has?
Run this command:
Code:
apktool if framework-miui-res.apk
You will get:
Code:
I: Framework installed to: /home/acid/apktool/framework/6.apk
So framework-miui-res.apk is ID = 6.
Try to install regular framework-res.apk. You will get ID = 1.
To complete the gap between ID1 and ID6 you have to install proper frameworks. AND MiuiSystemUi is NOT a framework! Thats nonsense!
ID is 127 which is out of range.
You have to install framework files that have proper ID from 1 to 6.
ID1:
framework-res.apk
ID2:
frameworks from producer base. So this is twframework-res for Samsung devices, com.htc.resources.apk for HTC, SemcGenericUxpRes.apk for Sony... etc. That doesnt really matter. ID2 frameworks are used when you recompile stock apps like Samsung TW apps or HTC apps (HTCAlbum, Music etc). If you just want to recompile framework-miui-res and boot rom then you can use any ID2 framework or just a dummy file.
ID3:
This is com.htc.dummyskin.apk. Just search for it. You can find it in HTC One roms (One X and One S). Search in MIUI roms for that devices (but with stock HTC based MIUI!). Or grab the file from micode.
ID4:
This is framework-htc-res.apk. Again. search for it. Also HTC roms should have this or grab dummy framework from micode.
ID5:
From micode.
ID6:
framework-miui-res.apk
Dummy frameworks from MiCode:
https://github.com/MiCode/patchrom_build/tree/jellybean/res
You can use 3-5.apk to fill the gap. But still I advice you to use proper ID2 frameworks in case you would like to compile stock apps.
And for last install frameworks in order:
Code:
apktool if framework-res.apk
apktool if twframework-res.apk (or htc or dummy)
apktool if 3.apk
apktool if 4.apk
apktool if 5.apk
apktool if framework-miui-res.apk
That should allow you to boot the rom. Also make sure you have miui aapt and apktool 1.5.3.
thanks a lot @ Accidd for very good explanation.
i worte it for samsung devices, and it seems its fine. this script will install frameworks automatically.
but for other devices i will update the application again, so if we want to compile Xiaomi frameworks , we need to use dummy framework for ID number 2?
It doesn't matter which device you do. You always have to install all frameworks.
Wysłane z MI-2
M_J_Nazari said:
i will update the application again,
Click to expand...
Click to collapse
Thanks Nazari!
And thank you Acid for clearing things!
Sent from my MI 2
Version 1.0.11.3 added to first post to compile Xiaomi phones frameworks.
In Windows Phone 8 Runtime component (C++/CX) we can use fopen or CreateFile2 to create/open a file. For example
Code:
fopen("hello.txt", "w");
You see, I don't explicitly specify any path. And I can't figure out where this hello.txt resides? It can't be in Installed Location, and it isn't in Local Folder. Where is it?
Well, you could try the following:
_fileno() to get the integer file descriptor from the FILE*
_get_osfhandle() to get the Win32 HANDLE from the fd
GetFileInformationByHandleEx() to get the file name from the HANDLE.
I *think* those are even all supported on WP8, though I haven't checked except for the last one.
APIs like GetFullPathName() would make it easy, but may not be supported. CreateFile2 would let you skip the first two APIs in that list, if it works.
I inspected the WP8 .vhd file, and saw that my file was created in the Install folder. It looks like native code does not conform to the rule (Install folder is read-only location)
Whaaaaaat?!? That's... um. Serious. I'll look into it.
onmyway133 said:
I inspected the WP8 .vhd file, and saw that my file was created in the Install folder. It looks like native code does not conform to the rule (Install folder is read-only location)
Click to expand...
Click to collapse
Are you sure it does not create it on the root of the isolated storage space? That's rather unexpected to have the file in a read-only folder...
The install location is read/write to the app.
What
the
hell?
I can send test code if anybody wants, but it's easy enough to check yourself. You don't even need native code to do it, the .NET APIs work well enough.
I am somewhat confused.
mcosmin222 said:
Are you sure it does not create it on the root of the isolated storage space? That's rather unexpected to have the file in a read-only folder...
Click to expand...
Click to collapse
You can create a simple project to test this. In the C++ WP Runtime Component project, just use fopen or CreateFile2
Then use Hyper-V manager and Disk Management to easily inspect the WP .vhd file (I'm using Emulator)
You can use some things like IsoStoreSpy to see that the newly created file does not reside in the Local Folder (in WP8, they rename Isolated Storage to Local Folder)
I wrote a small app to test it; I can share the source if you want. It's really simple. I used the native APIs to create the file and write to it, then used the managed APIs to confirm it was there and read it, then used the native APIs to delete it, and the managed ones to confirm it was gone. Very simple. I then used the managed APIs to create the file myself (await Package.Current.InstalledLocation.CreateFileAsync("hello.txt")) and it worked.
Have you tried to create a xap file in the Install folder and reboot?
My 8X is freezing after creating a xap...
@spikedviper: No, I haven't tried anything like that. I don't seem to have write access from my app to the folder where pre-installed / OEM XAPs reside.
I did try editing the manifest; I was able to edit it with no problems but changing the capabilities didn't *do* anything, so I'm pretty sure it's still only parsed at install time.
hm...so what is the default path if no path specified?
looks like it stores it here: ms-appdata:///Local/ anyway check out "Data for Windows Phone" at msdn
I am new to Android Studio.I like the IDE very much,it has got some nice set of features and has a rich look and feel, however I have some issues with the IDE. I recently created a Cordova application in android studio.I created an HTML file called index.html under assests/www folder.I included my jquery-1.11.3.min.js inside index.html file.I have the habit of checking whether the file jquery-1.11.3.min.js has been correctly included inside HTML file.In eclipse I use cntrl +click to check whether the js file path given is right.But when I use the same thing in Android studio,even if the path is right,it is showing like 'Cannot find declaration to go to'.Please help me on this.
Quick Intro :
Let me answer that question, an apk, first of all, is the format of Android apps, as .exe would be for Windows, apk means Android Package by the way.
But what’s the big deal?
Well an apk contain a lot of things into it.
When you open it as an archive, you might get those files:
AndroidManifest.xml
assets
res
META-INF
resources.arsc
classes.dex
AndroidManifest.xml is the file that contains the information about the app itself: the list of all activities, all permissions, the name of the app’s package, and the software/hardware requirements. To be able to read it, you’ll need to decompile the apk file.
Assets and res folders are meant for resources. Most often, you won’t see the assets folder because its usage is limited, (explanations here). We’ll focus on res since asset isn’t used so often.
META-INF contains CERT.RSA and CERT.SF (certificate) as well as MANIFEST.MF (a manifest)
Those files are the app signature, and META-INF is the folder that contains signature.
The resources.arsc file is the file holding most of the resources that were originally in the res folder. After compiling the code, Android Studio (or others software) compile resources into this file. You won’t be able to open it with an archive explorer. We’ll need to decompile the apk to get the resources back into the res folder.
And, finally, the classes.dex file contains the every smali files of the app. A smali file contains the java code for a specific part of the app. To be able to have the smali files (into the smali folder), you’ll have to baksmali your app.
Hopefully, apktool (a reverse engineering tool) does it for you.
Let’s decompile the apk using apktool (a popular tool used to decompile apps):
Once apktool is installed (see the apktool web page to know how to install), you’ll need to use the command prompt to decompile the apk:
Code:
java -jar apktool.jar d [name of the apk].apk
(I advise to create a folder and to put every file needed in it: the apk, the apktool.jar file, and the apktool script).
You’ll have an out folder, and when you browse it, you’ll have most of the time:
AndroidManifest.xml
original (a folder)
res (a folder)
smali (a folder)
The AndroidManifest.xml that you see here is the translated one.
In the “original” folder rest the META-INF folder and the original AndroidManifest.xml file (untranslated). As you can guess by its name, this folder contains unchanged original files.
The res folder is now full, because every resource from the resources.arsc file are now back into the res folder
Same for the smali folder, this folder contains every piece of code contained into the classes.dex file.
We will now focus on the res folder. Now that it’s complete, we can see those folders (it depends on your apk, but here is the list of the most common ones):
anim (other animation stuff, see the links at the end of the thread)
animator (animation properties)
color (color state list: in which condition this color is used for a particular element)
drawable (can be pictures or xml files, it contains a lot of things)
layout (contains the files that define the layouts of the app)
mipmap (icons for different screen densities)
values (xml files that contains values, that will be referenced in other xml files in other folders)
xml (every other unclassified xml files)
Those folders contain files that will be named following their resource ID.
So how does all of this work together?
Well, the java code written in the smali files will call resources with their IDs. This way, the app will show you the write thing at the right moment, following the code. The layouts are already described in the layout folder. What the code really do is analyzing the action of the end user and calling other resources in consequence.
For example, I’m using the XDA Labs app on my phone. I’m in my phone’s section, and I’m about to click on a thread to open it.
I clicked on the thread, so the code loaded the thread layout with every post in it, and other resources such as the little arrows at the top to jump to the end/beginning of the thread, the reply button, its color, … That’s how to work if I want to keep it simple.
I tried, in this guide, to simplify android app basic for beginners. Feel free to ask any question, I’ll be glad to answer.
If you want to go further into it, you can read a very complete guide about app basics by google (it’s a bit complicated to read, assuming you’re just starting to understand).
Here are the links:
https://developer.android.com/guide
If you have any question about that guide, you can also ask me (with the quote you didn’t understood).
Keep at mind that mastering app basics is really important if you ever want to theme/create an app. So, this guide and the google one is a good place to start.
Have fun reading
Hello Raiz,
I decompiled the apk of an androind app from playstore using dex jar and apktool however I can't find the scripts anywhere in the resulting files. Where should I look? Or is there something more that I have to do? I'm trying to edit something for personal use to make the game more enjoyable. I saw a .unity3D file in there so I presume it was made in unity if this helps.
Good tutorial about concepts of APK file. The details you share are so educational. Thanks for sharing