yashsingh1/xdaforums huggingface dataset:
[Android Software Development] vinodkbishnoi:
Hi,

I have decompiled an APK using apktool. And changed one file "strings.xml" The language was in Chines and I just replaced all Chines text with English. Now I recompiled that APK using apktool. Then I signed that APK with JARSIGNER. Then I zipaligned the APK.

And then I tried to install APK thorough "adb install" command and I was geeting "install failed shared user incompatible".

These are starting line of Menifist.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest android:sharedUserId="android.uid.system" android:versionCode="1" android:versionName="1.0" package="com.android.ktcit"

xmlns:android="http://schemas.android.com/apk/res/android">

<application android:label="@string/app_name" android:icon="@drawable/icon" android:name="KTCITApp">

<receiver android:label="@string/app_name" android:name=".KTCITBootReceiver">

<intent-filter>

<action android:name="android.intent.action.BOOT_COMPLETED " />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</receiver>​

What should I do?
[Android Software Development] flshg:
@vinodkbishnoi

I guess you're trying to edit a system apk. I think you have to sign it using the original rom platform key as android has checked that the app keys dont match. You could also try pushing the app into the system/app folder to make it part of the rom.
[Android Software Development] iBotPeaches:
You resigned it with a new key. Take the original APK, and move the resources.arsc, and any binary folder that exists in build/res/ and move those into the original apk.

That will retain the original signature, but with your new changes.
[Android Software Development] reosm:
Browser.apk, settings.apk, contacts.apk Please send decompile state lines is missing, please help me
[Android Software Development] csphelps76:
i've been tryin to download the patched aapt for linux but all i'm getting when i click the link is a page full of coded script and no file....any help here?
[Android Software Development] iBotPeaches:
Your browser is opening the file instead of downloading it. Just "Save Link as".

basic stuff here :o
[Android Software Development] csphelps76:
thanks for the quick reply...my brain is kinda mush at this point...i've been up since yesterday morning blowing out windows and setting up ubuntu and just found this new apktool...didn't even cross my mind to save the link as a file
[Android Software Development] csphelps76:
chris@chris-HP-Pavilion-dv7-Notebook-PC:~$ apktool d framework-res.apk

Input file (framework-res.apk) was not found or was not readable.

i get this message regardles what i try to decompile
[Android Software Development] cowsquad:
Okay man, have you installed framework. red.apk on you apktool folder? If yes, open terminal then navigate to the dir that you saved your framework. apk and execute the apktool d framework-res.apk

tapatalked² cowsquadGnex®
[Android Software Development] csphelps76:
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 16, --target-sdk-version, 16, -F, /tmp/APKTOOL3843169143125259360.tmp, -x, -S, /home/chris/appmods/framework-res/res, -M, /home/chris/appmods/framework-res/AndroidManifest.xml]

at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:255)

at brut.androlib.Androlib.buildResourcesFull(Androlib.java:324)

at brut.androlib.Androlib.buildResources(Androlib.java:269)

at brut.androlib.Androlib.build(Androlib.java:192)

at brut.androlib.Androlib.build(Androlib.java:174)

at brut.apktool.Main.cmdBuild(Main.java:188)

at brut.apktool.Main.main(Main.java:70)

Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 16, --target-sdk-version, 16, -F, /tmp/APKTOOL3843169143125259360.tmp, -x, -S, /home/chris/appmods/framework-res/res, -M, /home/chris/appmods/framework-res/AndroidManifest.xml]

at brut.util.OS.exec(OS.java:87)

at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:253)

... 6 more

Caused by: java.io.IOException: Cannot run program "aapt": java.io.IOException: error=13, Permission denied

at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)

at java.lang.Runtime.exec(Runtime.java:610)

at java.lang.Runtime.exec(Runtime.java:483)

at brut.util.OS.exec(OS.java:78)

... 7 more

Caused by: java.io.IOException: java.io.IOException: error=13, Permission denied

at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)

at java.lang.ProcessImpl.start(ProcessImpl.java:81)

at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)

... 10 more

i can install framework and decompile it but get this when i recompile without any changes...and apktool wont pickup any of the other apps i've tried to decompile...something i'm missing?
[Android Software Development] iBotPeaches:
Yes you are missing reading the messages again.

