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

[core] Bug: showing invalid resource names in some specific APK files #919

Closed
AndroidDeveloperLB opened this issue Apr 29, 2020 · 10 comments · Fixed by #923
Closed

[core] Bug: showing invalid resource names in some specific APK files #919

AndroidDeveloperLB opened this issue Apr 29, 2020 · 10 comments · Fixed by #923
Labels
bug Core Issues in jadx-core module

Comments

@AndroidDeveloperLB
Copy link

Describe error

The bug is that I get these:

    <application android:label="  ?0x7 131072" android:defaultToDeviceProtectedStorage="true" android:directBootAware="true">
        <service android:label="  ?0x7 131073" android:name="android.ext.services.notification.Assistant" android:permission="android.permission.BIND_NOTIFICATION_ASSISTANT_SERVICE" android:exported="true">

image

The label is invalid.

@AndroidDeveloperLB AndroidDeveloperLB added Core Issues in jadx-core module bug labels Apr 29, 2020
@jpstotz
Copy link
Collaborator

jpstotz commented Apr 29, 2020

That is an interesting case. The attribute value is of type 7, but the TYPE_* constants in TypedValue.java do not define a type 7. Hence this value type is not specified in Android.

The value "131072" is the resource-ID containing the String Android Services Library.

apktool however seem to be able to decode this manifest it resolves the label as @string/app_name

@AndroidDeveloperLB
Copy link
Author

How could it be? Is it possible to fix it?

@jpstotz
Copy link
Collaborator

jpstotz commented Apr 29, 2020

As wer are outside of the specification we cloud only implement some code based on the sample data we have. But this code is likely to fail with a different APK as the definition of the data and how the different values relate to each other is unclear.

@jackwpa
Copy link

jackwpa commented Apr 29, 2020

AFAIR types 7 and 8 are for TYPE_DYNAMIC_REFERENCE and TYPE_DYNAMIC_ATTRIBUTE, respectively. Those references can be resolved and then used as TYPE_REFERENCE and TYPE_ATTRIBUTE.

JEB renders that portion as:

<service android:exported="true" android:label="DynRef_0x00020001" android:name="android.ext.services.notification.Assistant" android:permission="android.permission.BIND_NOTIFICATION_ASSISTANT_SERVICE">

aapt2 generates a similar (unresolved) output:

E: service (line=45)
    A: http://schemas.android.com/apk/res/android:label(0x01010001)=@0x00020001

@AndroidDeveloperLB
Copy link
Author

But somehow the Android framework handles it fine.
I tested, and it returns the correct app-label of this APK: "Android Services Library"

@jpstotz
Copy link
Collaborator

jpstotz commented Apr 29, 2020

@jackwpa Thanks for the info that sounds very good. A little research showed up that the Roboelectric project has an implementation that mentions those types. The project is under MIT license so we can use it as source for info and code.

apktool defines it here: https://github.com/iBotPeaches/Apktool/blob/3ee39c988ac82962b01aabb096a36c21d8d1f9da/brut.apktool/apktool-lib/src/main/java/android/util/TypedValue.java#L57
and uses it here:
https://github.com/iBotPeaches/Apktool/blob/b4493a51bbc5582175e1f6a93a71ae7c58428818/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/value/ResValueFactory.java#L36

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Apr 29, 2020

You can also get it from ClassyShark:
https://github.com/google/android-classyshark

This is its result:

image

Maybe you could have a dependency to their code ? Could be better to depend on Google, no?
But... it seems quite old...

Checking here:
https://www.apkdecompilers.com/
I actually got the manifest right:

...android:label="@string/app_name">

AndroidManifest.zip

@AndroidDeveloperLB
Copy link
Author

Why close? Was it fixed already?

@skylot
Copy link
Owner

skylot commented Apr 29, 2020

@AndroidDeveloperLB Yes, I just merged PR #923 submitted by @jpstotz .
Now, these attributes look right: <application android:label="@string/app_name"
Please check latest unstable build.

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Apr 29, 2020

Sadly I still don't know how to use it on Android.
Once I figure out, I could make a nice sample that will check all APK files on the device. This APK I've found by trying to check how well JADX handles APK files that another library that I tried - had some issues with (here) .

Can you please help me on this? I need to know the dependency that I will have to put into gradle file, and then I need to know how, given an InputStream, of the APK file (or the manifest if you wish), to get the result information: package-name, version-code, version-name, app-label, app-icon...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants