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

fix: zip entry name #3038

Closed
wants to merge 1 commit into from
Closed

fix: zip entry name #3038

wants to merge 1 commit into from

Conversation

xtulnx
Copy link

@xtulnx xtulnx commented Apr 9, 2023

In a unity3d game, if there is a resource directory assets/AssetBundles/Assets, for example

assets
├── AssetBundles
│   ├── Assets
│   │   └── a.txt
│   └── b.json

would result in an entry Assets/AssetBundles/b.json in the apk:

$ unzip -l demo.apk | grep -i assets/AssetBundles
         0 04-07-2023 23:03 assets/AssetBundles/Assets/a.txt
         0 04-07-2023 23:10 Assets/AssetBundles/b.json

@jiashie
Copy link

jiashie commented Apr 13, 2023

same issue here!!!

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.

Could we add a test for this? Not following the change and to be sure it doesn't regress - I think we should adapt test apk for both aapt1 and aapt2.

@iBotPeaches
Copy link
Owner

@xtulnx - I wrote a test for this and its not failing without this patch. Am I properly following in this PR? #3074

@xtulnx
Copy link
Author

xtulnx commented May 23, 2023

test-apktool.zip

@iBotPeaches Hi, Here is the demo:

On macOS 13.3.1

Open the Android project, compile and run the application.

view apk:

$  unzip -l ./app/build/outputs/apk/debug/app-debug.apk|grep -i "assets"
       10  01-01-1981 01:01   assets/a.txt
        9  01-01-1981 01:01   assets/AssetBundles/Assets/d.txt
       10  01-01-1981 01:01   assets/AssetBundles/c.txt
       10  01-01-1981 01:01   assets/Assets/b.txt

unpack

$ java -jar ~/tools/apktools/apktool_2.6.0.jar d ./app/build/outputs/apk/debug/app-debug.apk -f -r -s -o tmp

I: Using Apktool 2.6.0 on app-debug.apk
I: Copying raw resources...
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files..

pack

$  java -jar ~/tools/apktools/apktool_2.6.0.jar b tmp

check

$  unzip -l tmp/dist/app-debug.apk | grep -i assets
       10  05-23-2023 11:11   Assets/a.txt
       10  05-23-2023 11:11   Assets/AssetBundles/c.txt
        9  05-23-2023 11:11   assets/AssetBundles/Assets/d.txt
       10  05-23-2023 11:11   assets/Assets/b.txt

Now, miss assets/a.txt and assets/AssetBundles/c.txt , the path has changed.

@iBotPeaches
Copy link
Owner

Couldn't replicate this :/

So closing.

➜  3038 unzip -l app-debug.apk| grep -i "assets"
       10  1981-01-01 01:01   assets/a.txt
        9  1981-01-01 01:01   assets/AssetBundles/Assets/d.txt
       10  1981-01-01 01:01   assets/AssetBundles/c.txt
       10  1981-01-01 01:01   assets/Assets/b.txt
➜  3038 apktool d app-debug.apk -f -r -s -o tmp
I: Using Apktool 2.7.1-7a22af-SNAPSHOT on app-debug.apk
I: Copying raw manifest...
I: Copying raw resources...
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
➜  3038 apktool b tmp 
I: Using Apktool 2.7.1-7a22af-SNAPSHOT
I: Copying tmp classes.dex file...
I: Copying tmp classes2.dex file...
I: Checking whether resources has changed...
I: Copying raw resources...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: tmp/dist/app-debug.apk
➜  3038 unzip -l tmp/dist/app-debug.apk| grep 'assets'
       10  2023-07-04 12:31   assets/Assets/b.txt
        9  2023-07-04 12:31   assets/AssetBundles/Assets/d.txt
       10  2023-07-04 12:31   assets/AssetBundles/c.txt
       10  2023-07-04 12:31   assets/a.txt
➜  3038 

Sorry for delay.

@iBotPeaches iBotPeaches closed this Jul 4, 2023
@stray-coding
Copy link

stray-coding commented Sep 5, 2023

@iBotPeaches You should use a Windows device to reproduce,not Mac device
assets will be rename Assets!!!
image
You can use jadx or 7z to view the wrong assets directory

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.

4 participants