"Caused by: java.io.IOException: java.io.IOException: error=13, Permission denied"

Install the Google SDK. That has aapt. Install aapt into your path. Don't respond back until you can run "aapt" at the command line without a problem.
[Android Software Development] cowsquad:
To all guys in this thread. I have seen some users asking question related to user's errors. in order to use apktool you must set up and have the pre- requisites needed to run apktool.

Windows users. How hard is to download the exe file and click on the file and walla , windows will do the rest. This thread is not about teaching user how to set up your working environment, it's about bugs related to ibotpeaches Apktool project . If you need help decompiling, setting up apktool and building apks, go to GOOGLE and find some help there. There are many helpful threads on xda-developers.com, please use them.

I am not trying to be mean to anyone, but sometimes users ask very common sense questions that could be answered with a little research.

Here are some useful links

Noobs guide about decompiling apks

http://xdaforums.com/showthread.php?t=1860115

This is a useful tool for windows users. This will do all the work for you. All you have to do is read and click options

http://xdaforums.com/showthread.php?t=1633333

How to use apkool

http://xdaforums.com/showthread.php?t=1466100

If I helped you, don't forget the thanks button.

Thank you Cow squad :)

tapatalked² cowsquadGnex®
[Android Software Development] csphelps76:
i had already installed android sdk but for whatever reason the install didn't take and had to redo it...
[Android Software Development] DSA:
Hey IBP

I don't know if this would be related to apktool...I'm assuming it is

I have integrated my own settings into the settings apk, for the apps that I have put a shortcut to into that menu I want to hide from the app drawer.

I know what do, but recompiling after editing the android manifest breaks the signature on the apk and it won't install

Do I have to get my own re-signing kit or is this something that can be included Into apktool at a later date?

Thanks for the great work up to now, 1.5.0 works like a dream for me
[Android Software Development] raziel23x:
Well a work around is to copy the signature to the new file but edit the Hash to the new md5 value

---------- Post added at 02:10 PM ---------- Previous post was at 02:08 PM ----------

It is mostly a hack job but it works
[Android Software Development] iBotPeaches:
This is just the downside to apktool. It generates a new APK w/ a signature mismatch to the original APK. There are 2 ways to fix this.

1) Make a whole new ROM with all these system apps signed together with a full rom signature.

2) Take the original apk. Inject the resources.arsc and any binary folders back into the original APK. It retains signatures and your modifications.

Now for the fun,

I'm working on an extension for the rebuild procedure.

-o, --original

injects resources back into original APK in order to retain signature.

Testing is difficult currently, but this will be a major release and a perfect way to fix this. EX

apktool b MiuiHome -o /system/app/MiuiHome.apk

Will build the folder MiuiHome, and take all the binary changes (resources.arsc, classes.dex, /res folder), and using no compression zip level inject into -o APK, which will retain signature and yet have new files.

The only problem. If you change AndroidManifest.xml and re-inject, that seems to break the signature and cause a signature mismatch. So if the system detects AndroidManifest change -o will refuse to work.
[Android Software Development] Ticklefish:
Can apktool cope with changing filenames?

I ask because my framework-res.apk de- and re-compiles without any issue once I've installed SemcGenericUxpRes.apk. But if I decompile it as mini_framework-res.apk, it doesn't. In fact, it makes aapt crash!

I use the same commands, the same apk's, the same files installed. The only difference is the name.
[Android Software Development] iBotPeaches:
In that case you might have to use the -t for storing the frameworks. So prior to renaming it. Store all the frameworks using

apktool install-framework FRAME.zip tag_name

(EX: apktool install-framework framework-res.apk crespo)

Then during decompile use

apktool d -t crespo name_of_apk.apk
[Android Software Development] Ticklefish:
Oh, I see. Very clever. Many thanks!
[Android Software Development] reosm:
Browser.apk, settings.apk, Please send contacts.apk decompile state lines is missing, please help me
[Android Software Development] Thebear j koss:
Post the log. Did you install all relevant resources to apktool? Apktool may not be compatible with all software and OS. One Plus has it's own OS called oxygen, may need to look in your device /one plus forums for specific instructions and fixes. If it is newest pie beta, i know for a fact it isn't working...

Sent from my PH-1 using Thebear Blue XDA Labs
[Android Software Development] Spannaa:
Did you include all frameworks?

IIRC, OOS 9 has a oneplus-framework-res.apk in priv-app
[Android Software Development] DoR3M3:
What resources you are referring to? When I decompile it's not complaining about wanting any additional frameworks, I mention this below...

According to apktool;

Finding Frameworks

For the most part any apk in /system/framework on a device will be a framework file. On some devices they might reside in /data/system-framework and even cleverly hidden in /system/app or /system/priv-app. They are usually named with the naming of "resources", "res" or "framework".

The only resources I can see matching this are framework-res.apk and oneplus-framework-res.apk

I'm using Oreo 8.1.0

I've been at this for days online, there aren't any forum specific instructions anywhere online across the web for this...

As I mentioned, if I just decompile and then compile it without any changes it still shows errors, meaning, it looks like OnePlus introduced all these errors into their xml according to apktool, as in, this was not done correctly by OnePlus...

OOS 5.1.7 Oreo also has the oneplus-framework-res.apk

If I do ./apktool if oneplus-framework-res.apk - Now I get 5.apk

Framework installed to: /home/foo/.local/share/apktool/framework/5.apk

But when I do ./apktool d Settings it doesn't show it's pulling from several resources.

According to apktool if I needed another resource it would show as loading from them like this example;

$ apktool d HtcContacts.apk

I: Loading resource table...

I: Decoding resources...

I: Loading resource table from file: /home/brutall/apktool/framework/1.apk

I: Loading resource table from file: /home/brutall/apktool/framework/2.apk

I: Copying assets and libs...

So then I run this command, my understanding to all the frameworks in a given /path but I still get the same errors.

./apktool b -c --frame-path /home/foo/.local/share/apktool/framework Settings

Here's a GitHub issue on this problem I'm having;

https://github.com/iBotPeaches/Apktool/issues/1965

By the way if I decompile Settings.apk it shows it's loading it's own resource 1.apk, line in bold, which made me think it doesn't need any additional resources/frameworks? But is this apktool's internal framework?

>./apktool d Settings.apk

I: Using Apktool 2.3.4 on Settings.apk

I: Loading resource table...

I: Decoding Shared Library (com.oneplus), pkgId: 5

I: Decoding AndroidManifest.xml with resources...

I: Loading resource table from file: /home/foo/.local/share/apktool/framework/1.apk

I: Regular manifest package...

I: Decoding file-resources...

