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: Error: Resource is not public. #2033

Closed
timea-techgirl opened this issue Mar 6, 2019 · 5 comments · Fixed by #2650
Closed

error: Error: Resource is not public. #2033

timea-techgirl opened this issue Mar 6, 2019 · 5 comments · Fixed by #2650

Comments

@timea-techgirl
Copy link

Error

Installing AOSP Contacts.apk on a factory image on Nexus 5 produces this error:
[INSTALL_FAILED_SHARED_USER_INCOMPATIBLE]

I used apktool to decompile Contacts.apk and removed android:sharedUserId="android.uid.shared" from the AndroidManifest.xml

When I rebuild, I get this error. However I fixed it by renaming lines 162 and 169 to @*android:bool and signed it. Now the application installed and it's working fine.

My questions are,
1. Will there be any crashes in the app because I edited it? What part of the app will have errors or missing icons or text due to this?

2. Will there be any implications for removing android:sharedUserId="android.uid.shared"?

3. Why do I get this error for an unmodified apk? Is this a bug in apktool? Because it can't build back an unmodified AOSP apk

Thank you!

Stacktrace/Logcat

java -jar apktool.jar b contacts
I: Using Apktool 2.4.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
S: WARNING: Could not write to (C:\Users\Timea\AppData\Local\apktool\framework), using C:\Users\Timea\AppData\Local\Temp\ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
W: C:\Users\Timea\Desktop\contacts\AndroidManifest.xml:162: error: Error: Resource is not public. (at 'enabled' with value '@android:bool/config_enableActivityRecognitionHardwareOverlay').
W:
W: C:\Users\Timea\Desktop\contacts\AndroidManifest.xml:169: error: Error: Resource is not public. (at 'enabled' with value '@android:bool/config_enableActivityRecognitionHardwareOverlay').
W:
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Timea\AppData\Local\Temp\brut_util_Jar_8957989242335304914.tmp, p, --forced-package-id, 127, --min-sdk-version, 23, --target-sdk-version, 23, --version-code, 23, --version-name, 6.0.1, --no-version-vectors, -F, C:\Users\Timea\AppData\Local\Temp\APKTOOL263780097906636209.tmp, -0, arsc, -0, res/drawable-ldrtl-sw600dp-xhdpi-v13/list_activated_holo.9.png, -0, png, -0, res/drawable-ldrtl-xhdpi-v4/list_background_holo.9.png, -0, res/drawable-ldrtl-xhdpi-v4/list_focused_holo.9.png, -0, res/drawable-ldrtl-xhdpi-v4/list_section_divider_holo_custom.9.png, -0, res/drawable-ldrtl-xhdpi-v4/list_title_holo.9.png, -0, res/drawable-ldrtl-xhdpi-v4/panel_content.9.png, -0, res/drawable-ldrtl-xhdpi-v4/quickcontact_badge_overlay_normal_light.9.png, -0, res/drawable-ldrtl-xhdpi-v4/quickcontact_badge_overlay_pressed_light.9.png, -0, res/drawable-ldrtl-xhdpi-v4/spinner_default_holo_dark.9.png, -0, res/drawable-sw600dp-xhdpi-v13/list_activated_holo.9.png, -0, res/drawable-xhdpi-v4/ab_stacked_solid_inverse_holo.9.png, -0, res/drawable-xhdpi-v4/aggregation_suggestions_bg.9.png, -0, res/drawable-xhdpi-v4/aggregation_suggestions_bg_light_holo.9.png, -0, res/drawable-xhdpi-v4/list_background_holo.9.png, -0, res/drawable-xhdpi-v4/list_section_divider_holo_custom.9.png, -0, res/drawable-xhdpi-v4/panel_content.9.png, -0, res/drawable-xhdpi-v4/quickcontact_badge_overlay_normal_light.9.png, -0, res/drawable-xhdpi-v4/spinner_default_holo_dark.9.png, -0, res/drawable-xxhdpi-v4/ab_solid_custom_blue_inverse_holo.9.png, -0, res/drawable-xxhdpi-v4/list_activated_holo.9.png, -0, res/drawable-xxhdpi-v4/list_focused_holo.9.png, -0, res/drawable-xxhdpi-v4/list_longpressed_holo_light.9.png, -0, res/drawable-xxhdpi-v4/list_pressed_holo_light.9.png, -0, res/drawable-xxhdpi-v4/list_title_holo.9.png, -0, res/drawable-xxhdpi-v4/quickcontact_badge_overlay_pressed_light.9.png, -0, arsc, -I, C:\Users\Timea\AppData\Local\Temp\1.apk, -S, C:\Users\Timea\Desktop\contacts\res, -M, C:\Users\Timea\Desktop\contacts\AndroidManifest.xml]

Information

  1. Apktool Version (apktool -version) - Tried v2.0.0 to v2.4.0 with different errors.
  2. Operating System (Mac, Linux, Windows) - Windows 10 x64
  3. APK From? (Playstore, ROM, Other) - Nexus 5 AOSP Contacts.apk from 6.0.1 Marshmallow system/priv-app

Steps to Reproduce

apktool d Contacts.apk
apktool b contacts

APK

https://drive.google.com/open?id=1mZ93G83ylEMoIO23SqizCJ_xQiL7dBdK

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything?
    Yes

  2. If you are trying to install a modified apk, did you resign it?
    Yes

  3. Are you using the latest apktool version?
    Yes

@iBotPeaches
Copy link
Owner

iBotPeaches commented Mar 8, 2019

  1. Will there be any crashes in the app because I edited it? What part of the app will have errors or missing icons or text due to this?

