Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with apktool b #1533

Closed
MJM111 opened this issue Jun 19, 2017 · 25 comments
Closed

Error with apktool b #1533

MJM111 opened this issue Jun 19, 2017 · 25 comments

Comments

@MJM111
Copy link

MJM111 commented Jun 19, 2017

Information

  1. Apktool Version (apktool -version) -2.1.1
  2. Operating System (Mac, Linux, Windows) -Linux Ubuntu 16.04 LTS
  3. APK From? (Playstore, ROM, Other) -Playstore

Stacktrace/Logcat

I: Using Apktool 2.1.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
Exception in thread "main" brut.androlib.AndrolibException: java.io.FileNotFoundException: /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/build/apk/classes.dex (No such file or directory)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:55)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:38)
	at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:364)
	at brut.androlib.Androlib.buildSources(Androlib.java:295)
	at brut.androlib.Androlib.build(Androlib.java:278)
	at brut.androlib.Androlib.build(Androlib.java:254)
	at brut.apktool.Main.cmdBuild(Main.java:224)
	at brut.apktool.Main.main(Main.java:84)
Caused by: java.io.FileNotFoundException: /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/build/apk/classes.dex (No such file or directory)
	at java.io.RandomAccessFile.open0(Native Method)
	at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
	at org.jf.dexlib2.writer.io.FileDataStore.<init>(FileDataStore.java:13)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:53)
	... 7 more

Steps to Reproduce

  1. apktool
  2. got the apk, changed a eqz to a nez to defeat cert pinning, saved it.
  3. did 'apktool b base' in the folder with base in it, got the above error
  4. I checked and there isn't a 'build' folder in 'base', I get that, just wondering why there isn't one/how to get around it.

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files
(.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it.

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything?YES, still got errors
  2. If you are trying to install a modified apk, did you resign it?I modified it, but need to build before I resign it.
  3. Are you using the latest apktool version? no, using 2.1.1
@MJM111
Copy link
Author

MJM111 commented Jun 19, 2017

I'm using 2.1.1 because I heard there was a regression error in the latest version. Will try latest version and post here.

@iBotPeaches
Copy link
Owner

Interesting. So a regression with latest that no one shares with the bug tracker? That will make sure it gets fixed :o

On topic...
So the application was named base.apk? You decoded to base/ folder? then compiled via apktool b base? This error is some environmental oddity where the assembled dex file is not to be found.

@MJM111
Copy link
Author

MJM111 commented Jun 19, 2017

Thanks for the quick response. Yep, it's named base.apk. I did:
apktool d base.apk
then altered the smali, saved it
apktool b base, errors

Any way to fix this? Does it have to do with the aapt or the framework?

@iBotPeaches
Copy link
Owner

Not sure. Looks like environment problem from the details I have. aapt is not involved at the assembling of .smali file stage so not that. Frameworks also have nothing to do with this stage, so related to the filesystem creating that .dex file as it assembles the smali files.

@MJM111
Copy link
Author

MJM111 commented Jun 19, 2017

When I run the same command but with sudo: sudo apktool b base I get this:
[sudo] password for mm:

I: Using Apktool 2.1.1
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 resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_2588416753999631477.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 25, --version-code, 90, --version-name, 2017.20.177.471142, -F, /tmp/APKTOOL7722875278552765767.tmp, -0, arsc, -0, js, -0, bin, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/res, -M, /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/AndroidManifest.xml]
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:437)
	at brut.androlib.Androlib.buildResources(Androlib.java:371)
	at brut.androlib.Androlib.build(Androlib.java:281)
	at brut.androlib.Androlib.build(Androlib.java:254)
	at brut.apktool.Main.cmdBuild(Main.java:224)
	at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_2588416753999631477.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 25, --version-code, 90, --version-name, 2017.20.177.471142, -F, /tmp/APKTOOL7722875278552765767.tmp, -0, arsc, -0, js, -0, bin, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/res, -M, /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/AndroidManifest.xml]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:436)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:423)
	... 5 more
Caused by: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_2588416753999631477.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 25, --version-code, 90, --version-name, 2017.20.177.471142, -F, /tmp/APKTOOL7722875278552765767.tmp, -0, arsc, -0, js, -0, bin, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/res, -M, /home/mm/Desktop/Work/workdayMobile/prodWorkday/base/AndroidManifest.xml]
	at brut.util.OS.exec(OS.java:97)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:430)
	... 6 more
Caused by: java.io.IOException: Cannot run program "/tmp/brut_util_Jar_2588416753999631477.tmp": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at brut.util.OS.exec(OS.java:90)
	... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 8 more