I: Decoding values */* XMLs...

I: Baksmaling classes.dex...

I: Baksmaling classes2.dex...

I: Baksmaling classes3.dex...

I: Copying assets and libs...

I: Copying unknown files...

I: Copying original files...

My understanding is if apktool wanted more resources/frameworks it would complain about it like;

Can't find framework resources for package of id: 2. You must install proper framework files...

Thanks

P.S. Info take from apktool docs; https://ibotpeaches.github.io/Apktool/documentation/
[Android Software Development] djdarkknight96:
Are they errors or warnings? Send the entire log so we can see. I have oos files decompiled without issue. I just don't compile them. I make themes so it compiles on the device so resources are all there working.

Edit: I just compiled OOS 8.1 framework successfully but translation warning for their added resources...That's normal. Trying systemui next

Edit 2: systemui only issue is the pip_dismiss_scrim.9.png known issue mentioned here a ton with how to fix it. So I'll try and see. Brb

Edit 3: ok now I see the styles errors with bool true/ false but removing the attribute from Theme.Systemui it builds!
[Android Software Development] djdarkknight96:
Logs have all the love! Lol

Hope that helps
[Android Software Development] DoR3M3:
[MENTION=2126467]djdarkknight96[/MENTION] I was doing a lot of editing when you posted, so you might of missed some of the editing I was doing, please look backup at my last reply and I listed a GitHub issue I posted for this, that shows all the errors/log...

The second reply on GitHub shows all the errors...

Thanks
[Android Software Development] djdarkknight96:
Keep reading mine you'll see I resolved it

Edit: Looks like you are building settings with the log on github but here you said it compiles settings. I'm confused then I'll try settings now
[Android Software Development] DoR3M3:
No I can't compile ./apktool b Settings spits out all those errors on GitHub. :(

Yes I see you resolved what you were doing, but not sure how that applies to Settings.apk?

I see you're going to try settings now, hopefully you can figure out what is going on...

Thanks
[Android Software Development] djdarkknight96:
It builds for me, just noticed I never updated apktool still using 224 so will decompile them compile with 234 next to check
[Android Software Development] djdarkknight96:
Better screenshot
[Android Software Development] djdarkknight96:
It built my friend
[Android Software Development] DoR3M3:
[MENTION=2126467]djdarkknight96[/MENTION] you built the Settings.apk that I posted on that Github issue?

I'm using 2.3.4 and I read through the install Docs before getting it and downloaded also the Linux Wrapper;

https://ibotpeaches.github.io/Apktool/install/

Linux:

Download Linux wrapper script (Right click, Save Link As apktool)

Download apktool-2 (find newest here)

Rename downloaded jar to apktool.jar

Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)

Make sure both files are executable (chmod +x)

Try running apktool via cli

But I did not stick them in /usr/local/bin, I just placed them in my $HOME as;

/home/foo/build/apktool - (Here is everything in that directory for the moment)

New Orig README Settings.apk aapt android build-tools apksigner apktool apktool.jar keystore.jks oneplus-framework-res.apk values

So what commands did you run, how did you get this to build? As I mentioned, I simply decompile and compile it and don't even touch anything I get errors;

./apktool d Settigns.apk & ./apktool b Settings

I also tried without the Linux Wrapper

java -jar apktool.jar d Settings.apk

I: Using Apktool 2.3.4 on Settings.apk

I: Loading resource table...

I: Decoding Shared Library (com.oneplus), pkgId: 5

I: Decoding AndroidManifest.xml with resources...

I: Loading resource table from file: /home/foo/.local/share/apktool/framework/1.apk

I: Regular manifest package...

I: Decoding file-resources...

I: Decoding values */* XMLs...

I: Baksmaling classes.dex...

I: Baksmaling classes2.dex...

I: Baksmaling classes3.dex...

I: Copying assets and libs...

I: Copying unknown files...

I: Copying original files...

java -jar apktool.jar b Settings

I: Using Apktool 2.3.4

I: Checking whether sources has changed...

I: Smaling smali folder into classes.dex...

I: Checking whether sources has changed...

I: Smaling smali_classes2 folder into classes2.dex...

I: Checking whether sources has changed...

I: Smaling smali_classes3 folder into classes3.dex...

I: Checking whether resources has changed...

I: Building resources...

W: /home/foo/Build/apktool/Settings/res/values/styles.xml:45: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Preference.SwitchPreference'.

W:

W: /home/foo/Build/apktool/Settings/res/values/styles.xml:3874: error: Error: No resource found that matches the given name: attr 'android:lightY'.

W:

W: /home/foo/Build/apktool/Settings/res/values/styles.xml:3879: error: Error: No resource found that matches the given name: attr 'android:lightY'.

W:

W: /home/foo/Build/apktool/Settings/res/values/styles.xml:3898: error: Error: No resource found that matches the given name: attr 'android:enableSubtitle'.

What version of Java do you have?

>java -version - I have JRE 8 installed...

java version "1.8.0_181"

Java(TM) SE Runtime Environment (build 1.8.0_181-b13)

Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

I only have Java JRE is this enough?
[Android Software Development] djdarkknight96:
Actually no I built it from a pull a user sent for me so yes I'm trying yours now...brb

No using just Windows not Linux anything
[Android Software Development] DoR3M3:
Ahh ok...

I noticed the Windows cmd prompt you're using... ;)

Thanks

P.S. I also just uploaded the oneplus-framework-res.apk to the GitHub issue if it's needed...
[Android Software Development] djdarkknight96:
It built with no edits

Yes and I have pixel Pie framework installed so shouldn't matter if using op framework

So this wouldn't be apktool issue since I got it built

Apktool b settings
[Android Software Development] DoR3M3:
So let me simplify...

I installed Java JRE 8

I downloaded and placed the apktool wrapper script and apktool.jar in a folder.

I placed Settings.apk in the same folder as the wrapper script and apktool.jar.

This is all I now have in that directory hopefully you understand Linux naming and paths? It's just like I have C:\Build\apktool and these files in them is all;

