Android Build Tools only builds x86_64 no matter w

2019-06-16 19:30发布

问题:

So this is happening. No matter what I try doing on the build.gradle, all APK are coming out with native_code = 'x86_64' flag, so when I deploy the app to the store the result is having +15K uncompatible devices, and only 19 compatible. I first thought that, somehow, having NDK installed was the reason, or my modified build script. But it still happens when I go through the Generate Signed APK wizard. The splits block was also originally missing, and didn't help. The weirdest thing is that when I install via a console push, IT WORKS!

I also tried switching to the recommended JRE, also several APK naming strategies regarding file creation, like moving the output to different directories or not using the file constructor.

My build.gradle looks like this:

defaultConfig {
    applicationId "com.chiskosystems.brokr"
    versionCode versionNumber
    versionName "${versionMajor}.${versionMinor}.${versionPatch} (${versionBuild}) Release"
    minSdkVersion 16
    targetSdkVersion 25
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true

    jackOptions {
        enabled false
    }

    vectorDrawables {
        useSupportLibrary true
    }
}

splits {
    abi {
        enable true
        reset()
        include 'armeabi', 'armeabi-v7a', 'arm64-v8a'
    }
}

project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3]

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def fileNaming = "apk/brokr"
        def outputFile = output.outputFile

        output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(
                        com.android.build.OutputFile.ABI), 0) * 10000000 + android.defaultConfig.versionCode

    }

}

signingConfigs {
    release {
        try {
            storeFile file('../mystore.jks')
            keyAlias 'release'
            storePassword KEYSTORE_PASSWORD
            keyPassword KEY_PASSWORD
        } catch (ex) {
            throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
        }
    }
}

dataBinding {
    enabled true
}

dexOptions {
    javaMaxHeapSize "3g"
    preDexLibraries false
}

buildTypes {
    release {
        minifyEnabled false
        proguardFile 'path/proguard-project.pro'
        ...
        buildConfigField "String", 'SERVER', '"https://myfirebaseserver.com"'
        debuggable false
        signingConfig signingConfigs.release
    }
    debug {
        minifyEnabled false
        applicationIdSuffix ".debug"
        versionNameSuffix "-debug"
        buildConfigField "String", 'SERVER', '"https://myfirebaseserver.com"'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

productFlavors {
    sandbox {
        buildConfigField "String", 'PAYPAL_ENV', '"PayPalConfiguration.ENVIRONMENT_NO_NETWORK"'
    }
    full {
        buildConfigField "String", 'PAYPAL_ENV', '"PayPalConfiguration.ENVIRONMENT_PRODUCTION"'
        signingConfig signingConfigs.release
        targetSdkVersion 25
    }
}

Happening on both Win and Unix systems. I've spent the whole day modifiyng the script without success and I'm helpless at this point.

Any ideas of what the bleep is going on? Thanks a lot!

回答1:

The cause was a dependency:

compile 'com.lambdaworks:scrypt:1.4.0'

apparently automatically grabbing my laptop's architecture and sticking that flag in there.