IONIC BASED App的多个apk生成原因 - import com.android.build.OutputFile - Unknown类型:IMPORT

时间:2018-03-06 14:35:59

标签: android gradle import apk

我正在重建android中的离子项目。由于库,我需要将apk拆分为更小的尺寸。它曾经工作(一年前),现在它没有,我升级了我的离子和一些环境。

问题在于线,它无法识别。

import com.android.build.OutputFile

这是错误:

Error:(180, 0) startup failed:
build file '/Users/some/project/ionicapp/platforms/android/build.gradle': 180: Unknown type: IMPORT at line: 180 column: 5. File: _BuildScript_ @ line 180, column 5.
       import com.android.build.OutputFile
       ^

这是我的build.gradle

ext.abiCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 4, 'x86': 5, 'x86_64': 6]

import com.android.build.OutputFile <--- problem

android.applicationVariants.all {
    variant ->

        // Assigns a different version code for each output APK
        // other than the universal APK.
        variant.outputs.each { output ->

            // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
            def baseAbiVersionCode =
                    // Determines the ABI for this variant and returns the mapped value.
                    project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))

            // Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
            // the following code does not override the version code for universal APKs.
            // However, because we want universal APKs to have the lowest version code,
            // this outcome is desirable.
            if (baseAbiVersionCode != null) {

                // Assigns the new version code to versionCodeOverride, which changes the version code
                // for only the output APK, not for the variant itself. Skipping this step simply
                // causes Gradle to use the value of variant.versionCode for the APK.
                output.versionCodeOverride =
                        baseAbiVersionCode * 100 + variant.versionCode
            }
        }
}

完整的build.gradle在这里https://gist.github.com/axilaris/73ba223cb51025c0732b33158742e837

我将gradle设置为:

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
}

我正在使用Android Studio 3.0.1

如果我删除“import com.android.build.OutputFile”这一行,则会出现此错误:

Error:(194, 0) Cannot get property 'abiCodes' on extra properties extension as it does not exist

主要问题是如何在build.gradle中识别以下内容?

  import com.android.build.OutputFile

0 个答案:

没有答案