Sourav Roy
Sourav Roy

Reputation: 73

Flutter: Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches()

I am new to Flutter and in learning phase. I have created a Flutter App as per demo which creates a dart program. When I run the initial program, it runs fine and the demo app come up but when I change and progress with creating some new, it fails with the error in subject. I have placed the code for main.dart and gradle properties and dependency below.

 import 'package:flutter/material.dart';

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

 class MyApp extends StatelessWidget {
     @override
     Widget build(BuildContext context) {
        return MaterialApp(
        theme: ThemeData(primaryColor: Colors.purpleAccent),
        home: Scaffold(
            appBar: AppBar(title: Text("Word  Generator")),
    
        ),
     );
    }

  }

 dependencies:
 flutter:
   sdk: flutter


 # The following adds the Cupertino Icons font to your application.
 # Use with the CupertinoIcons class for iOS style icons.
 cupertino_icons: ^0.1.3

 org.gradle.jvmargs=-Xmx1536M
 android.enableR8=true
 #android.useAndroidX=true
 #android.enableJetifier=true

 Log for the error:
 C:\Git\flutter\wordpairgenerator>flutter run --enable-software-rendering
 Using software rendering with device SM G615FU. You may get better performance with hardware mode by 
 configuring hardware rendering for your device.
 Launching lib\main.dart on SM G615FU in debug mode...

 FAILURE: Build failed with an exception.

 * What went wrong:
 Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not create service of type DefaultGeneralCompileCaches using 
GradleScopeCompileServices.createGeneralCompileCaches().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more 
log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 49s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        57.5s
Exception: Gradle task assembleDebug failed with exit code 1

Log for the app ran correctly:
C:\Git\flutter\myapp>flutter run --enable-software-rendering
Using software rendering with device SM G615FU. You may get better performance with hardware mode by 
configuring hardware rendering for your device.
Launching lib\main.dart on SM G615FU in debug mode...
F/AdjustPurchase(12613): PRODUCTION: AdjustPurchase is running in production mode. Use this setting 
only for the build that you want to publish. Set the environment to `sandbox` if you want to test 
your app!
Running Gradle task 'assembleDebug'...

Running Gradle task 'assembleDebug'... Done                       123.6s (!)
√ Built build\app\outputs\apk\debug\app-debug.apk.
D/Surface (13245): Surface::connect(this=0xd0815400,api=2)
D/GraphicBuffer(13245): register, handle(0xe7f34100) (w:1080 h:1920 s:1088 f:0x4 u:0x000933)
Syncing files to device SM G615FU...
3,033ms (!)

Upvotes: 4

Views: 5138

Answers (1)

Arvind suresh
Arvind suresh

Reputation: 198

i have faced this issue recently and recovered from this issue by updating the gradle file by changing the distributionUrl in android/gradle/wrapper/gradle-wrapper.properties file from

https://services.gradle.org/distributions/gradle-5.6.2-all.zip to https://services.gradle.org/distributions/gradle-6.1.1-all.zip

i waited for sometime to download the gradle file after that it worked fine for me hope it will help for you too.

Upvotes: 2

Related Questions