abimaps安卓版本|android gradle xml 配置文件的值吗

⑴ abimaps签到偏差较大

莪可以解决任意位置签到及修改位置的问题,还有现场拍照都可以解决,联系莪用/户/名。

⑵ 怎么查看android abi架构

自动导入(推荐)在Mole的buid.gradle文件中添加依赖和属性配置:android{defaultConfig{ndk{//设置支持的SO库架构abiFilters'armeabi'//,'x86','armeabi-v7a','x86_64','arm64-v8a'}}}dependencies{compile'com.tencent.bugly:crashreport:latest.release'//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.8}

⑶ android gradle xml 配置文件的值吗

include ':app2'project(':app2').projectDir = new File('path/to/app2')12Mole中的build.gradle//设置脚本的运行环境buildscript {//支持java 依赖库管理(maven/ivy),用于项目的依赖。repositories {mavenCentral()}//依赖包的定义。支持maven/ivy,远程,本地库,也支持单文件dependencies {classpath 'com.android.tools.build:gradle:0.4'}}//声明构建的项目类型,这里当然是android了apply plugin: 'android'//设置编译android项目的参数android {compileSdkVersion 17buildToolsVersion "17"defaultConfig {minSdkVersion 8targetSdkVersion 17}//Android默认配置sourceSets {main {manifest.srcFile 'AndroidManifest.xml'java.srcDirs = ['src']resources.srcDirs = ['src']aidl.srcDirs = ['src']renderscript.srcDirs = ['src']res.srcDirs = ['res']assets.srcDirs = ['assets']}//测试所在的路径,这里假设是tests文件夹,没有可以不写这一行instrumentTest.setRoot('tests')}//这个是解决lint报错的代码lintOptions {abortOnError false}/*** 签名设置*/signingConfigs {myConfigs {storeFile file("签名文件地址")keyAlias "…"keyPassword "…"storePassword "…"}}/*** 混淆设置*/buildTypes {release {signingConfig signingConfigs.myConfigsrunProguard trueproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}/*** 渠道打包(不同包名)*/proctFlavors {qqqq {applicationId = '包名'}hhhhh {applicationId='包名'}}}/*** .so文件的导入*/task NativeLibs(type: Copy) {from fileTree(dir: 'libs', include: 'armeabi/*.so') into 'build/lib'}tasks.withType(Compile) {options.encoding = "UTF-8"}tasks.withType(Compile) {compileTask -> compileTask.dependsOn NativeLibs}clean.dependsOn 'cleanCopyNativeLibs'tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->pkgTask.jniFolders = [new File(buildDir, 'lib')]}//依赖库dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])}一些关键词说明: android用来指定Android打包插件的相关属性,其包含如下节点 compileSdkVersion(apiLevel):设置编译时用的Android版本 buildToolsVersion(buildToolsVersionName):设置编译时使用的构建工具的版本 defaultConfig:设置一些默认属性,其可用属性是buildTypes和ProctFlavors之和 sourceSets:配置相关源文件的位置,当你的项目的目录结构跟默认的有区别但又不想改的时候sourceSets就派上用场了 – aidl 设置aidi的目录 – assets 设置assets资源目录 – compileConfigurationName The name of the compile configuration for this source set. – java Java源代码目录 – jni JNI代码目录 – jniLibs 已编译好的JNI库目录 – manifest 指定清单文件 – name The name of this source set. – packageConfigurationName The name of the runtime configuration for this source set. – providedConfigurationName The name of the compiled-only configuration for this source set. – renderscript Renderscript源代码目录 – res 资源目录 – setRoot(path) 根目录 signingConfigs:配置签名信息 – keyAlias 签名的别名 – keyPassword 密码 – storeFile 签名文件的路径 – storePassword 签名密码 – storeType 类型 buildTypes:配置构建类型,可打出不同类型的包,默认有debug和release两种,你还可以在增加N种 – applicationIdSuffix 修改applicationId,在默认applicationId的基础上加后缀。在buildType中修改applicationId时只能加后缀,不能完全修改 – debuggable 设置是否生成debug版的APK – jniDebuggable 设置生成的APK是否支持调试本地代码 – minifyEnabled 设置是否执行混淆 – multiDexEnabled Whether Multi-Dex is enabled for this variant. – renderscriptDebuggable 设置生成的APK是否支持调试RenderScript代码 – renderscriptOptimLevel 设置RenderScript优化级别 – signingConfig 设置签名信息 – versionNameSuffix 修改版本名称,在默认版本名称的基础上加后缀。在buildType中修改版本名称时只能加后缀,不能完全修改 – zipAlignEnabled 设置是否对APK包执行ZIP对齐优化 – proguardFile(proguardFile) 添加一个混淆文件 – proguardFiles(proguardFileArray) 添加多个混淆文件 – setProguardFiles(proguardFileIterable) 设置多个混淆文件 proctFlavors:配置不同风格的APP,在buildTypes的基础上还可以让每一个类型的APP拥有不同的风格,所以最终打出的APK的数量就是buildTypes乘以proctFlavors – applicationId 设置应用ID – multiDexEnabled Whether Multi-Dex is enabled for this variant.signingConfig Signing config used by this proct flavor. – testApplicationId 设置测试时的应用ID – testFunctionalTest See instrumentation. – testHandleProfiling See instrumentation. – testInstrumentationRunner Test instrumentation runner class name. – versionCode 设置版本号 – versionName 设置版本名称 – minSdkVersion(int minSdkVersion) 设置兼容的最小SDK版本 – minSdkVersion(String minSdkVersion) 设置兼容的最小版本 – proguardFile(proguardFile) 添加一个混淆文件 – proguardFiles(proguardFileArray) 添加多个混淆文件 – setProguardFiles(proguardFileIterable) 设置多个混淆文件 – targetSdkVersion(int targetSdkVersion) 设置目标SDK版本 – targetSdkVersion(String targetSdkVersion) 设置目标SDK版本 testOptions:设置测试相关属性 – reportDir 设置测试报告的目录 – resultsDir 设置测试结果的目录 – aaptOptions:设置AAPT的属性 – failOnMissingConfigEntry Forces aapt to return an error if it fails to find an entry for a configuration. – ignoreAssets Pattern describing assets to be ignore. – noCompress Extensions of files that will not be stored compressed in the APK. – useNewCruncher Whether to use the new cruncher. lintOptions:设置Lint的属性 – abortOnError 设置是否在lint发生错误时终止构建 – absolutePaths Whether lint should display full paths in the error output. By default the paths are relative to the path lint was invoked from. – check The exact set of issues to check, or null to run the issues that are enabled by default plus any issues enabled via LintOptions.getEnable() and without issues disabled via LintOptions.getDisable(). If non-null, callers are allowed to modify this collection. – checkAllWarnings Returns whether lint should check all warnings, including those off by default. – checkReleaseBuilds Returns whether lint should check for fatal errors ring release builds. Default is true. If issues with severity “fatal” are found, the release build is aborted. – disable The set of issue id’s to suppress. Callers are allowed to modify this collection. – enable The set of issue id’s to enable. Callers are allowed to modify this collection. To enable a given issue, add the issue ID to the returned set. – explainIssues Returns whether lint should include explanations for issue errors. (Note that HTML and XML reports intentionally do this – – – unconditionally, ignoring this setting.) – htmlOutput The optional path to where an HTML report should be written. – htmlReport Whether we should write an HTML report. Default true. The location can be controlled by LintOptions.getHtmlOutput(). – ignoreWarnings Returns whether lint will only check for errors (ignoring warnings). – lintConfig The default configuration file to use as a fallback. – noLines Whether lint should include the source lines in the output where errors occurred (true by default). – quiet Returns whether lint should be quiet (for example, not write informational messages such as paths to report files written). – severityOverrides An optional map of severity overrides. The map maps from issue id’s to the corresponding severity to use, which must be – “fatal”, “error”, “warning”, or “ignore”. – showAll Returns whether lint should include all output (e.g. include all alternate locations, not truncating long messages, etc.) – textOutput The optional path to where a text report should be written. The special value “stdout” can be used to point to standard output. – textReport Whether we should write an text report. Default false. The location can be controlled by LintOptions.getTextOutput(). – warningsAsErrors Returns whether lint should treat all warnings as errors. – xmlOutput The optional path to where an XML report should be written. – xmlReport Whether we should write an XML report. Default true. The location can be controlled by LintOptions.getXmlOutput(). – check(id) Adds the id to the set of issues to check. – check(ids) Adds the ids to the set of issues to check. – disable(id) Adds the id to the set of issues to enable. – disable(ids) Adds the ids to the set of issues to enable. – enable(id) Adds the id to the set of issues to enable. – enable(ids) Adds the ids to the set of issues to enable. – error(id) Adds a severity override for the given issues. – error(ids) Adds a severity override for the given issues. – fatal(id) Adds a severity override for the given issues. – fatal(ids) Adds a severity override for the given issues. – ignore(id) Adds a severity override for the given issues. – ignore(ids) Adds a severity override for the given issues. – warning(id) Adds a severity override for the given issues. – warning(ids) Adds a severity override for the given issues. dexOptions – incremental Whether to enable the incremental mode for dx. This has many limitations and may not work. Use carefully. – javaMaxHeapSize Sets the -JXmx* value when calling dx. Format should follow the 1024M pattern. – jumboMode Enable jumbo mode in dx (–force-jumbo). – preDexLibraries Whether to pre-dex libraries. This can improve incremental builds, but clean builds may be slower. compileOptions:设置编译的相关属性 – sourceCompatibility Language level of the source code. – targetCompatibility Version of the generated Java bytecode. packagingOptions:设置APK包的相关属性 – excludes The list of excluded paths. – pickFirsts The list of paths where the first occurrence is packaged in the APK.– exclude(path) Adds an excluded paths. – pickFirst(path) Adds a firstPick path. First pick paths do get packaged in the APK, but only the first occurrence gets packaged. – jacoco:设置JaCoCo的相关属性 – version 设置JaCoCo的版本 splits:设置如何拆分APK(比如你想拆分成arm版和x86版) – abi ABI settings. – abiFilters The list of ABI filters used for multi-apk. – density Density settings. – densityFilters The list of Density filters used for multi-apk.dependencies:配置依赖

⑷ 我帮同事用abi maps签到可以吗

你可以试试看啊如果同事确实没到那么不能代签,那是违规

⑸ abi maps登陆不上去是怎么回事

网站封了,或者你的网络有问题

⑹ 腾讯X5内核集成-解决遇到的问题(ABI平台匹配加载理解)

上周项目有需要,集成了“腾讯X5浏览器内核”过程中,也遇到了一些问题。经过摸索,也顺带补充解决了之前ABI方面的理解。 APP,内容模块视频部分,使用时夏正流行H5技术。 Html5的Video控件播放视频,在Android平台的WebView中播放的效果,和IOS播放效果有差异。IOS点击视频部分,会用系统自带的浏览器全屏播放视频,体验效果佳;而Android的WebView无法全屏。至少体验效果比IOS上的差一些。 ①Html5页面使用一些开源封装过的Video,带全屏等。 结果:产品部,认为体验不佳。提出疑问:“为什么在QQ上播放那么好呢?”,这,毕竟我们是技术方, 也不好直接说“别人技术牛”。 ②重写WebChromeClient的onShowCustomView开启全屏;onHideCustomView退出全屏。 结果:相信有朋友也折腾过这玩意,在Android 4.4开始的手机,大部分不会进入该回调方法。 ③技术体验上,不懂技术的同事等, 都是用QQ,微信举例。那就使用腾讯X5内核吧。 ①成功调用x5内核条件是安装腾讯三个常见产品之一:1、手机QQ;2、微信;3、QQ浏览器。当然版本也有限制,到这里,我们至少知道,三者中一个,是很有可能成功的,只要版本不太低,至少身边朋友的版本,都不至于太低了。 ②第一次安装集成该SDK的版本必须预热(从SDK接入文档中理解,理论上是, 大部分情况第一次是启动失败的,从试验中,是kill了进程,再开启才成功)。 ③ABI只提供armeabi的.so ①导入相应的.jar,  .so 文件: libs: tbs_sdk_v1.5.1.1057_25436_obfs_20160331_144900.jararmeabi:liblbs.so②预热X5内核: /*** 开启额外进程 服务 预加载X5内核, 此操作必须在主进程调起X5内核前进行,否则将不会实现预加载 */ private voidpreinitX5WithService() { Intent intent =newIntent(this,FirstLoadingX5Service.class); startService(intent); } /** * X5内核在使用preinit接口之后,对于首次安装首次加载没有效果 * 实际上,X5webview的preinit接口只是降低了webview的冷启动时间; * 因此,现阶段要想做到首次安装首次加载X5内核,必须要让X5内核提前获取到内核的加载条件 */ private voidpreinitX5WebCore() { if(!QbSdk.isTbsCoreInited()) { // preinit只需要调用一次,如果已经完成了初始化,那么就直接构造view QbSdk.preInit(MainActivity.this, null);// 设置X5初始化完成的回调接口 } } ③用多台手机测试:华为4A, 华为荣耀(忘记什么型号,是64位CPU),google nenux4, 小米4C, 华为mate 7, 红米Note2 等等。APP打包测试。 结果:只有我的华为4A能播放。 为什么别的,就不正常呢? ——————————以下-解决篇——————————– ①CPU方面,华为4A是比较老的CPU, 估计就是armeabi的了,由于别的机型,我都有对应的abi目录,都各自找到相应的平台目录, 所以无法加载“liblbs.so”。 ②尝试将“liblbs.so”放在各个abi目录中, 结果还是没办法启动x5。 ③通过网络,google等搜索,再次进行ABI方面的理解加深,获取解决方案: 项目的“build.gradle”文件defaultConfig,增加配置 ndk {abiFilters"armeabi","armeabi-v7a","x86","mips" } 结果:确实解决了问题。 ①难道是别的平台都指向了最低兼容的armeabi目录? 噢,如果这样做的话,在APP中性能会有极大的损失。如arm-v7中的  浮点运算,这就损失极大。更何况64位的CPU。 ②难道是机器是智能化了?先找相应平台的.so, 不行,再逐个查看向下的兼容平台?如果是这样,那就太好了。 ③什么优先顺序呢?这个Android选取ABI的机制?我也想了解。 顺带这个问题一起学习。 ①google一些资料,在overflow上,找到挺好的http://stackoverflow.com/questions/20674650/how-to-configure-ndk-with-android-gradle-plugin-0-7/21413011#21413011。 鬼老很务实, 他也有这种的疑问,从假象的提出,到论证,到结论。佩服。 文中的一些片段,我摘取一下: To simply Link in Prebuilt Native Libraries, just add an ndk section to your task. For instance, I added it below in proctFlavors. The abiFilter is the folder name the libs are stored in. abiFilters means both libs from the comma separated list will be added to your final APK (so you could theoretically have "armeabi", "armeabi-v7a", "x86", and "mips" all in one APK, and the O/S would choose the supported architecture lib on install):Very helpful. Thanks indeed. BTW, do you know the default search directory for user static libraries? I opt not to use the trick of "-I" in ldLibs, if possible. – weidongxu Apr 16 '14 at 20:10how does one explore/download the files listed here?: docs.google.com/… – Cliff Apr 26 '14 at 17:47 Found the example download but now I'm facing another issue w/ Gradle 1.11. The generated Androud.mk file uses absolute paths: stackoverflow.com/questions/23344567/… – Cliff Apr 28 '14 at 16:09 Thanks for the ldlibs tricking – I just found out that ldlibs are not kept in the order you type them in, which makes using multiple static libraries just about completely unusable. Unless they're "one" argument, after which it works. Awesome! – dascandy Jan 1 '15 at 22:15 2 This is the most detailed step-by-step introction I've ever seen for ndk setup. Google should have hired you to rewrite all their documentations. – John Jul 15 '15 at 16:53 Thanks @John, nice of you to say. The closest interview to google I had was at Microsoft, but they told me I wasn't "the right fit for Microsoft" when I couldn't write a bubble sort algorithm on the board (who the frick would want to memorize that…). Actually, that was just 1 of 3 interviews, the other 2 offered me jobs, but I declined and started my own business. 🙂 – reactive-core Oct 14 '15 at 18:49 @reactive-core, No wonder why Windows so fxxx up, they judge programmer by bubble sort algorithm! 🙂 – John Oct 15 '15 at 7:17 add a comment up vote 26 down vote accepted Found the answer. Including ndk.dir=path/to/ndk in the local.properties file did the trick. Update: On the latest versions of Android Studio, you can set the value directly in the Project Structure > SDK location. shareimprove this answer edited Oct 8 '15 at 10:25 answered Dec 19 '13 at 7:13 user1906 1,1311920 Don't forget to accept your answer – orip Dec 23 '13 at 9:54 3 Is it a good idea to put something manually into the local.properties file, since it says "This file is automatically generated by Android Studio. Do not modify this file — YOUR CHANGES WILL BE ERASED!" ? 从这对话中, 至少至少,都是能证明挺有料子的人。 OK,接下来,我也实验。 ②项目中,有用到,信鸽,地图等一系列的.so文件。 我把armeabi的目录,只剩下腾讯x5内核的"liblbs.so"文件。用除了我手里的华为4A的,设备来安装apk, 非armeabi基础平台的设备,都能顺利加载x5内核。这是其次,最重要的是 armeabi目录删除的所有.so包的,功能存在。 结论:手机读取了对应手机平台的.so, 找不到"liblbs.so"的时候, 才去armeabi目录,找它。这样就很完美。符合提前提出的 疑问②。 ①集成X5的APP, 第一次安装,多数手机是加载X5内核失败,取到sys core。 ②back back 关闭应用,再打开仍然失败。要按 任务,“划掉“这个进程任务才成功。哎,这点,腾讯又不说,怎么做了。 ① 启动 TBSDemo,等待几秒钟后看到提示框“x5内核安装成功,是否重启”,此时点击“重启” . 这句话是引用腾讯X5内核SDK接入文档(http://x5.tencent.com/doc?id=1003) ②重启体验不好吧,最后使用的方案是在 "关闭APP首页",时候彻底关闭这个进程。 @Overridepublic voidonBackPressed() { //是否新装应用、或者刚更新到本次版本的应用 booleanisFist4Video = SharePreferenceUtil.getBooleanDataByKey(this,"isFist4Video", true); if(isFist4Video){ SharePreferenceUtil.(this,"isFist4Video", false); android.os.Process.killProcess(android.os.Process.myPid()); super.onBackPressed(); } super.onBackPressed();  } ③上述虽然解决了,第一次安装,不用关闭进程,而让用户back首页关闭应用而杀进程。然而体验并不是非常好。 (这玩意测试过,对是否有问题,没有影响。只是第二次就好) 合作伙伴微信,手机QQ,QQ空间,京东58,同城,搜狐视频,新浪新闻 这些”合作伙伴“,别人都是安装完,就正常使用的?如何做到呢?朋友们,一起讨论哦。

⑺ 越狱机不能安装abi maps吗

MAPS是一套促销员管理系统,简称MAPS。 SPR(促销员)通过手机进行签到和上报促销销量,对应主管PTL/PTA(促销主管/促销助理)可通过后台管理系统或手机查看促销员考勤和销量情况,监控并分配下属SPR的工作。

⑻ 如何创建Android库以及Android aar文件详解

创建 Android 库

Android 库在结构上与 Android 应用模块相同。它可以提供构建应用所需的一切内容,包括源代码、资源文件和 Android 清单。不过,Android 库将编译到您可以用作 Android 应用模块依赖项的 Android 归档 (AAR:Android Archive Resource) 文件,而不是在设备上运行的 APK。与 JAR 文件不同,AAR 文件可以包含 Android 资源和一个清单文件,这样,除了 Java 类与方法外,您还可以捆绑布局和可绘制对象等共享资源。

库模块在以下情况下非常有用:

构建使用某些相同组件(例如 Activity、服务或 UI 布局)的多个应用。

构建存在多个 APK 变体(例如免费版本和付费版本)的应用并且需要在两种版本中使用相同的核心组件。在任何一种情况下,只需要将您希望重用的文件移动到库模块中,然后以依赖项的形式为每个应用模块添加库。本页面将说明如何执行这两个操作。

创建库模块

要在您的项目中创建一个新的库模块,请按以下步骤操作:1、点击** File > New > New Mole。**2、在出现的 Create New Mole 窗口中,依次点击** Android Library 和 Next。还存在一个用于创建 Java 库的选项,可以构建传统的 JAR 文件。尽管 JAR 文件在大多数项目中都非常实用(尤其在您希望与其他平台共享代码时),但这种文件不允许您包含 Android 资源或清单文件,而后者对于 Android 项目中的代码重用非常有用。**因此,本指南将侧重论述创建 Android 库。3、为您的库命名,并为库中代码选择一个最低的 SDK 版本,然后点击 Finish。

在 Gradle 项目同步完成后,库模块将显示左侧的 Project 面板中。如果您未看到新模块文件夹,请确保将视图切换为 Android 视图。

将应用模块转换为库模块

如果您现有的应用模块包含您希望重用的所有代码,则可以按照以下步骤将其转换为库模块:

1、打开现有应用模块的 build.gradle 文件。您应在顶部看到以下内容:

apply plugin: 'com.android.application'

2、按照下面所示更改插件分配:

apply plugin: 'com.android.library'

3、点击 Sync Project with Gradle Files。

就这么简单。模块的整个结构仍然相同,但是现在它将作为 Android 库运行,构建也将创建一个 AAR 文件,而不是 APK。

生成aar

在Android Studio1.4中,New project,先默认新建一个Applicaton mole,接后File > New > New Mole,选择Androd Library > Next,指定Library Name和Mole Name。

新建的Library与正常的Application最大区别是mole build.gradle中是**apply plugin: ‘com.android.library’ **而不是 apply plugin: 'com.android.application'

Build > Make project,自动生成aar文件。

以依赖项形式添加您的库

要在另一个应用模块中使用您的 Android 库的代码,请按以下步骤操作:

1、通过两种方式之一将库添加到您的项目(如果您是在相同项目中创建的库模块,则该模块已经存在,您可以跳过此步骤):

添加已编译的 AAR(或 JAR)文件:1、点击 File > New Mole。2、依次点击 Import .JAR/.AAR Package 和** Next**。3、输入 AAR 或 JAR 文件的位置,然后点击 Finish。

将库模块导入到您的项目中:1、点击** File > New > Import Mole。**2、输入库模块目录的位置,然后点击 Finish。库模块将复制到您的项目中,因此您可以尽管编辑库代码。如果您希望维护一个版本的库代码,则此方法可能不是您想要的,您应按照上文所述导入编译的 AAR 文件。

2、确保库列在您 settings.gradle 文件的顶部,如下面名为“my-library-mole”的库所示:

include ':app', ':my-library-mole'

3、打开应用模块的 build.gradle 文件,并向 dependencies 块中添加一行新代码,如下面的片段所示:

dependencies { compile project(":my-library-mole")}

4、点击 Sync Project with Gradle Files。在上面的示例中,名为 my-library- mole 的 Android 库模块成为 build.gradle 文件所在模块的构建依赖项。您的应用模块现在可以访问 Android 库中的任何代码和资源,库 AAR 文件在构建时已捆绑到您的 APK 中。不过,如果希望单独共享 AAR 文件,则可以在 项目名称/模块名称/build/outputs/aar/ 中找到它,也可以通过点击 Build > Make Project 的方式重新生成此文件。

选择要设为公开的资源

库中的所有资源在默认情况下均处于公开状态。要将所有资源隐式设为私有,您必须至少将一个特定的属性定义为公开。资源包括您项目的 res/ 目录中的所有文件,例如图像。要阻止您的库用户访问仅供内部使用的资源,您应通过声明一个或多个公开资源的方式来使用这种自动私有标识机制。

要删除某个公开资源,请将一个声明添加到您的库的 public.xml文件中。如果您之前尚未添加公开资源,则需要在您的库的 res/values/目录中创建public.xml 文件。

下面的示例代码可以创建两个名称分别为 mylib_app_name和 mylib_public_string 的公开字符串资源:

<resources> <public name="mylib_app_name" type="string"/> <public name="mylib_public_string" type="string"/></resources>“`如果希望任何资源保持对使用您的库的开发者可见,您应当将其设为公开。例如,尽管 [v7 appcompat 库](https://developer.android.com/topic/libraries/support-library/features.html#v7-appcompat)中的大多数资源都是私有资源,但是为了支持[Material Design](https://developer.android.com/design/material/index.html),控制工具栏小部件的属性应当公开。将属性隐式设为私有不仅可以阻止您的库用户从内部库资源获得代码自动完成建议,还让您能够在不中断您的库客户端的情况下重命名或移除私有资源。私有资源不在代码自动完成和 [Theme Editor](https://developer.android.com/studio/write/theme-editor.html) 的作用范围内,并且如果您尝试引用私有资源,[Lint](https://developer.android.com/studio/write/lint.html) 将显示警告。##开发注意事项在开发您的库模块和相关应用时,请注意以下行为和限制。将库模块引用添加至您的 Android 应用模块后,您可以设置它们的相对优先级。构建时,库会按照一次一个的方式与应用合并,并按照从低到高的优先级顺序。* **资源合并冲突**构建工具会将库模块中的资源与相关应用模块的资源合并。如果在两个模块中均定义了给定资源 ID,将使用应用中的资源。如果多个 AAR 库之间发生冲突,将使用依赖项列表首先列出(位于 dependencies块顶部)的库中的资源。为了避免常用资源 ID 的资源冲突,请使用在模块(或在所有项目模块)中具有唯一性的前缀或其他一致的命名方案。* **库模块可以包含 JAR 库**您可以开发一个自身包含 JAR 库的库模块;不过,您需要手动编辑相关应用模块的构建路径,并添加 JAR 文件的路径。* **库模块可以依赖外部 JAR 库**您可以开发一个依赖于外部库(例如 Maps 外部库)的库模块。在这种情况下,相关应用必须针对包含外部库(例如 Google API 插件)的目标构建。另外也要注意,库模块和相关应用都必须在其清单文件的 [<uses- library>](https://developer.android.com/guide/topics/manifest/uses-library-element.html) 元素中声明外部库。* **库模块不得包含原始资源**工具不支持在库模块中使用原始资源文件(保存在 assets/目录中)。应用使用的任何原始资源都必须存储在应用模块自身的 assets/目录中。* **应用模块的 minSdkVersion必须大于或等于库定义的版本**库作为相关应用模块的一部分编译,因此,库模块中使用的 API 必须与应用模块支持的平台版本兼容。* **每个库模块都会创建自己的 R 类**在您构建相关应用模块时,库模块将先编译到 AAR 文件中,然后再添加到应用模块中。因此,每个库都有其自己的 R 类,并根据库的软件包名称命名。从主模块和库模块生成的 R 类会在所需的所有软件包(包括主模块的软件包和库的软件包)中创建。* **库模块可能包含自己的 ProGuard 配置文件**通过将 [ProGuard](https://developer.android.com/studio/build/shrink-code.html) 配置文件添加到包含其 ProGuard 指令的库,您可以在自己的库上启用代码压缩。构建工具会为库模块将此文件嵌入到生成的 AAR 文件中。在您将库添加到应用模块时,库的 ProGuard 文件将附加至应用模块的 ProGuard 配置文件 (proguard.txt)。通过将 ProGuard 文件嵌入到您的库模块中,您可以确保依赖于此库的应用模块不必手动更新其 ProGuard 文件即可使用库。当 ProGuard 在 Android 应用模块上运行时,它会同时使用来自应用模块和库的指令,因此您不应当只在库上运行 ProGuard。要指定您的库的配置文件名称,请将其添加到 consumerProguardFiles方法中,此方法位于您的库的 build.gradle文件的 defaultConfig块内。例如,以下片段会将 lib-proguard-rules.txt设置为库的 ProGuard 配置文件:

android {defaultConfig {consumerProguardFiles 'lib-proguard-rules.txt'}…}

默认情况下,应用模块会使用库的发布构建,即使在使用应用模块的调试构建类型时亦是如此。要使用库中不同的构建类型,您必须将依赖项添加到应用的 build.gradle文件的 dependencies块中,并在库的 build.gradle文件中将 publishNonDefault设置为 true。例如,您应用的 build.gradle文件中的以下代码段会使应用在应用模块于调试模式下构建时使用库的调试构建类型,以及在应用模块于发布模式下构建时使用库的发布构建类型:

dependencies {debugCompile project(path: ':library', configuration: 'debug')releaseCompile project(path: ':library', configuration: 'release')}

您还必须在自己库的 build.gradle文件的 android 块内添加以下代码行,以便将此库的非发布配置展示给使用它的项目:

android {…publishNonDefault true}“`不过请注意,设置 publishNonDefault会增加构建时间。为了确保您的库的 ProGuard 规则不会将意外的压缩副作用施加到应用模块,请仅包含适当规则,停用不适用于此库的 ProGuard 功能。尝试协助开发者的规则可能会与应用模块或它的其他库中的现有代码冲突,因此不应包含这些规则。例如,您的库的 ProGuard 文件可以指定在应用模块的压缩期间需要保留的代码。

注:Jack 工具链仅支持 ProGuard 的部分压缩和模糊选项。

AAR 文件详解

AAR 文件的文件扩展名为 .aar,Maven 工件类型也应当是 aar。文件本身是一个包含以下强制性条目的 zip文件:

/AndroidManifest.xml

/classes.jar

/res/

/R.txt

此外,AAR 文件可能包含以下可选条目中的一个或多个:

/assets/

/libs/**名称 **.jar

/jni/abi 名称 /名称.so(其中 abi 名称是 Android 支持的 ABI 之一)

/proguard.txt

/lint.jar


赞 (0)