无法使用flutter包“upgrader”检测更新

问题描述 投票:0回答:3

我是flutter新手,因为我希望用户在有更新时自动收到通知/强制他们更新,所以我使用了flutter包升级程序(https://github.com/larryaasen/upgrader) 。调试显示,即使我的 pubspec 版本低于我在 dart 和 XML 中设置的最低应用程序版本,也没有可用的更新。

飞镖:

final appcastURL = 'https://raw.githubusercontent.com/jeejaykim/apispa/jeejaykim-test/test.xml';
final cfg = AppcastConfiguration(url: appcastURL, supportedOS: ['android']);

return Scaffold(
        body: UpgradeAlert(
            dialogStyle: UpgradeDialogStyle.cupertino,
            appcastConfig: cfg,
            debugLogging: true,
            showLater: false,
            showIgnore: false,
            minAppVersion: '120.0.0',
            child: Container(width: 0, height: 0)),
      );

调试:

I/flutter ( 8444): upgrader: build UpgradeAlert
I/flutter ( 8444): FormatException: Cannot parse empty string into version
I/flutter ( 8444): upgrader: blocked: false
I/flutter ( 8444): upgrader: debugDisplayAlways: false
I/flutter ( 8444): upgrader: debugDisplayOnce: false
I/flutter ( 8444): upgrader: hasAlerted: false
I/flutter ( 8444): upgrader: appStoreVersion: null
I/flutter ( 8444): upgrader: installedVersion: null
I/flutter ( 8444): upgrader: minAppVersion: 120.0.0
I/flutter ( 8444): upgrader: isUpdateAvailable: false
I/flutter ( 8444): upgrader: shouldDisplayUpgrade: false
I/flutter ( 8444): upgrader: appcast item count: 4
I/flutter ( 8444): upgrader: appcast best item version: 200.0.0

pubspec:

version: 110.00.05+5
flutter
3个回答
2
投票

当我使用您的代码和 appcastURL 进行测试时,我可以看到更新弹出窗口。
我刚刚将“ios”添加到supportedOS参数中,因为我使用iPhone模拟器进行了测试。

这是我启动应用程序时的完整日志。

flutter: upgrader: package info packageName: com.example.stackoverflow
flutter: upgrader: package info appName: null
flutter: upgrader: package info version: 110.00.05
flutter: upgrader: appcast is available for this platform
flutter: upgrader: appcast item count: 4
flutter: upgrader: appcast best item version: 200.0.0
flutter: upgrader: blocked: true
flutter: upgrader: debugDisplayAlways: false
flutter: upgrader: debugDisplayOnce: false
flutter: upgrader: hasAlerted: false
flutter: upgrader: appStoreVersion: 200.0.0
flutter: upgrader: installedVersion: 110.00.05
flutter: upgrader: minAppVersion: 120.0.0
flutter: upgrader: isUpdateAvailable: true
flutter: upgrader: shouldDisplayUpgrade: true
flutter: upgrader: showDialog title: Update App?
flutter: upgrader: showDialog message: A new version of  is available! Version 200.0.0 is now available-you have 110.00.05.

“package_info”包似乎无法获取“versionName”。 https://github.com/larryaasen/upgrader/blob/6f5827cd4feb3d13685ea4b2baa0911589876ab8/lib/src/upgrader.dart#L152

FormatException: Cannot parse empty string into version

您会检查“android/app/build.gradle”文件中的 flutterVersionName 吗? 我的代码如下。


def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

如果与我的代码相同,请执行以下步骤。

flutter clean
flutter pub get
flutter run

并且在“/android”中生成了一个“local.properties”文件。
请检查该文件中的“flutter.versionName”值。


0
投票

appCastUrl('https://raw.githubusercontent.com/jeejaykim/apispa/jeejaykim-test/test.xml')指向404页面(未找到)。

试试这个:https://raw.githubusercontent.com/larryaasen/upgrader/master/test/testappcast.xml

或者,您可以使用包文档页面(在 pub.dev 上)上的 Appcast 示例文件创建您自己的原始 github 用户内容。使用格式:

raw.githubusercontent.com/用户名/仓库名称/分支名称/路径


0
投票

所以我当前的版本是 1.0.7+15 用于调试,我将其更改为 1.0.6+15 它会检测到,但当我将其更改为 1.0.7+16 时则不会,所以如果您更改版本名称它检测到,但当您更改版本代码时,它不会检测到。

版本名称为1.0.7 版本号是15

© www.soinside.com 2019 - 2024. All rights reserved.