~/Build/apktool >

Settings.apk apktool apktool.jar

What do mean you have the Pie Framework installed? Maybe I need to install a framwork for this?

If you could please be so kind and explain what Java you have installed and where you have apktool installed, if it's like installed as example in the android build-tools folder, etc...?

I just need you to break down the steps of how you have everything setup to accomplish this, becasue if you have this working then maybe my Build Enviroment is not correct is all I can think... hmm

Also what are all the decompile compile commands you ran?

THANKS
[Android Software Development] djdarkknight96:
I have no Linux experience since 2005 so never used this on Linux.

I set this up a long time ago so not sure I missed a step.

I have Java Home set in my windows variables and just place the aapt.exe aapt2.exe and the.bat and .jar in the folder and use command from that folder to decompile and compile.
[Android Software Development] DoR3M3:
Ok don't worry about Linux, just please try and tell me what you are doing at the moment?

Ok Java set...

So you have the apktool.bat and apktool.jar along with aapt.exe and aapt2.exe and this is all you have in the folder along with the Settings.apk?

So now what commands are you running to do this? I still don't understand how you are decompiling this, and then compile it, please show me?

Where is the framework installed that you are talking about?

Thanks
[Android Software Development] djdarkknight96:
I didn't do anything special "apktool d settings.apk" then "apktool b settings"

When pie came out stable I got the framework and used "apktool if framework-res.apk" it installed it to my pc just like I seen you have done so it's installed correctly but also apktool has the resources already. So I don't think it's that. But I'll upload the apk so you can try it.

https://drive.google.com/file/d/1Nv5HGKkgdhPz4TjSkX3Uc75SqfDBHUSe/view?usp=drivesdk
[Android Software Development] djdarkknight96:
The folder I build with. Just so you see nothing special
[Android Software Development] DoR3M3:
Ok now we're getting somewhere, but I need to please know the order you are running commands in?

Like is this what you are doing?

apktool if framework-res.apk

apktool d Settings.apk

apktool b Settings

OH and if this is what you are doing, I did it like this and YES it compiles, but then the phone is messed up, just a blank screen when it boots, so it doesn't work like this... :(
[Android Software Development] djdarkknight96:
Yep perfect steps!

Ok now the tricky part..I lie it's the easy part. System apps you can't use entire build.

Edit files

Build

Take only edited files and drop in untouched apk using 7zip

Also do not sign it, so keep original signature and manifest.

If edited values only place resources.arsc to the untouched apk. If Smali drop classes, if layout only place layouts you edited...

All from build folder.
[Android Software Development] DoR3M3:
Ok I understand the working with an untouched apk, I've done this in the past.

The problem now is I need to edit in /res/values xml files, so I need to decompile the apk so the resoruces.arsc is decocded.

So now the tricker part, I don't know how I can edit res/values xml files and pack them back into the resources.arsc and then take the new resources.arsc and put it into the untouched apk?

hmm
[Android Software Development] djdarkknight96:
They get built when you build

Values is inside the resources.arsc so only drop from build folder that and the edits will be moved to untouched apk.
[Android Software Development] DoR3M3:
Sorry I don't understand what you are saying?

Can you please elaborate some steps?

1. apktool d Settings.apk

2. Settings\res\values - I edit a few xml files

3. Now what next?

Thanks
[Android Software Development] djdarkknight96:
4. Build with apktool b settings

5. Go inside build folder it will have all files built with the edits you made

6. Drop resources.arsc to untouched apk

7. Place now touched apk to system
[Android Software Development] DoR3M3:
Nope doesn't work... :(

Settings\build\apk only has 3 dex files in it;

classes.dex classes2.dex classes3.dex
[Android Software Development] djdarkknight96:
Build folder not apk

Oh wait, yes right directory..brb
[Android Software Development] DoR3M3:
The only thing in the build folder is the apk folder with those dex files in it... :eek:

Since it craps at compiling, I don't see how I'll end up with anything in the build folder, I assume that apktool b Settings needs to complete properly, then I will have something in the build folder as you suggest... hmm
[Android Software Development] djdarkknight96:
Then something isn't right,, I'm building again because I deleted it. Brb
[Android Software Development] djdarkknight96:
See here I have it all built