@MJM111
Copy link
Author

MJM111 commented Jun 19, 2017

So it seems to get past the classes.dex issue

@iBotPeaches
Copy link
Owner

Another permission issue. You don't have permission to write/execute files from java tmpdir. You can download the aapt binaries used from the repo and use the --aapt binary_path_to_file parameter to load it elsewhere. This looks like support, not really a bug so far.

  1. aapt binaries here - https://github.com/iBotPeaches/Apktool/tree/master/brut.apktool/apktool-lib/src/main/resources/prebuilt/aapt

@Delphian2015
Copy link

I have the same error using 2.2.3 jar. What shall we do with aapt? Download and install?

@iBotPeaches
Copy link
Owner

@Delphian2015 If you don't have permission to java tmpdir, that would be a solution.

@Delphian2015
Copy link

Thank you for fast answer. Downloaded aapt. Then installed it. After that started command: apktool d base.apk, then apktool b base. And caught the same error.

@Delphian2015
Copy link

This apk for Android 7.1

@iBotPeaches
Copy link
Owner

Did you read my comment directly above your first response? #1533 (comment)

You need to tell apktool where to find that aapt binary.

@Delphian2015
Copy link

I put all files into folder d:\apktool (apktool.bat, apktool.jar and aapt). Then did in command prompt d:\apktool\aapt.exe. Or is this an incorrect command?

@iBotPeaches
Copy link
Owner

That is not correct. Please read this comment again - #1533 (comment)

@Delphian2015
Copy link

iBotPeaches I read, but I am not an expert in this. Can you explain more detail how to "use the --aapt binary_path_to_file parameter to load it elsewhere"? I have all files and apk into d:\apktool. What shall I do? Thank you for your help.

@iBotPeaches
Copy link
Owner

Respectfully, this is very basic parameter stuff. We've now clogged a bug report with 10 replies over things located in the documentation and internet.

apktool d --aapt D:\apktool\aapt.exe base.apk 

@Delphian2015
Copy link

Delphian2015 commented Jun 27, 2017

iBotPeaches before that I was using apk studio, but today I caught the error and downloaded apktool and now i am trying understand how to work with it. I tried
apktool d --aapt D:\apktool\aapt.exe base.apk
apktool b --aapt D:\apktool\aapt.exe base

Caught the same error:

d:\apktool>apktool b --aapt d:apktool\aapt.exe base
I: Using Apktool 2.2.3
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_assets folder into assets.dex...
base\smali_assets\java\com\d\b\a\a.smali[15,4] Class Lcom/d/b/a/a; has already b
een interned
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file
: java/com/d/b/a/a.smali
        at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:75)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:59)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
        at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:420)
        at brut.androlib.Androlib.buildNonDefaultSources(Androlib.java:366)
        at brut.androlib.Androlib.build(Androlib.java:308)
        at brut.androlib.Androlib.build(Androlib.java:264)
        at brut.apktool.Main.cmdBuild(Main.java:231)
        at brut.apktool.Main.main(Main.java:84)

@iBotPeaches
Copy link
Owner

That error has nothing to do with aapt. You can see right here

base\smali_assets\java\com\d\b\a\a.smali[15,4] Class Lcom/d/b/a/a; has already been interned

You must have two classes with same name - https://stackoverflow.com/questions/32505162/smali-multidex-has-already-been-interned/32507592

@Delphian2015
Copy link

How do I understand this error is related to the language? Because there is no answer in stackoverflow. I didn't change anything in base folder, only did decode and build.

@MJM111
Copy link
Author

MJM111 commented Jun 28, 2017

I've made it a bit further through the build process, I'm now getting this exact error (for which you posted a solution): #1371
However I'm using version 2.1.1. Is there a workaround for that version?

@iBotPeaches
Copy link
Owner

Download the latest framework and install it apktool if newer_framework.apk? That would work around #1371 as that is just updating the internal framework to a newer version.

@MJM111
Copy link
Author

MJM111 commented Jun 28, 2017

From my phone (a droid) or from a newer version of apktool?

@Delphian2015
Copy link

The error because of two copy of the folder in smali_assets the first one - smali_assets/java/com, the second smali_assets/com the folders have the same files, if I delete one of them I can build apk with warnings, but the apk doesn't work.

@MJM111
Copy link
Author

MJM111 commented Jul 31, 2017

I got my issue fixed. Thanks for the help!

@iBotPeaches
Copy link
Owner

Thanks for responding, I will close this then as you were original OP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants