Skip to content

fix rebuild apk without res directory when it use AndResGuard plugin #2943

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

Conversation

xuuhaoo
Copy link

@xuuhaoo xuuhaoo commented Nov 20, 2022

fix rebuild apk without res when the origin apk use https://github.co…m/shwenzhang/AndResGuard plugin to guard resource.
according to AndResGuard official document, ex. "It changes res/drawable/wechat to r/d/a"

…m/shwenzhang/AndResGuard plugin to guard resource.

according to AndResGuard offical document, ex. "It changes res/drawable/wechat to r/d/a"
Copy link
Owner

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

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

Lots of unrelated CS changes in here.

Comment on lines +129 to +130
LOGGER.info("Found illegal resources dir r,decode it!");
apkResourcesFileNames.add("r");
Copy link
Owner

Choose a reason for hiding this comment

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

This messaging pattern does not follow our pattern we have.

apkFile.getDirectory().copyToDir(outDir, APK_RESOURCES_FILENAMES);
Directory directory = apkFile.getDirectory();
List<String> apkResourcesFileNames = new ArrayList<>(Arrays.asList(APK_RESOURCES_FILENAMES));
if (directory.getDirs().containsKey("r")) {
Copy link
Owner

Choose a reason for hiding this comment

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

What about R and r?

try {
LOGGER.info("Copying raw resources...");
apkFile.getDirectory().copyToDir(outDir, APK_RESOURCES_FILENAMES);
Directory directory = apkFile.getDirectory();
List<String> apkResourcesFileNames = new ArrayList<>(Arrays.asList(APK_RESOURCES_FILENAMES));
Copy link
Owner

Choose a reason for hiding this comment

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

Couldn't we just load all the AndResGuard res directories into APK_RESOURCES_FILENAMES and ensure copyToDir handles null/missing directories?

@iBotPeaches
Copy link
Owner

Thanks for drawing my attention to this area. I've refactored it and added a test to prevent regression with raw handling w/ AndResGuard in here - #2944

So closing this one.

iBotPeaches added a commit that referenced this pull request Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants