How to override defaultConfig abiFilters in buildTypes












0















abiFilters is set in android build.gradle defaultConfig block.



I'd like to exclude x86 from release buildType, but can't find an easy way to do it



Here is the build.gradle:



defaultConfig {
ndk {
abiFilters "armeabi", "x86"
moduleName "cipher_v1"
cFlags "-DRELEASE=1"
if (rootProject.ext.has("testCrack")) {
cFlags += " -DTEST_CRACK"
}
if (project.ext.has("authKey") && project.ext.has("androidId")) {
cFlags += "-DAUTH_KEY=\"" + project.ext.authKey + "\""
"-DANDROID_ID=\"" + project.ext.androidId + "\""
}
}
}

buildTypes {
release {
ndk {
abiFilters "armeabi"
}
}
}


Here is what I get:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so
17640 02-01-1980 00:00 jni/x86/libcipher_v1.so


Here is what I really want:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so


I'd like to keep a full abiFilters in the defautlConfig block



And specify ones in certain buildType





EDIT 1:



Yes, removing the defaultConfig and setting abiFilters in both debug & release block would work. But my question is how to utilize the defaultConfig










share|improve this question

























  • Answered my own question, but willing to see if any better solutions. Still don't know how to completely override abiFilters from defaultConfig

    – Felix.D
    Nov 19 '18 at 14:00
















0















abiFilters is set in android build.gradle defaultConfig block.



I'd like to exclude x86 from release buildType, but can't find an easy way to do it



Here is the build.gradle:



defaultConfig {
ndk {
abiFilters "armeabi", "x86"
moduleName "cipher_v1"
cFlags "-DRELEASE=1"
if (rootProject.ext.has("testCrack")) {
cFlags += " -DTEST_CRACK"
}
if (project.ext.has("authKey") && project.ext.has("androidId")) {
cFlags += "-DAUTH_KEY=\"" + project.ext.authKey + "\""
"-DANDROID_ID=\"" + project.ext.androidId + "\""
}
}
}

buildTypes {
release {
ndk {
abiFilters "armeabi"
}
}
}


Here is what I get:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so
17640 02-01-1980 00:00 jni/x86/libcipher_v1.so


Here is what I really want:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so


I'd like to keep a full abiFilters in the defautlConfig block



And specify ones in certain buildType





EDIT 1:



Yes, removing the defaultConfig and setting abiFilters in both debug & release block would work. But my question is how to utilize the defaultConfig










share|improve this question

























  • Answered my own question, but willing to see if any better solutions. Still don't know how to completely override abiFilters from defaultConfig

    – Felix.D
    Nov 19 '18 at 14:00














0












0








0








abiFilters is set in android build.gradle defaultConfig block.



I'd like to exclude x86 from release buildType, but can't find an easy way to do it



Here is the build.gradle:



defaultConfig {
ndk {
abiFilters "armeabi", "x86"
moduleName "cipher_v1"
cFlags "-DRELEASE=1"
if (rootProject.ext.has("testCrack")) {
cFlags += " -DTEST_CRACK"
}
if (project.ext.has("authKey") && project.ext.has("androidId")) {
cFlags += "-DAUTH_KEY=\"" + project.ext.authKey + "\""
"-DANDROID_ID=\"" + project.ext.androidId + "\""
}
}
}

buildTypes {
release {
ndk {
abiFilters "armeabi"
}
}
}


Here is what I get:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so
17640 02-01-1980 00:00 jni/x86/libcipher_v1.so


Here is what I really want:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so


I'd like to keep a full abiFilters in the defautlConfig block



And specify ones in certain buildType





EDIT 1:



Yes, removing the defaultConfig and setting abiFilters in both debug & release block would work. But my question is how to utilize the defaultConfig










share|improve this question
















abiFilters is set in android build.gradle defaultConfig block.



I'd like to exclude x86 from release buildType, but can't find an easy way to do it



Here is the build.gradle:



defaultConfig {
ndk {
abiFilters "armeabi", "x86"
moduleName "cipher_v1"
cFlags "-DRELEASE=1"
if (rootProject.ext.has("testCrack")) {
cFlags += " -DTEST_CRACK"
}
if (project.ext.has("authKey") && project.ext.has("androidId")) {
cFlags += "-DAUTH_KEY=\"" + project.ext.authKey + "\""
"-DANDROID_ID=\"" + project.ext.androidId + "\""
}
}
}

