Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/211.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android多味库模块用于应用模块_Android_Gradle_Module_Static Libraries_Android Productflavors - Fatal编程技术网

Android多味库模块用于应用模块

Android多味库模块用于应用模块,android,gradle,module,static-libraries,android-productflavors,Android,Gradle,Module,Static Libraries,Android Productflavors,我正在尝试设置一个依赖于使用“.so”文件的库模块的项目 到目前为止,我有: 库模块 .so文件到jniLibs中:armeabi、armeabi-v7a和x86 这是用于配置的Android.mk文件: #版权所有(C)2010安卓开源项目 # #根据Apache许可证2.0版(以下简称“许可证”)获得许可; #除非遵守许可证,否则不得使用此文件。 #您可以通过以下方式获得许可证副本: # # http://www.apache.org/licenses/LICENSE-2.0

我正在尝试设置一个依赖于使用“.so”文件的库模块的项目

到目前为止,我有:

库模块
  • .so文件到jniLibs中:armeabi、armeabi-v7a和x86
  • 这是用于配置的Android.mk文件:
#版权所有(C)2010安卓开源项目 # #根据Apache许可证2.0版(以下简称“许可证”)获得许可; #除非遵守许可证,否则不得使用此文件。 #您可以通过以下方式获得许可证副本: # # http://www.apache.org/licenses/LICENSE-2.0 # #除非适用法律要求或书面同意,软件 #根据许可证进行的分发是按“原样”进行分发的, #无任何明示或暗示的保证或条件。 #请参阅许可证以了解管理权限和权限的特定语言 #许可证下的限制。 本地路径:=$(调用我的目录) 包括$(清除变量) #这里我们给出了模块名和源文件 本地模块:=我的模块 本地\u SRC\u文件:=$(TARGET\u ARCH\u ABI)/my-lib.so 本地导出包含:=$(本地路径)/包含 包括$(预建共享库)
  • 这是build.gradle文件:
