如何在没有.mk文件的情况下强制gradle在Android Studion中创建.a文件?

时间:2015-12-02 06:59:11

标签: android-studio gradle android-ndk static-libraries static-linking

项目是在Android Studio中制作的。 它是Java + C到NDK。 Android Studio正在生成* .so文件。 如何将其更改为* .a文件?

.so文件由gradle NDK制作。 (没有.mk文件)

gradle中是否有方法/标志要求静态库(.a文件)? (我需要分享.a而不是.so)

Gradle文件:

apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1'
defaultConfig {
    minSdkVersion 10
    targetSdkVersion 19
    versionCode 1
    versionName '1.0'

    ndk
    {
        moduleName "mylib"
        ldLibs  "m", "log", "android", "jnigraphics"
    }
}
// This actual the app version code. Our given range is [0, 99999]
defaultConfig.versionCode = 3

// 2 dimensions of flavors. API is more important than ABI.
flavorDimensions "abi"

productFlavors {
    x86 {
        dimension "abi"
        ndk {
            abiFilter "x86"
        }
        // this is the flavor part of the version code.
        // It must be higher than the arm one for devices supporting
        // both, as x86 is preferred.
        versionCode = 3
    }
    arm {
        dimension "abi"
        ndk {
            abiFilter "armeabi-v7a"
        }
        versionCode = 2
    }
    mips {
        dimension "abi"
        ndk {
            abiFilter "mips"
        }
        versionCode = 1
    }
    fat {
        dimension "abi"
        // fat binary, lowest version code to be
        // the last option
        versionCode = 0
    }
}

// make per-variant version code
applicationVariants.all { variant ->
    // get the version code of each flavor
    def abiVersion = variant.productFlavors.get(0).versionCode

    // set the composite code
    variant.mergedFlavor.versionCode = abiVersion * 100000 + defaultConfig.versionCode
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(include: ['*.jar'], dir: 'libs')    
}

0 个答案:

没有答案