buildTypes {
release {
ndk {
abiFilters "armeabi"
}
}
}


Here is what I get:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so
17640 02-01-1980 00:00 jni/x86/libcipher_v1.so


Here is what I really want:



unzip -l base-release.aar|grep cipher
17752 02-01-1980 00:00 jni/armeabi/libcipher_v1.so


I'd like to keep a full abiFilters in the defautlConfig block



And specify ones in certain buildType





EDIT 1:



Yes, removing the defaultConfig and setting abiFilters in both debug & release block would work. But my question is how to utilize the defaultConfig







android gradle android-gradle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 1:25







Felix.D

















asked Nov 15 '18 at 14:56









Felix.DFelix.D

342312




342312













  • Answered my own question, but willing to see if any better solutions. Still don't know how to completely override abiFilters from defaultConfig

    – Felix.D
    Nov 19 '18 at 14:00



















  • Answered my own question, but willing to see if any better solutions. Still don't know how to completely override abiFilters from defaultConfig

    – Felix.D
    Nov 19 '18 at 14:00

















Answered my own question, but willing to see if any better solutions. Still don't know how to completely override abiFilters from defaultConfig

– Felix.D
Nov 19 '18 at 14:00





Answered my own question, but willing to see if any better solutions. Still don't know how to completely override abiFilters from defaultConfig

– Felix.D
Nov 19 '18 at 14:00












3 Answers
3






active

oldest

votes


















0














android {
buildTypes {
debug {
ndk {
abiFilters "armeabi", "x86"
}
}
release {
ndk {
abiFilters "armeabi"
}
}
}
}


productFlavors also would support dimension abi.






share|improve this answer
























  • This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

    – Felix.D
    Nov 16 '18 at 1:22











  • @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

    – Martin Zeitler
    Nov 16 '18 at 4:10













  • it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

    – Martin Zeitler
    Nov 16 '18 at 4:15













  • Thanks, your comment lead me to a solution

    – Felix.D
    Nov 19 '18 at 13:50



















0














Feeding a command line option, e.g. "no_x86"





  1. Add below to your app/build.gradle



    defaultConfig {
    ndk {

    ...
    if (project.hasProperty("no_x86")) {
    abiFilters "armeabi"
    } else {
    abiFilters "armeabi", "x86"
    }

    ...
    }
    }



  2. Use below command to generate the APKs without x86 ABI by feeding option no_x86 to the command.



    ./gradlew assemble -Pno_x86


    but don't feed option no_x86 to the command if you want to build APKs with x86 abi. As the defaultConfig is to keep a full abiFilters per your requirement.



    For certain buildType, you can invoke the corresponding build command by feeding or not feeding the -Pno_x86 property. E.g. ./gradlew assembleRelease -Pno_x86




Reference: https://stackoverflow.com/a/52980193/8034839






