Sunday, 1 July 2018

IONIC BASED App's multiple apk generation causes - import com.android.build.OutputFile - Unknown type: IMPORT

I am rebuilding an ionic project in android. due to a library, I need to split the apk to smaller size. It used to work (a year ago), and now it doesn't, I have upgraded my ionic and some environments.
The problem is the line, it does not recognized.
import com.android.build.OutputFile

Here is the error:
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
       ^

Here is my 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
            }
        }
}

the full build.gradle is here https://gist.github.com/axilaris/73ba223cb51025c0732b33158742e837
I'v set gradle to:
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
}

I'm using Android Studio 3.0.1
And if I remove the line "import com.android.build.OutputFile", it gives this error:
Error:(194, 0) Cannot get property 'abiCodes' on extra properties extension as it does not exist

The main question is how to get this below recognized in build.gradle ?
  import com.android.build.OutputFile



from IONIC BASED App's multiple apk generation causes - import com.android.build.OutputFile - Unknown type: IMPORT

No comments:

Post a Comment