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

local Keystore is not present or missing? #34

Open
cah-iswaria-sasi opened this issue Nov 5, 2024 · 5 comments
Open

local Keystore is not present or missing? #34

cah-iswaria-sasi opened this issue Nov 5, 2024 · 5 comments

Comments

@cah-iswaria-sasi
Copy link

cah-iswaria-sasi commented Nov 5, 2024

We are using alvrme/alpine-android:android-34-jdk17 image for our android project.

Challenge: while extracting apk from aab build, we see warning saying debug.keystore isn't present under ~.android/ folder.

why is not present or where shall we find that local debug.keystore signing thing. Please respond what are we missing here and what are the steps to be taken care of.

image

@alvr

@cah-iswaria-sasi
Copy link
Author

someone please help?

@alvr
Copy link
Owner

alvr commented Nov 25, 2024

The file is created automatically when you compile the project in debug. If you are not compiling it, you need to create it before. You can create a new one executing this command inside the container.

keytool -genkeypair -v -keystore ~/.android/debug.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias androiddebugkey -storepass android -keypass android

Otherwise, if you prefer a Gradle task:

tasks.register("generateDebugKeystore") {
    group = "build setup"
    description = "Generates a debug.keystore file in the ~/.android/ directory."

    doLast {
        val homeDir = System.getProperty("user.home")
        val keystorePath = "$homeDir/.android/debug.keystore"
        val keystoreFile = File(keystorePath)

        if (keystoreFile.exists()) {
            println("debug.keystore already exists at: $keystorePath")
        } else {
            println("Generating debug.keystore at: $keystorePath")
            val command = listOf(
                "keytool",
                "-genkeypair",
                "-v",
                "-keystore", keystorePath, 
                "-keyalg", "RSA",
                "-keysize", "2048",
                "-validity", "10000",
                "-alias", "androiddebugkey",
                "-storepass", "android",
                "-keypass", "android"
            )

            val process = ProcessBuilder(command)
                .redirectOutput(ProcessBuilder.Redirect.INHERIT)
                .redirectError(ProcessBuilder.Redirect.INHERIT)
                .start()

            val exitCode = process.waitFor()
            if (exitCode == 0) {
                println("debug.keystore generated successfully!")
            } else {
                println("Failed to generate debug.keystore. Exit code: $exitCode")
            }
        }
    }
}

Execute this task before building the APK with Bundletool.

@cah-iswaria-sasi
Copy link
Author

@alvr Thank you so much, will try this way and get back to you for an update.

@cah-iswaria-sasi
Copy link
Author

cah-iswaria-sasi commented Nov 25, 2024

@alvr Hi, Below are my observations.
-> for apk generation, i tried to build with gradle task - assembleDebug and list to find whether debug.keystore been creating or not.
luckily, it is creating debug.keystore by default under ~.android/debug.keystore.
image

->for aab generation, tried with gradle task - bundleProdDebug or bundleDebug but its not creating debug.keystore nor present. why?
image

@alvr
Copy link
Owner

alvr commented Nov 26, 2024

By default, AABs are not signed during creation if the signingConfig is not specified for that buildType. That is because the signing is done when creating the APK from that AAB.

https://developer.android.com/build/building-cmdline?hl=en#bundle_build_gradle
https://developer.android.com/tools/bundletool?hl=en#generate-apks-from-sdk-bundle

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

No branches or pull requests

2 participants