Skip to content

Force the replacement of an existing application#75

Closed
mark2185 wants to merge 1 commit into
silbinarywolf:mainfrom
mark2185:main
Closed

Force the replacement of an existing application#75
mark2185 wants to merge 1 commit into
silbinarywolf:mainfrom
mark2185:main

Conversation

@mark2185
Copy link
Copy Markdown

This just circumvents the need for manually uninstalling the application. I'd leave the instructions in the examples' README.md since it's useful to see how to uninstall the application, but it's likely not a needed step anymore.

From adb's manual:

APP INSTALLATION
     -r:     Replace existing application.

The flag is there since at least 2012 so a compatibility check isn't needed since there aren't any for e.g. dx which is not available since NDK 30 (or somewhere around that time).

@mark2185
Copy link
Copy Markdown
Author

Actually, scratch that, this flags helps with the INSTALL_FAILED_ALREADY_EXISTS error, but not with INSTALL_FAILED_UPDATE_INCOMPATIBLE.

I'll try to see what else I can dig up.

@silbinarywolf
Copy link
Copy Markdown
Owner

The way I would resolve the INSTALL_FAILED_UPDATE_INCOMPATIBLE issue for the most part, would be to store the example default key in zig-out or something so that deleting .zig-cache doesn't delete the previously used/generated Android key.

Perhaps making it so tools.zig.createKeyStore looks specifically in the zig-out folder for the default example key if the password and distinguished_name fields match. If the example key doesn't exist, then generate it then.

ie. Somewhere around here:

/// Generates an example key that you can use for debugging your application locally
pub const example: CreateKey = .{
.alias = "default",
.password = "example_password",
.algorithm = .rsa,
.key_size_in_bits = 4096,
.validity_in_days = 10_000,
.distinguished_name = "CN=example.com, OU=ID, O=Example, L=Doe, S=Jane, C=GB",
};
};
pub fn createKeyStore(sdk: *const Sdk, options: CreateKey) KeyStore {

@silbinarywolf
Copy link
Copy Markdown
Owner

I'm going to close this for now, please re-open if/when you push further changes :)

@silbinarywolf
Copy link
Copy Markdown
Owner

@mark2185 I've scoped out a seperate issue to resolve most of the developer UX issues with app uninstalling here and it does it in a kind of standard Android development way: #79

@mark2185
Copy link
Copy Markdown
Author

mark2185 commented Apr 8, 2026

Sweet, even better then!

I'd like to take a crack at it in a couple of days if you don't mind. I kinda got sidetracked when I opened this PR so I didn't get back to it yet.

@silbinarywolf
Copy link
Copy Markdown
Owner

@mark2185 Sure thing!

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