0

I want to release the Android App on VSCode but it got this problem, this is the first time i deploy the app to apk

When i use this command on "flutter deployment web"

 keytool -genkey -v -keystore C:\Users\Admin\Videos\Halloween_Official - 2\official_halloween\android\app\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload

I got this error :

keytool : The term 'keytool' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:3
+   keytool -genkey -v -keystore C:\Users\Admin\Videos\Halloween_Offici ...
+   ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (keytool:String) [], CommandNotFoundExceptio
   n
    + FullyQualifiedErrorId : CommandNotFoundException

The output of Flutter doctor when i run:

[!] Flutter (Channel master, 3.6.0-1.0.pre.38, on Microsoft Windows [Version
    10.0.22000.1219], locale en-US)
    • Flutter version 3.6.0-1.0.pre.38 on channel master at C:\src\flutter
    ! Warning: `dart` on your path resolves to C:\dart-sdk\bin\dart.exe,    
      which is not inside your current Flutter SDK checkout at
      C:\src\flutter. Consider adding C:\src\flutter\bin to the front of    
      your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 338841afd3 (6 days ago), 2022-11-11 10:01:11 -0800 
    • Engine revision 7326e5b335
    • Dart version 2.19.0 (build 2.19.0-389.0.dev)
    • DevTools version 2.19.0
    • If those were intentional, you can disregard the above warnings;
      however it is recommended to use "git" directly to perform update     
      checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version    
    31.0.0)
    • Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
    • Platform android-Sv2, build-tools 31.0.0
    • Java binary at: C:\Program Files\Java\jdk-15.0.1\bin\java
    X Cannot execute C:\Program Files\Java\jdk-15.0.1\bin\java to determine
      the version

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe       

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows
      development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including 
      all of its default components

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit
      https://flutter.dev/docs/get-started/install/windows#android-setup for
      detailed instructions).

[√] IntelliJ IDEA Community Edition (version 2021.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition
      2021.3
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] VS Code (version 1.73.1)
    • VS Code at C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code    
    • Flutter extension version 3.52.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows
      [Version 10.0.22000.1219]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome
      107.0.5304.107
    • Edge (web)        • edge    • web-javascript • Microsoft Edge
      107.0.1418.42

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 4 categories.

I did all of the above commands on VS Code by using Powershell Terminal. How can i fix this problem

destructor
  • 41
  • 5
  • Please provide your code and commands as text and not as an image. – jraufeisen Nov 17 '22 at 09:24
  • 1
    i edited my problem, can you check it – destructor Nov 17 '22 at 09:27
  • Have you installed Android Studio? What does "flutter doctor" return as an output? Seems to be related to a missing or not-found installation of the JDK: https://stackoverflow.com/questions/19431788/keytool-is-not-recognized-as-an-internal-or-external-command – jraufeisen Nov 17 '22 at 09:34
  • i installed it before but i deleted it, and the "flutter doctor" output i posted it above , could u check it – destructor Nov 17 '22 at 09:38
  • 1
    Oh yeah, you need to install Visual Studio Code and Android Studio. Just follow the links provided by fluter doctor – jraufeisen Nov 17 '22 at 10:04

2 Answers2

1

To write up an answer following up on our discussion:

As flutter doctor revelas some problems, you will need to

  • Install Visual Studio Code
  • Install Android Studio. This will provide the JDK and the keytool command with it
jraufeisen
  • 3,005
  • 7
  • 27
  • 43
0

I could solve The term 'keytool' is not recognized this way:

Run flutter doctor -v in terminal and copy the java binary location. for me it was : C:\Program Files\Android\Android Studio\jbr\bin

Then add this location to path variable of system environment variable.

After adding the java path, open command prompt and type the keytool -genkey, you will see that keytool is recognized now.

Notice that you can access keytool command from cmd now, and if you want to use keytool command from android studio terminal, you should type the full path to java according to flutter docs

Zahra
  • 2,231
  • 3
  • 21
  • 41