SQLite Forum

sqlite-android-3460100.aar version number and select sqlite_version(); The results are inconsistent
Login

sqlite-android-3460100.aar version number and select sqlite_version(); The results are inconsistent

(1.1) By leeyi (leeyisoft) on 2024-08-16 07:22:01 edited from 1.0 [source]

sqlite-android-3460100.aar version number and select sqlite_version(); The results are inconsistent

https://sqlite.org/2024/sqlite-android-3460100.aar

(SHA3-256: c3bec0e3a17349d3a7a6b9b7d9f23e4b14ae38a175469c28377cd1e7aa41f62c )

openssl dgst -sha3-256 /Users/leeyi/project/imboy.pub/imboyflutter/android/app/lib/sqlite-android-3460100.aar
  SHA3-256(/Users/leeyi/project/imboy.pub/imboyflutter/android/app/lib/sqlite-android-3460100.aar)= c3bec0e3a17349d3a7a6b9b7d9f23e4b14ae38a175469c28377cd1e7aa41f62c

in ./android/app/build.gradle

    dependencies {
        implementation files('lib/sqlite-android-3460100.aar')
    }

dart code ``` Future<Database?> get db async { _db ??= await _initDatabase();

// https://developer.android.com/reference/android/database/sqlite/package-summary
// 查询 SQLite 版本
final versionResult =
    await _db?.database.rawQuery('select sqlite_version();');
if (versionResult!.isNotEmpty) {
  iPrint('SQLite version: $versionResult');
  // andriod [ +225 ms] I/flutter (19060): iPrint SQLite version: [{sqlite_version(): 3.46.0}]
}
return _db;

}

Future<Database?> _initDatabase() async { // Init ffi loader if needed. sqfliteFfiInit();

String path = await dbPath();

// Check if the database exists
var exists = await databaseExists(path);
if (!exists) {
  // Should happen only the first time you launch your application
  iPrint("Creating new copy from asset");
  // Make sure the parent directory exists
  try {
    await Directory(dirname(path)).create(recursive: true);
  } catch (_) {}

  // Copy from asset
  ByteData data = await rootBundle.load(url.join("assets", "example.db"));
  List<int> bytes = data.buffer.asUint8List(
    data.offsetInBytes,
    data.lengthInBytes,
  );
  // Write and flush the bytes written
  await File(path).writeAsBytes(bytes, flush: true);
} else {
  iPrint("Opening existing database");
}

// debugPrint("> on open db path {$path}");
return await databaseFactoryFfi.openDatabase(
  path,
  options: OpenDatabaseOptions(
    version: _dbVersion,
    onConfigure: _onConfigure,
    onCreate: _onCreate,
    onUpgrade: _onUpgrade,
    onDowngrade: _onDowngrade,
    readOnly: false,
    singleInstance: true,
  ), // 重新打开相同的文件是安全的,它会给你相同的数据库。
);

} ```

(2) By Stephan Beal (stephan) on 2024-08-15 11:34:47 in reply to 1.0 [link] [source]

  // ios [  +55 ms] flutter: iPrint SQLite version: [{sqlite_version(): 3.46.1}]
  // andriod [ +225 ms] I/flutter (19060): iPrint SQLite version: [{sqlite_version(): 3.46.0}]

You seem to be reporting that Android and iOS are reporting different version numbers for that aar file. After dissecting that file, we can see that the only 3.46 version number in that distribution is 3.46.1:

$ strings $(find . -type f) | grep 3.46
3.46.1
3.46.1
3.46.1
3.46.1

$ for i in $(find . -type f); do strings $i | grep 3.46 && echo $i; done
3.46.1
./jni/x86_64/libsqliteX.so
3.46.1
./jni/armeabi-v7a/libsqliteX.so
3.46.1
./jni/x86/libsqliteX.so
3.46.1
./jni/arm64-v8a/libsqliteX.so

which strongly suggests that your Android build is using the 3.46 version, not 3.46.1, of the included JNI pieces.

(3) By leeyi (leeyisoft) on 2024-08-16 07:27:33 in reply to 2 [link] [source]

Don't feel the same way about ios line comments, this issue has nothing to do with ISO;

I download the files at https://sqlite.org/2024/sqlite-android-3460100.aar

If I did everything correctly, the version of sqlite printed on Android should be "[{sqlite_version(): 3.46.1}]" instead of [{sqlite_version(): 3.46.0}] as I observed.

You said "which strongly suggests that your Android build is using the 3.46 version, not 3.46.1, of the included JNI pieces. "I seem to have a point, but I don't understand it (limited by the results of my knowledge, I'm a layman on Android development).

(4) By leeyi (leeyisoft) on 2024-08-19 01:24:58 in reply to 2 [link] [source]

I found something, The version of sqlite3 in my flutter project (IMBoy) should be android/build.gradle configured in sqlite3_flutter_libs
'eu.simonbinder:sqlite3-native-library:3.46.0+1'

/Users/leeyi/.pub-cache/hosted/pub.flutter-io.cn/sqlite3_flutter_libs-0.5.24/android/build.gradle ``` dependencies { implementation 'eu.simonbinder:sqlite3-native-library:3.46.0+1' }

```