Flutter 编译错误 - 任务 ':flutter_paystack:compileDebugKotlin' 执行失败

时间:2021-01-01 09:14:43

标签: android flutter

e: C:\SRC_Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_paystack-1.0.2+1\android\src\main\kotlin\co\paystack\flutterpaystack\FlutterPaystackPlugin.kt: (33, 88): Unresolved reference: VERSION_NAME
e: C:\SRC_Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_paystack-1.0.2+1\android\src\main\kotlin\co\paystack\flutterpaystack\FlutterPaystackPlugin.kt: (37, 36): Unresolved reference: VERSION_CODE

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_paystack:compileDebugKotlin'.
> Compilation error. See log for more 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 1m 23s
Exception: Gradle task assembleDebug failed with exit code 1

2 个答案:

答案 0 :(得分:0)

您可以尝试升级您的 flutter_paystack package。现在它有一个新版本(v1.0.4+1)。

答案 1 :(得分:0)

这为我解决了问题

在你的 MethodCallHandlerImpl.kt 文件中,替换这个:

        "getUserAgent" -> {
            result.success("Android_" + Build.VERSION.SDK_INT + "_Paystack_" + 
            BuildConfig.VERSION_NAME)
        }

        "getVersionCode" -> {
            result.success(BuildConfig.VERSION_CODE.toString())
        }

这样:

       "getUserAgent" -> {
        //result.success("Android_" + Build.VERSION.SDK_INT + "_Paystack_" + 
         BuildConfig.VERSION_NAME)
        result.success("Android_" + "29" + "_Paystack_" + "1.0.0" )
       }
       "getVersionCode" -> {
        //result.success(BuildConfig.VERSION_CODE.toString())
        result.success("1")
       }

稍后谢谢我。快乐编码!