No idea, too many variables to know.

  1. Will there be any implications for removing android:sharedUserId="android.uid.shared"?

SharedUserId helps Android know how to share application data among apps. So I imagine something would break with removing it.

  1. Why do I get this error for an unmodified apk? Is this a bug in apktool? Because it can't build back an unmodified AOSP apk

Might be a bug, not sure at this point. You could try building with aapt2 via --use-aapt2 during build on v2.4.0 to see if that resolves anything.

@timea-techgirl
Copy link
Author

timea-techgirl commented Mar 8, 2019

I got a similar error:

java -jar apktool.jar b --use-aapt2 contacts
I: Using Apktool 2.4.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
S: WARNING: Could not write to (C:\Users\Timea\AppData\Local\apktool\framework), using C:\Users\Timea\AppData\Local\Temp\ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
W: C:\Users\Timea\Desktop\contacts\AndroidManifest.xml:162: error: resource android:bool/config_enableActivityRecognitionHardwareOverlay is private.
W: C:\Users\Timea\Desktop\contacts\AndroidManifest.xml:169: error: resource android:bool/config_enableActivityRecognitionHardwareOverlay is private.
W: error: failed processing manifest.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Timea\AppData\Local\Temp\brut_util_Jar_3549403088357364900.tmp, link, -o, C:\Users\Timea\AppData\Local\Temp\APKTOOL5067405864196056344.tmp, --package-id, 127, --min-sdk-version, 23, --target-sdk-version, 23, --version-code, 23, --version-name, 6.0.1, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, -0, arsc, -0, res/drawable-ldrtl-sw600dp-xhdpi-v13/list_activated_holo.9.png, -0, png, -0, res/drawable-ldrtl-xhdpi-v4/list_background_holo.9.png, -0, res/drawable-ldrtl-xhdpi-v4/list_focused_holo.9.png, -0, res/drawable-ldrtl-xhdpi-v4/list_section_divider_holo_custom.9.png, -0, res/drawable-ldrtl-xhdpi-v4/list_title_holo.9.png, -0, res/drawable-ldrtl-xhdpi-v4/panel_content.9.png, -0, res/drawable-ldrtl-xhdpi-v4/quickcontact_badge_overlay_normal_light.9.png, -0, res/drawable-ldrtl-xhdpi-v4/quickcontact_badge_overlay_pressed_light.9.png, -0, res/drawable-ldrtl-xhdpi-v4/spinner_default_holo_dark.9.png, -0, res/drawable-sw600dp-xhdpi-v13/list_activated_holo.9.png, -0, res/drawable-xhdpi-v4/ab_stacked_solid_inverse_holo.9.png, -0, res/drawable-xhdpi-v4/aggregation_suggestions_bg.9.png, -0, res/drawable-xhdpi-v4/aggregation_suggestions_bg_light_holo.9.png, -0, res/drawable-xhdpi-v4/list_background_holo.9.png, -0, res/drawable-xhdpi-v4/list_section_divider_holo_custom.9.png, -0, res/drawable-xhdpi-v4/panel_content.9.png, -0, res/drawable-xhdpi-v4/quickcontact_badge_overlay_normal_light.9.png, -0, res/drawable-xhdpi-v4/spinner_default_holo_dark.9.png, -0, res/drawable-xxhdpi-v4/ab_solid_custom_blue_inverse_holo.9.png, -0, res/drawable-xxhdpi-v4/list_activated_holo.9.png, -0, res/drawable-xxhdpi-v4/list_focused_holo.9.png, -0, res/drawable-xxhdpi-v4/list_longpressed_holo_light.9.png, -0, res/drawable-xxhdpi-v4/list_pressed_holo_light.9.png, -0, res/drawable-xxhdpi-v4/list_title_holo.9.png, -0, res/drawable-xxhdpi-v4/quickcontact_badge_overlay_pressed_light.9.png, -0, arsc, -I, C:\Users\Timea\AppData\Local\Temp\1.apk, --manifest, C:\Users\Timea\Desktop\contacts\AndroidManifest.xml, C:\Users\Timea\Desktop\contacts\build\resources.zip]

@iBotPeaches
Copy link
Owner

Sorry I took a year+ off basically and this link is a 404 and we have 2.4.1 out and v2.5.0 due in a few weeks. Closing as old and new versions on horizon.

@bughunter2
Copy link

bughunter2 commented Dec 25, 2022

Seems this problem can still occur, even with apktool v2.7.0.

I guess if an app is compiled in such a way that it accesses private properties, this problem can occur, as I'm guessing apktool simply doesn't generate the @* syntax but generates just the @ syntax. When I had this problem with an app, I changed the syntax to @* just like the bug reporter and that worked.

For example, I changed this ...:
<color name="some_property">@android:color/foobar</color>
... into this ...:
<color name="some_property">@*android:color/foobar</color>

After that, building the app worked, and the app worked fine.

I think this issue can be reproduced with any app, just by accessing a private property. (Maybe some app developers do it on purpose to make rebuilding an app harder?)

Also, useful to know:
I can verify that, when I decoded the rebuilt app (the one with the modified @* syntax) once more, it resulted in the plain old @ syntax again, so the * was lost and I had to re-apply it to make it build again.

@AfifAlfahmi
Copy link

in my case i fixed it by changing the version of material dependency to 1.3.0

implementation 'com.google.android.material:material:1.3.0'

but if you do not have the source code use older version of Apktool, try 2.6.1

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 a pull request may close this issue.

4 participants