8

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!

WTF! WTF2!

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!

Chisko
  • 3,092
  • 6
  • 27
  • 45
  • Just an initial thought, `applicationVariants.all { variant -> variant.outputs.each`, could this maybe be overwriting the .apk's with only the last build which in this case might be x86_64. I remember having a similar problem a while back. What I've had to do is to look for an identifier and only write that for the specific build. – just_user Apr 04 '17 at 13:24
  • @just_user So doing kind of like a switch for archs inside that block? – Chisko Apr 04 '17 at 13:31
  • Exactly, but I'd test it first. Remove x86_64 from the building to see if all builds are just x86 then or one of the others. – just_user Apr 04 '17 at 13:37
  • Following @just_user advice, removed x86 support as I don't really need it. Result is the same – Chisko Apr 04 '17 at 22:39
  • @just_user I tried doing the switch you mentioned but I could figure out if I need to compare a property inside `variant.outputs` or against a string. Could you please be more specific? :) – Chisko Apr 05 '17 at 14:24
  • So I copied the build script into a new project and now the native_code flag is not set at all. This is weird as **** – Chisko Apr 05 '17 at 16:38
  • I've tried your script too and haven't been able to have it working. But if you get no native_code flag set, try `gradle clean`? – just_user Apr 06 '17 at 10:14
  • No those don't work either, also did reset cachés – Chisko Apr 06 '17 at 15:38
  • Double-check the permissions listed in your `AndroidManifest.xml`. Last time I had *0 apps supported* at Google Play, it was caused by a typo in `android.hardware.camera`. – JP Ventura Apr 06 '17 at 19:41
  • Thank you for your suggestion @JPVentura but the Manifest is typo-free – Chisko Apr 06 '17 at 20:09

1 Answers1

3

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.

Chisko
  • 3,092
  • 6
  • 27
  • 45