share|improve this answer

































    0














    Thanks to Martin, I found a workable solution from this:



    when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out



    I realize that adding wanted abi to debug is a workaround for removing unwanted abi for release



    Works For Me



    defaultConfig {
    ndk {
    //abiFilters "armeabi", "x86"
    abiFilters "armeabi"
    }
    }

    buildTypes {
    debug {
    ndk {
    //abiFilters "armeabi", "x86"
    abiFilters "x86"
    }
    }
    release {
    //ndk {
    // abiFilters "armeabi"
    //}
    }
    }





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322169%2fhow-to-override-defaultconfig-abifilters-in-buildtypes%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      android {
      buildTypes {
      debug {
      ndk {
      abiFilters "armeabi", "x86"
      }
      }
      release {
      ndk {
      abiFilters "armeabi"
      }
      }
      }
      }


      productFlavors also would support dimension abi.






      share|improve this answer
























      • This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

        – Felix.D
        Nov 16 '18 at 1:22











      • @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

        – Martin Zeitler
        Nov 16 '18 at 4:10













      • it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

        – Martin Zeitler
        Nov 16 '18 at 4:15













      • Thanks, your comment lead me to a solution

        – Felix.D
        Nov 19 '18 at 13:50
















      0














      android {
      buildTypes {
      debug {
      ndk {
      abiFilters "armeabi", "x86"
      }
      }
      release {
      ndk {
      abiFilters "armeabi"
      }
      }
      }
      }


      productFlavors also would support dimension abi.






      share|improve this answer
























      • This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

        – Felix.D
        Nov 16 '18 at 1:22











      • @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

        – Martin Zeitler
        Nov 16 '18 at 4:10













      • it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

        – Martin Zeitler
        Nov 16 '18 at 4:15













      • Thanks, your comment lead me to a solution

        – Felix.D
        Nov 19 '18 at 13:50














      0












      0








      0







      android {
      buildTypes {
      debug {
      ndk {
      abiFilters "armeabi", "x86"
      }
      }
      release {
      ndk {
      abiFilters "armeabi"
      }
      }
      }
      }


      productFlavors also would support dimension abi.






      share|improve this answer













      android {
      buildTypes {
      debug {
      ndk {
      abiFilters "armeabi", "x86"
      }
      }
      release {
      ndk {
      abiFilters "armeabi"
      }
      }
      }
      }


      productFlavors also would support dimension abi.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 15 '18 at 19:30









      Martin ZeitlerMartin Zeitler

      18.7k34372




      18.7k34372













      • This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

        – Felix.D
        Nov 16 '18 at 1:22











      • @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

        – Martin Zeitler
        Nov 16 '18 at 4:10













      • it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

        – Martin Zeitler
        Nov 16 '18 at 4:15













      • Thanks, your comment lead me to a solution

        – Felix.D
        Nov 19 '18 at 13:50



















      • This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

        – Felix.D
        Nov 16 '18 at 1:22











      • @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

        – Martin Zeitler
        Nov 16 '18 at 4:10













      • it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

        – Martin Zeitler
        Nov 16 '18 at 4:15













      • Thanks, your comment lead me to a solution

        – Felix.D
        Nov 19 '18 at 13:50

















      This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

      – Felix.D
      Nov 16 '18 at 1:22





      This would work, but I want to maintain a default abiFilters in defautConfig. And only tweak some of the buildTypes or flavors

      – Felix.D
      Nov 16 '18 at 1:22













      @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

      – Martin Zeitler
      Nov 16 '18 at 4:10







      @Felix.D when only configuring build-type release, it might require a reset(). this at least works with splits, where one could even build two separete packages. as the issue is being described, it sounds alike as if abiFilters would only add filters, but not override them, as expected.

      – Martin Zeitler
      Nov 16 '18 at 4:10















      it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

      – Martin Zeitler
      Nov 16 '18 at 4:15







      it's exactly the opposite approach, but when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out.

      – Martin Zeitler
      Nov 16 '18 at 4:15















      Thanks, your comment lead me to a solution

      – Felix.D
      Nov 19 '18 at 13:50





      Thanks, your comment lead me to a solution

      – Felix.D
      Nov 19 '18 at 13:50













      0














      Feeding a command line option, e.g. "no_x86"





      1. Add below to your app/build.gradle



        defaultConfig {
        ndk {

        ...
        if (project.hasProperty("no_x86")) {
        abiFilters "armeabi"
        } else {
        abiFilters "armeabi", "x86"
        }

        ...
        }
        }



      2. Use below command to generate the APKs without x86 ABI by feeding option no_x86 to the command.



        ./gradlew assemble -Pno_x86


        but don't feed option no_x86 to the command if you want to build APKs with x86 abi. As the defaultConfig is to keep a full abiFilters per your requirement.



        For certain buildType, you can invoke the corresponding build command by feeding or not feeding the -Pno_x86 property. E.g. ./gradlew assembleRelease -Pno_x86




      Reference: https://stackoverflow.com/a/52980193/8034839






      share|improve this answer






























        0














        Feeding a command line option, e.g. "no_x86"





        1. Add below to your app/build.gradle



          defaultConfig {
          ndk {

          ...
          if (project.hasProperty("no_x86")) {
          abiFilters "armeabi"
          } else {
          abiFilters "armeabi", "x86"
          }

          ...
          }
          }



        2. Use below command to generate the APKs without x86 ABI by feeding option no_x86 to the command.



          ./gradlew assemble -Pno_x86


          but don't feed option no_x86 to the command if you want to build APKs with x86 abi. As the defaultConfig is to keep a full abiFilters per your requirement.



          For certain buildType, you can invoke the corresponding build command by feeding or not feeding the -Pno_x86 property. E.g. ./gradlew assembleRelease -Pno_x86




        Reference: https://stackoverflow.com/a/52980193/8034839






        share|improve this answer




























          0












          0








          0







          Feeding a command line option, e.g. "no_x86"





          1. Add below to your app/build.gradle



            defaultConfig {
            ndk {

            ...
            if (project.hasProperty("no_x86")) {
            abiFilters "armeabi"
            } else {
            abiFilters "armeabi", "x86"
            }

            ...
            }
            }



          2. Use below command to generate the APKs without x86 ABI by feeding option no_x86 to the command.



            ./gradlew assemble -Pno_x86


            but don't feed option no_x86 to the command if you want to build APKs with x86 abi. As the defaultConfig is to keep a full abiFilters per your requirement.



            For certain buildType, you can invoke the corresponding build command by feeding or not feeding the -Pno_x86 property. E.g. ./gradlew assembleRelease -Pno_x86




          Reference: https://stackoverflow.com/a/52980193/8034839






          share|improve this answer















          Feeding a command line option, e.g. "no_x86"





          1. Add below to your app/build.gradle



            defaultConfig {
            ndk {

            ...
            if (project.hasProperty("no_x86")) {
            abiFilters "armeabi"
            } else {
            abiFilters "armeabi", "x86"
            }

            ...
            }
            }



          2. Use below command to generate the APKs without x86 ABI by feeding option no_x86 to the command.



            ./gradlew assemble -Pno_x86


            but don't feed option no_x86 to the command if you want to build APKs with x86 abi. As the defaultConfig is to keep a full abiFilters per your requirement.



            For certain buildType, you can invoke the corresponding build command by feeding or not feeding the -Pno_x86 property. E.g. ./gradlew assembleRelease -Pno_x86




          Reference: https://stackoverflow.com/a/52980193/8034839







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 1:58

























          answered Nov 16 '18 at 1:50









          shizhenshizhen

          3,69741234




          3,69741234























              0














              Thanks to Martin, I found a workable solution from this:



              when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out



              I realize that adding wanted abi to debug is a workaround for removing unwanted abi for release



              Works For Me



              defaultConfig {
              ndk {
              //abiFilters "armeabi", "x86"
              abiFilters "armeabi"
              }
              }

              buildTypes {
              debug {
              ndk {
              //abiFilters "armeabi", "x86"
              abiFilters "x86"
              }
              }
              release {
              //ndk {
              // abiFilters "armeabi"
              //}
              }
              }





              share|improve this answer




























                0














                Thanks to Martin, I found a workable solution from this:



                when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out



                I realize that adding wanted abi to debug is a workaround for removing unwanted abi for release



                Works For Me



                defaultConfig {
                ndk {
                //abiFilters "armeabi", "x86"
                abiFilters "armeabi"
                }
                }

                buildTypes {
                debug {
                ndk {
                //abiFilters "armeabi", "x86"
                abiFilters "x86"
                }
                }
                release {
                //ndk {
                // abiFilters "armeabi"
                //}
                }
                }





                share|improve this answer


























                  0












                  0








                  0







                  Thanks to Martin, I found a workable solution from this:



                  when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out



                  I realize that adding wanted abi to debug is a workaround for removing unwanted abi for release



                  Works For Me



                  defaultConfig {
                  ndk {
                  //abiFilters "armeabi", "x86"
                  abiFilters "armeabi"
                  }
                  }

                  buildTypes {
                  debug {
                  ndk {
                  //abiFilters "armeabi", "x86"
                  abiFilters "x86"
                  }
                  }
                  release {
                  //ndk {
                  // abiFilters "armeabi"
                  //}
                  }
                  }





                  share|improve this answer













                  Thanks to Martin, I found a workable solution from this:



                  when defaultConfig would only have armeabi configured and build-type debug would then add x86, this might work out



                  I realize that adding wanted abi to debug is a workaround for removing unwanted abi for release



                  Works For Me



                  defaultConfig {
                  ndk {
                  //abiFilters "armeabi", "x86"
                  abiFilters "armeabi"
                  }
                  }

                  buildTypes {
                  debug {
                  ndk {
                  //abiFilters "armeabi", "x86"
                  abiFilters "x86"
                  }
                  }
                  release {
                  //ndk {
                  // abiFilters "armeabi"
                  //}
                  }
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 '18 at 13:58









                  Felix.DFelix.D

                  342312




                  342312






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322169%2fhow-to-override-defaultconfig-abifilters-in-buildtypes%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bressuire

                      Vorschmack

                      Quarantine