Zionnite
Zionnite

Reputation: 463

Flutter says Execution failed for task ':sqflite:compileDebugJavaWithJavac'

I used to have this sqflite in my pubspec.yaml file but recently I removed the dependence seeing I won't be making use of it, then I run the app on my android device and emulator I got a strange error and have googled for the solution, it seems I can't find any help and as well check stackoverflow.

What have done so far:

  1. As a rule of thumb, i ran flutter clean to see if issue will be resolved but it did not worked either
  2. Invalidate and Restart Android Studio

Here is the Error am having

Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
/Users/zionnite/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/android/src/main/java/com/tekartik/sqflite/SqflitePlugin.java:910: error: cannot find symbol
                        database.deleteDatabase(path);
                        ^
  symbol: variable database
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sqflite:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 58s
Exception: Gradle task assembleDebug failed with exit code 1

Dependency of Interest

#  sqflite: ^2.0.0+3
#  path_provider: ^2.0.1

At this time even if I enable the dependency, the issue still persists.

However, everything is working out great on my ios simulator except android device and emulator

Upvotes: 2

Views: 7015

Answers (4)

benten
benten

Reputation: 790

I was encountering the same issue.I have done everything which is mentioned on stackoverflow .but the problem is in my new added package which is cached_network_image .I just remove this package and every thing start working.So you just check which new package you added and which create fuss..

Upvotes: 1

Prakritii
Prakritii

Reputation: 21

Issue resolved after downloading Java 11,also check the gradle and wrapper version you're using

Upvotes: 1

nahoang
nahoang

Reputation: 2478

The issue caused by Java version 8. So you should use Java version 11.

  • Add this to build.gradle file (android/app/build.gradle)

     compileOptions {
          sourceCompatibility JavaVersion.VERSION_11
          targetCompatibility JavaVersion.VERSION_11
      }
    
  • Change JDK of Gradle in Android studio enter image description here

Finally, Clean and rebuild. That's it.

Upvotes: 1

Zionnite
Zionnite

Reputation: 463

I was able combat the enemy of death fighting for the progress of my code and obtain victory through the magical touch of flutter pub cache repair.

what i mean to say is that, when i ran flutter pub cache repair, Flutter was able to build and run on my android device and emulator

Upvotes: 0

Related Questions