You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter升级后sqflite构建失败问题求助

Fixing sqflite Build Error After Flutter Upgrade

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.yaml and update the sqflite line to:
    sqflite: ^1.3.2
    
  • Run flutter pub get to 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 clean in your project root.
  • Delete the following folders from your project:
    • .gradle (root project folder)
    • android/.gradle
    • android/build
  • Re-run flutter pub get followed by flutter 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 buildscript block 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 16:17:33