'Connection has been shutdown: javax.net.ssl.SSLException: Tag mismatch

Has anyone encountered this error before? I'm new in flutter, is there anything wrong while running the sample file of flutter that I'm missing? The stack trace gives me 3 error like : Exception in thread "main" javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: Tag mismatch! and Caused by: javax.net.ssl.SSLException: Tag mismatch! and Caused by: javax.crypto.AEADBadTagException: Tag mismatch!

Here is my stacktrace

    Exception in thread "main" javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: Tag mismatch!
        at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1533)
        at sun.security.ssl.AppInputStream.available(AppInputStream.java:60)
        at java.io.BufferedInputStream.available(BufferedInputStream.java:410)
        at sun.net.www.MeteredStream.available(MeteredStream.java:170)
        at sun.net.www.http.KeepAliveStream.close(KeepAliveStream.java:85)
        at java.io.FilterInputStream.close(FilterInputStream.java:181)  
        at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(HttpURLConnection.java:3527)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:77)
        at org.gradle.wrapper.Download.download(Download.java:44)
        at org.gradle.wrapper.Install$1.call(Install.java:61)
        at org.gradle.wrapper.Install$1.call(Install.java:48)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: javax.net.ssl.SSLException: Tag mismatch!
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1022)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:933)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
        at sun.net.www.MeteredStream.read(MeteredStream.java:134)       
        at java.io.FilterInputStream.read(FilterInputStream.java:133)
        at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3454)
        at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3447)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:62)
        ... 7 more
Caused by: javax.crypto.AEADBadTagException: Tag mismatch!
        at com.sun.crypto.provider.GaloisCounterMode.decryptFinal(GaloisCounterMode.java:592)
        at com.sun.crypto.provider.CipherCore.finalNoPadding(CipherCore.java:1116)
        at com.sun.crypto.provider.CipherCore.fillOutputBuffer(CipherCore.java:1053)
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:941)
        at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:491)
        at javax.crypto.Cipher.doFinal(Cipher.java:2376)
        at sun.security.ssl.CipherBox.decrypt(CipherBox.java:461)
        at sun.security.ssl.InputRecord.decrypt(InputRecord.java:172)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1017)
        ... 16 more
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         3.0s
Exception: Gradle task assembleDebug failed with exit code 1

the following file is "main.dart"

    import 'package:flutter/material.dart';

void main() {   runApp(MyApp()); }

class MyApp extends StatelessWidget {   @override   Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );   } }

class MyHomePage extends StatefulWidget {   MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override   _MyHomePageState createState() => _MyHomePageState(); }

class _MyHomePageState extends State<MyHomePage> {   int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });   }

  @override   Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );   } }

Flutter Doctor Summary

PS F:\Flutter\chat_app> flutter doctor -v
[√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.19042.804], locale en-US)
    • Flutter version 1.22.6 at C:\src\flutter
    • Framework revision 9b2d32b605 (4 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

 
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\ShreeDivyangnaRajaji\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[!] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.53.2)
    • VS Code at C:\Users\ShreeDivyangnaRajaji\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.19.0

[√] Connected device (1 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)

! Doctor found issues in 1 category.

When I run any project, the same stack of error I face. Any help will be appreciated. Thank you :)



Solution 1:[1]

Try updating android studio and the corresponding flutter and dart sdks. Then go into sdk manager and update the build tools. restart your IDE and emulator and flutter should work now.

Solution 2:[2]

this is gradle version error so change the gradle distrubution url to distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2