应用插件:“com.android.library” 安卓{ 编译DK23版 buildToolsVersion“23.0.2” 默认配置{ 第15版 targetSdkVersion 23 版本代码1 版本名称“1.0” } 编译选项{ sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } 建筑类型{ 释放{ minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro' } } sourceSets.main.jni.srcDirs=[]//禁用自动ndk生成调用 //默认情况下,将发布样式设置为 defaultPublishConfig“X86Debug” 出版非默认真实 产品风味{ //有关ABI筛选器的详细说明,请参阅“支持的ABI”@ // https://developer.android.com/ndk/guides/abis.html#sa 手臂{ ndk{ abiFilter(“armeabi”) } } arm7{ ndk{ abiFilter(“armeabi-v7a”) } } x86{ ndk{ abiFilter(“x86”) } } //这是fat apk,包括所有ABI 脂肪 } } 依赖关系{ testCompile'junit:junit:4.12' 编译'com.j256.ormlite:ormlite android:4.48' } 应用模块
  • 这是build.gradle:
... 应用插件:“com.android.application” ... 安卓{ ... //如果需要对口味使用多个过滤器,则顺序很重要 “空气污染指数”、“空气污染指数” 产品风味{ //定义单独的开发和产品风格。 发展{ 维度“api” //dev利用minSDKVersion=21来允许Android gradle插件 //为每个模块预先编制索引,并生成可在其上测试的APK //Android棒棒糖没有耗时的dex合并过程。 明斯克版本21 } 刺激{ 维度“api” //应用程序的实际版本。 minSdkVersion Integer.parseInt((字符串)project.ANDROID\u BUILD\u MIN\u SDK\u VERSION) } //有关ABI筛选器的详细说明,请参阅“支持的ABI”@ // https://developer.android.com/ndk/guides/abis.html#sa 手臂{ 维度“abi” ndk{ abiFilter(“armeabi”) } } arm7{ 维度“abi” ndk{ abiFilter(“armeabi-v7a”) } } x86{ 维度“abi” ndk{ abiFilter(“x86”) } } } ... 建筑类型{ 释放{ //禁用所有组件以进行调试 可调试错误 //使用更新的proguard规则 proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro' //混淆、清理和优化项目代码 minifyEnabled true //启用zip对齐以进行优化 Zipalignedtrue //仅在发布buildType上使用发布密钥 signingConfig signingConfigs.prod } 调试{ 可调试真 minifyEnabled false Zipalignedfalse } } ... 编译选项{ sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } 配置{ //x86版本 DEVX862调试编译 prodX86DebugCompile devX86ReleaseCompile prodX86ReleaseCompile //arm版本 devArmDebugCompile prodArmDebugCompile devArmReleaseCompile prodArmReleaseCompile //arm7版本 devArm7DebugCompile prodArm7DebugCompile devArm7ReleaseCompile prodArm7ReleaseCompile } 依赖关系{ 编译文件树(包括:['*.jar'],目录:“libs”) devX86DebugCompile项目(路径:':我的模块库',配置:'x86Debug') prodX86DebugCompile项目(路径:':我的模块库',配置:'x86Debug') DEVX86ReleaseComile项目(路径:':我的模块库',配置:'x86Release') ProdX86ReleaseComile项目(路径:':我的模块库',配置:'x86Release') devArmDebugCompile项目(路径:':我的模块库',配置:'armDebug') prodArmDebugCompile项目(路径:':我的模块库',配置:'armDebug') DevarmReleaseComile项目(路径:':我的模块库',配置:'armRelease') ProdArmReleaseComile项目(路径:':我的模块库',配置:'armRelease') devArm7DebugCompile项目(路径:':我的模块库',配置:'arm7Debug') 前驱臂 # Copyright (C) 2010 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # Here we give our module name and source file(s) LOCAL_MODULE := my-module LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/my-lib.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_SHARED_LIBRARY) apply plugin: 'com.android.library' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets.main.jni.srcDirs = [] //disable automatic ndk-build call // By default set the publish flavor to defaultPublishConfig "X86Debug" publishNonDefault true productFlavors { // for detailed abiFilter descriptions, refer to "Supported ABIs" @ // https://developer.android.com/ndk/guides/abis.html#sa arm { ndk { abiFilter("armeabi") } } arm7 { ndk { abiFilter("armeabi-v7a") } } x86 { ndk { abiFilter("x86") } } // This is the fat apk which includes all the ABIs fat } } dependencies { testCompile 'junit:junit:4.12' compile 'com.j256.ormlite:ormlite-android:4.48' } ... apply plugin: 'com.android.application' ... android { ... // In case more than one filter should be applied for the flavors, the order is important flavorDimensions "api", "abi" productFlavors { // Define separate dev and prod product flavors. dev { dimension "api" // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin // to pre-dex each module and produce an APK that can be tested on // Android Lollipop without time consuming dex merging processes. minSdkVersion 21 } prod { dimension "api" // The actual minSdkVersion for the application. minSdkVersion Integer.parseInt((String) project.ANDROID_BUILD_MIN_SDK_VERSION) } // for detailed abiFilter descriptions, refer to "Supported ABIs" @ // https://developer.android.com/ndk/guides/abis.html#sa arm { dimension "abi" ndk { abiFilter("armeabi") } } arm7 { dimension "abi" ndk { abiFilter("armeabi-v7a") } } x86 { dimension "abi" ndk { abiFilter("x86") } } } ... buildTypes { release { // Disable all components for debug debuggable false // Use the updated proguard rules proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // Obfuscate, clean and optimize project code minifyEnabled true // Enable zip align for optimizations zipAlignEnabled true //Only use the release key on a release buildType signingConfig signingConfigs.prod } debug { debuggable true minifyEnabled false zipAlignEnabled false } } ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } } configurations { // x86 versions devX86DebugCompile prodX86DebugCompile devX86ReleaseCompile prodX86ReleaseCompile // arm versions devArmDebugCompile prodArmDebugCompile devArmReleaseCompile prodArmReleaseCompile // arm7 versions devArm7DebugCompile prodArm7DebugCompile devArm7ReleaseCompile prodArm7ReleaseCompile } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') devX86DebugCompile project(path: ':my-module-lib', configuration: 'x86Debug') prodX86DebugCompile project(path: ':my-module-lib', configuration: 'x86Debug') devX86ReleaseCompile project(path: ':my-module-lib', configuration: 'x86Release') prodX86ReleaseCompile project(path: ':my-module-lib', configuration: 'x86Release') devArmDebugCompile project(path: ':my-module-lib', configuration: 'armDebug') prodArmDebugCompile project(path: ':my-module-lib', configuration: 'armDebug') devArmReleaseCompile project(path: ':my-module-lib', configuration: 'armRelease') prodArmReleaseCompile project(path: ':my-module-lib', configuration: 'armRelease') devArm7DebugCompile project(path: ':my-module-lib', configuration: 'arm7Debug') prodArm7DebugCompile project(path: ':my-module-lib', configuration: 'arm7Debug') devArm7ReleaseCompile project(path: ':my-module-lib', configuration: 'arm7Release') prodArm7ReleaseCompile project(path: ':my-module-lib', configuration: 'arm7Release') ... }