离子:未指定compileSdkVersion-找不到方法leftShift()

时间:2019-03-04 15:53:39

标签: android cordova ionic-framework gradle

我刚刚使用Ionic 4启动了我的应用程序。目前,我从未在启动项目时对原始代码进行任何修改(使用侧面菜单)。 在经历许多其他错误之后,我遇到了一个我不知道如何解决它的错误。 当我尝试执行以下操作时会发生这种情况:

  

ionic cordova构建android

    FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'D:\workspace\iganalytics\app\platforms\android\app\build.gradle' line: 148

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method leftShift() for arguments [build_8ka4my3njl1nfn72j8pdlyfze$_run_closure6@5b9f348] on task ':app:cdvPrintProps' of type org.gradle.api.DefaultTask.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified.

* 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 1s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'D:\workspace\iganalytics\app\platforms\android\app\build.gradle' line: 148

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method leftShift() for arguments [build_8ka4my3njl1nfn72j8pdlyfze$_run_closure6@5b9f348] on task ':app:cdvPrintProps' of type org.gradle.api.DefaultTask.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified.

* 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 1s
[ERROR] An error occurred while running subprocess cordova.

        cordova build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

我将此行添加到config.xml:

<preference name="android-targetSdkVersion" value="28" />

没有运气。

build.gradle 148行开头:

task cdvPrintProps << {
    println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
    println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
    println('cdvVersionCode=' + cdvVersionCode)
    println('cdvVersionCodeForceAbiDigit=' + cdvVersionCodeForceAbiDigit)
    println('cdvMinSdkVersion=' + cdvMinSdkVersion)
    println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
    println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
    println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
    println('cdvBuildArch=' + cdvBuildArch)
    println('computedVersionCode=' + android.defaultConfig.versionCode)
    android.productFlavors.each { flavor ->
        println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
    }
}

3 个答案:

答案 0 :(得分:2)

通过添加平台android @ 8而不是仅安装版本7的android来使其正常运行

答案 1 :(得分:2)

昨天我遇到了类似的问题,并通过在config.xml中添加<preference name="android-targetSdkVersion" value="22" />来解决

答案 2 :(得分:1)

我遇到了同样的问题。解决方案已更新为android @ 8。谢谢@Splinteer。 这是有关执行此操作的更多详细信息:

列出您的平台:

ionic cordova platform list

使用以下方法删除android

ionic cordova platform rm android

添加android @ 8:

ionic cordova platform add android@8