Flutter升级后sqflite构建失败问题求助
Hey there, let's resolve this :sqflite:createFullJarDebug failure you're encountering post-Flutter upgrade. I've reviewed your error logs and project configs, and here are targeted fixes to get your app building again:
Step 1: Update sqflite to a Compatible Version
Your current sqflite version (^1.3.1+1) might not be fully compatible with Flutter 1.22.2. Let's upgrade to a more recent 1.x release that supports your Dart/Flutter version:
- Open your
pubspec.yamland update the sqflite line to:sqflite: ^1.3.2 - Run
flutter pub getto fetch the updated dependency.
Step 2: Perform a Deep Clean of Build Caches
A standard flutter clean might not clear all Android-specific cached files causing the missing res.jar issue. Do a full cleanup:
- Run
flutter cleanin your project root. - Delete the following folders from your project:
.gradle(root project folder)android/.gradleandroid/build
- Re-run
flutter pub getfollowed byflutter run.
Step 3: Ensure Gradle & Kotlin Compatibility
Your Android build config is missing a defined Kotlin version and up-to-date Gradle plugin, which can cause compatibility issues with newer Flutter versions. Update your android/build.gradle file:
- Add the
buildscriptblock at the very top of the file to specify Kotlin and Gradle versions:buildscript { ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.6.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() jcenter() } } - Keep the rest of your existing build.gradle content intact below this block.
Step 4: Verify Path Dependency Integration
Since you replaced path_provider with path, double-check that all file path logic in your app uses the path package correctly. For example, when defining your database path, use code like:
import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; Future<Database> openMyDatabase() async { final dbPath = await getDatabasesPath(); final path = join(dbPath, 'your_app_database.db'); // ... rest of your database initialization logic }
Ensure there are no leftover imports or references to path_provider in your codebase.
Error Context for Reference
Your build error was:
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':sqflite:createFullJarDebug'.java.nio.file.NoSuchFileException: C:\Users\fayem\AndroidStudioProjects\myapp\build\sqflite\intermediates\library_java_res\debug\res.jar
- 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 10s
Exception: Gradle task assembleDebug failed with exit code 1
内容的提问来源于stack exchange,提问作者Fatemeh Hasheminasab

