Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixes handling of applications without packages in resources #66

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

Open
kiber-io wants to merge 1 commit into REAndroid:main
base: main
Choose a base branch
Loading
from kiber-io:main

Conversation

@kiber-io
Copy link

@kiber-io kiber-io commented Jun 20, 2024

After one of the latest changes the handling of applications that don't contain packages in the .arsc file broke down:

ERROR:
java.io.IOException: Can not decode without package
	at com.reandroid.arsc.chunk.xml.ResXmlDocument.serialize(ResXmlDocument.java:509)
	at com.reandroid.apk.ApkModuleXmlDecoder.serializeXml(ApkModuleXmlDecoder.java:250)
	at com.reandroid.apk.ApkModuleXmlDecoder.decodeAndroidManifestXml(ApkModuleXmlDecoder.java:229)
	at com.reandroid.apk.ApkModuleXmlDecoder.decodeAndroidManifest(ApkModuleXmlDecoder.java:198)
	at com.reandroid.apk.ApkModuleDecoder.decode(ApkModuleDecoder.java:56)
	at com.reandroid.apkeditor.decompile.Decompiler.run(Decompiler.java:71)
	at com.reandroid.apkeditor.decompile.Decompiler.execute(Decompiler.java:210)
	at com.reandroid.apkeditor.Main.execute(Main.java:81)
	at com.reandroid.apkeditor.Main.execute(Main.java:64)
	at com.reandroid.apkeditor.Main.main(Main.java:36)

And on build:

Exception in thread "main" java.lang.IllegalArgumentException: java.io.IOException: Can not decode without package
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.getBytes(XMLEncodeSource.java:53)
	at com.reandroid.archive.ByteInputSource.openStream(ByteInputSource.java:38)
	at com.reandroid.apk.ApkModule.getAndroidManifest(ApkModule.java:787)
	at com.reandroid.apkeditor.smali.SmaliCompiler.buildDexFiles(SmaliCompiler.java:54)
	at com.reandroid.apk.ApkModuleEncoder.encodeDexFiles(ApkModuleEncoder.java:152)
	at com.reandroid.apk.ApkModuleEncoder.scanDirectory(ApkModuleEncoder.java:45)
	at com.reandroid.apkeditor.compile.Builder.buildXml(Builder.java:116)
	at com.reandroid.apkeditor.compile.Builder.run(Builder.java:47)
	at com.reandroid.apkeditor.compile.Builder.execute(Builder.java:181)
	at com.reandroid.apkeditor.Main.execute(Main.java:85)
	at com.reandroid.apkeditor.Main.execute(Main.java:64)
	at com.reandroid.apkeditor.Main.main(Main.java:36)
Caused by: java.io.IOException: Can not decode without package
	at com.reandroid.arsc.chunk.xml.ResXmlDocument.parse(ResXmlDocument.java:470)
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.encode(XMLEncodeSource.java:77)
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.getArray(XMLEncodeSource.java:65)
Caused by: java.io.IOException: Can not decode without package
	at com.reandroid.apk.xmlencoder.XMLEncodeSource.getBytes(XMLEncodeSource.java:51)
	... 11 more

packageBlock = tableBlock.pickOrEmptyPackage();
}
if(packageBlock != null) {
manifestBlock.setPackageBlock(packageBlock);
Copy link
Owner

@REAndroid REAndroid Jun 20, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you,

there are some cases where packages will be constructed latter, can you experiment with this one ?
put setApkFile out of if block

 if(packageBlock != null) {
 manifestBlock.setPackageBlock(packageBlock);
 }
 manifestBlock.setApkFile(this);

Copy link
Owner

@REAndroid REAndroid Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ...
The purpose of ensureLoadedManifestLinked() is to check multiple times that manifest has correct package. In both cases ( pickOneOrEmpty & setApkFile) the manifest will claim having correct package even if new package is produced latter.

My other idea is :

 if(packageBlock != null && !packageBlock.isEmpty()) {
 TableBlock linkedTable = packageBlock.getTableBlock();
 if(linkedTable == tableBlock) {
 return;
 }
 }
 packageBlock = tableBlock.pickOne(manifestBlock.guessCurrentPackageId());
 if(packageBlock == null) {
 packageBlock = tableBlock.pickOrEmptyPackage();
 }

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

Reviewers

@REAndroid REAndroid REAndroid left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /