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

KeytoolException: Failed to read key AndroidDebugKey from store: Invalid keystore format #1112

Closed
mhsmith opened this issue Feb 26, 2023 · 10 comments · Fixed by #1271
Closed
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.

Comments

@mhsmith
Copy link
Member

mhsmith commented Feb 26, 2023

Reported by warchants on Discord, with the following log:

           > Task :app:packageDebug FAILED                                                                                                                         subprocess.py:638
                                                                                                                                                                   subprocess.py:638
           FAILURE: Build failed with an exception.                                                                                                                subprocess.py:638
                                                                                                                                                                   subprocess.py:638
           * What went wrong:                                                                                                                                      subprocess.py:638
           Execution failed for task ':app:packageDebug'.                                                                                                          subprocess.py:638
           > A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable                                  subprocess.py:638
              > com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "C:\Users\Shahab\.android\debug.keystore": Invalid  subprocess.py:638
           keystore format                                                                                                                                                          

The first time a debug build is done on any given machine, the Android Gradle plugin creates the debug.keystore file with a randomly-generated key, and then uses it for all subsequent debug builds of all apps on that machine. Unfortunately it looks like there's been a backward-incompatible change to the file's format, so files created by new Java versions (e.g. the version that comes with new versions of Android Studio) cannot be read by the Java version that Briefcase currently uses.

Based on this discussion, we could fix this by moving to Java 8u301 or newer. I've confirmed that it works OK with Corretto version 1.8.0_352.

Such a new version is not available at https://github.com/AdoptOpenJDK/openjdk8-binaries, which Briefcase currently uses. But its successor, https://adoptium.net/, currently offers version 8u362. See #1065.

@mhsmith mhsmith added bug A crash or error in behavior. android The issue relates to Android mobile support. labels Feb 26, 2023
@mhsmith
Copy link
Member Author

mhsmith commented Feb 26, 2023

This is probably not a new problem, because Android Studio has come with Java 11 since 2021. We just haven't seen it before because most of our users are Android novices whose first Android build was through Briefcase, not Android Studio.

@bobwatcherx
Copy link

This is probably not a new problem, because Android Studio has come with Java 11 since 2021. We just haven't seen it before because most of our users are Android novices whose first Android build was through Briefcase, not Android Studio.

i using command briefcase package android
but get error like this

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:packageDebug'.

A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "/root/.android/debug.keystore": Invalid keystore format

how solution

@bobwatcherx
Copy link

This is probably not a new problem, because Android Studio has come with Java 11 since 2021. We just haven't seen it before because most of our users are Android novices whose first Android build was through Briefcase, not Android Studio.

and how to use own sdk root i get message like this


** WARNING: ANDROID_SDK_ROOT does not point to an Android SDK **


The location pointed to by the ANDROID_SDK_ROOT environment
variable:

/root/Android/Sdk

doesn't appear to contain an Android SDK.

Briefcase will use its own SDK instance.

how to use own sdk root

my .bashrc file is

for examples

#export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/

#export ANDROID_HOME=/root/Android/Sdk
export ANDROID_SDK_ROOT=/root/Android/Sdk
#export PATH=$PATH:$ANDROID_HOME/tools
#export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator/

#export PATH=$PATH:/opt/gradle/gradle-8.1.1/bin
export PATH=$PATH:/opt/gradle/gradle-7.6/bin

@mhsmith
Copy link
Member Author

mhsmith commented May 9, 2023

You can work around the "Invalid keystore format" error by deleting the debug.keystore file and then running briefcase again.

The "doesn't appear to contain an Android SDK" error means that either the ANDROID_SDK_ROOT directory doesn't exist, or it doesn't contain an executable cmdline-tools/latest/bin/sdkmanager.

@bobwatcherx
Copy link

bobwatcherx commented May 10, 2023 via email

@bobwatcherx
Copy link

I success build debug apk . but when i run it on my android . suddenly my android application exits itself

root@mopt-HP-Convertible-x360-11-ab1XX:/home/mopt/belajar/fletpp/fpyo2apkdist# briefcase build android

*************************************************************************
** WARNING: ANDROID_SDK_ROOT does not point to an Android SDK          **
*************************************************************************

    The location pointed to by the ANDROID_SDK_ROOT environment
    variable:

    /root/Android/Sdk

    doesn't appear to contain an Android SDK.

    Briefcase will use its own SDK instance.

*************************************************************************

[fpyo2apk] Updating app metadata...
Setting main module... done

[fpyo2apk] Building Android APK...

> Configure project :app
Warning: Python version 3.10 may have fewer packages available. If you experience problems, try switching to version 3.8.

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:extractPythonBuildPackages UP-TO-DATE
> Task :app:generateDebugPythonRequirements UP-TO-DATE
> Task :app:mergeDebugPythonSources UP-TO-DATE
> Task :app:generateDebugPythonProxies UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:checkDebugAarMetadata UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugMainManifest UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugManifestForPackage UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:compileDebugSources UP-TO-DATE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:generateDebugPythonAppAssets UP-TO-DATE
> Task :app:generateDebugPythonMiscAssets UP-TO-DATE
> Task :app:generateDebugPythonRequirementsAssets UP-TO-DATE
> Task :app:generateDebugPythonBuildAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:compressDebugAssets UP-TO-DATE
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:mergeDebugJavaResource UP-TO-DATE
> Task :app:checkDebugDuplicateClasses UP-TO-DATE
> Task :app:desugarDebugFileDependencies UP-TO-DATE
> Task :app:mergeExtDexDebug UP-TO-DATE
> Task :app:mergeLibDexDebug UP-TO-DATE
> Task :app:dexBuilderDebug UP-TO-DATE
> Task :app:mergeProjectDexDebug UP-TO-DATE
> Task :app:generateDebugPythonJniLibs UP-TO-DATE
> Task :app:mergeDebugJniLibFolders UP-TO-DATE
> Task :app:mergeDebugNativeLibs UP-TO-DATE
> Task :app:stripDebugDebugSymbols UP-TO-DATE
> Task :app:validateSigningDebug UP-TO-DATE
> Task :app:writeDebugAppMetadata UP-TO-DATE
> Task :app:writeDebugSigningConfigVersions UP-TO-DATE
> Task :app:packageDebug UP-TO-DATE
> Task :app:assembleDebug UP-TO-DATE

BUILD SUCCESSFUL in 8s
38 actionable tasks: 38 up-to-date
Building... done

[fpyo2apk] Built build/fpyo2apk/android/gradle/app/build/outputs/apk/debug/app-debug.apk

@bobwatcherx
Copy link

@mhsmith
Copy link
Member Author

mhsmith commented May 10, 2023

is it possible to build an Android briefcase with our own keystore like the myown.keystore file

Briefcase doesn't currently have an option for this (#865 (comment)). You can do it by using Android Studio to open the build/.../android/gradle directory, and then running the command Build > Generate Signed Bundle / APK.

@mhsmith
Copy link
Member Author

mhsmith commented May 10, 2023

I success build debug apk . but when i run it on my android . suddenly my android application exits itself

Instead of installing the APK manually, try using briefcase run android, then you should see the error messages.

@freakboy3742
Copy link
Member

FYI - I've opened #1268 so the feature request of signing Android apps isn't forgotten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants