android keep class,Android 打包时 Keep 住某些方法或类

# ${android_sdk}/tools/proguard/proguard-android.txt

# Understand the @Keep support annotation.

-keep class android.support.annotation.Keep

-keep @android.support.annotation.Keep class * {*;}

-keepclasseswithmembers class * {

@android.support.annotation.Keep ;

}

-keepclasseswithmembers class * {

@android.support.annotation.Keep ;

}

-keepclasseswithmembers class * {

@android.support.annotation.Keep (...);

}

// android/support/annotation/Keep.java

/**

* Denotes that the annotated element should not be removed when

* the code is minified at build time. This is typically used

* on methods and classes that are accessed only via reflection

* so a compiler may think that the code is unused.

*

* Example:

*

* @Keep

* public void foo() {

* ...

* }

*

*/

@Retention(CLASS)

@Target({PACKAGE,TYPE,ANNOTATION_TYPE,CONSTRUCTOR,METHOD,FIELD})

public @interface Keep {

}

File filters

Like general filters, a file filter is a comma-separated list of file names that can contain wildcards. Only files with matching file names are read (in the case of input jars), or written (in the case of output jars). The following wildcards are supported:

?

matches any single character in a file name.

*****

matches any part of a filename not containing the directory separator.

**

matches any part of a filename, possibly containing any number of directory separators.

For example, "java/**.class,javax/**.class" matches all class files in the java and javax.

Furthermore, a file name can be preceded by an exclamation mark '!' to exclude the file name from further attempts to match with subsequent file names.

For example, "!**.gif,images/**" matches all files in the images directory, except gif files.

Class specifications

A class specification is a template of classes and class members (fields and methods). It is used in the various -keep options and in the -assumenosideeffects option. The corresponding option is only applied to classes and class members that match the template.

The template was designed to look very Java-like, with some extensions for wildcards. To get a feel for the syntax, you should probably look at the examples, but this is an attempt at a complete formal definition:

[@annotationtype] [[!]public|final|abstract|@ ...] [!]interface|class|enum classname

[extends|implements [@annotationtype] classname]

[{

[@annotationtype] [[!]public|private|protected|static|volatile|transient ...] |

(fieldtype fieldname);

[@annotationtype] [[!]public|private|protected|static|synchronized|native|abstract|strictfp ...] |

(argumenttype,...) |

classname(argumenttype,...) |

(returntype methodname(argumenttype,...));

[@annotationtype] [[!]public|private|protected|static ... ] *;

...

}]

Square brackets "[ ]" mean that their contents are optional. Ellipsis dots "..." mean that any number of the preceding items may be specified. A vertical bar "|" delimits two alternatives. Non-bold parentheses "()" just group parts of the specification that belong together. The indentation tries to clarify the intended meaning, but white-space is irrelevant in actual configuration files.

The class keyword refers to any interface or class. The interface keyword restricts matches to interface classes. The enum keyword restricts matches to enumeration classes. Preceding the interface or enum keywords by a ! restricts matches to classes that are not interfaces or enumerations, respectively.

Every classname must be fully qualified, e.g. java.lang.String.Inner classes are separated by a dollar sign "$", e.g. java.lang.Thread$State

. Class names may be specified as regular expressions containing the following wildcards:

?

matches any single character in a class name, but not the package separator. For example, "com.example.Test?" matches "com.example.Test1" and "com.example.Test2", but not "com.example.Test12".

*****

matches any part of a class name not containing the package separator. For example, "com.example.*Test*" matches "com.example.Test" and "com.example.YourTestApplication", but not "com.example.mysubpackage.MyTest". Or, more generally, "com.example.*" matches all classes in "com.example", but not in its subpackages.

**

matches any part of a class name, possibly containing any number of package separators. For example, "**.Test" matches all Test classes in all packages except the root package. Or, "com.example.**" matches all classes in "com.example" and in its subpackages.

matches the n'th matched wildcard in the same option. For example, "com.example.*Foo<1>" matches "com.example.BarFooBar".

For additional flexibility, class names can actually be comma-separated lists of class names, with optional ! negators, just like file name filters. This notation doesn't look very Java-like, so it should be used with moderation.

For convenience and for backward compatibility, the class name * refers to any class, irrespective of its package.

Java编译时根据调用该方法的类或对象所属的类决定

class Base{     int x = 1;     static int y = 2; } class Subclass extends Base{     int x = 4;     i ...

4&period;Android 打包时出现的Android Export aborted because fatal error were founds &lbrack;closed&rsqb;

Android 程序开发完成后,如果要发布到互联网上供别人使用,就需要将自己的程序打包成Android 安装包文件(Android Package,APK),其扩展名为.apk.使用run as 也能 ...

Android自定义属性时TypedArray的使用方法

有时候android传统的页面布局不足以满足我们的需求,常常需要自己定义view,通常继承View,然后重写构造方法以及onDraw等函数,再 具体实现自己定义的复杂view.我们知道在给控件赋属性时 ...

记录一次maven打包时将test目录下的类打包到jar中&comma;Maven Assembly Plugin的使用

今天有人问我打包后找不到主类,运行的类写在test中.按照常规,test目录下的文件不会打包到jar包中.(但是我测试一个springboot工程就可以,这里之后再研究) 具体解决如下 第一步:在po ...

Android studio运行时报错,方法,类找不到,或者JVM内存溢出解决方案

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessExceptio ...

Android退出时关闭所有Activity的方法

Android退出时,有的Activity可能没有被关闭.为了在Android退出时关闭所有的Activity,设计了以下的类: //关闭Activity的类 public class CloseAc ...

Android Studio 打包时 Signature Version 选择V1还是V2 ?

只勾选V2会导致 7.0 以下的安卓机出现 INSTALL_PARSE_FAILED_NO_CERTIFICATES 的问题 ,推荐全选. 解决方案一v1和v2的签名使用1)只勾选v1签名并不会影响什 ...

退出Android程序时清除所有activity的实现方法

思路: 1. 自定义ActivityList管理类,添加删除维护该list; 2.Activity Stack 类似上面: 3.singleTask定义一个Activity为该启动模式,然后当返回时, ...

随机推荐

&num;MySQL for Python&lpar;MySQLdb&rpar; Note

#MySQL for Python(MySQLdb) Note #切记不要在python中创建表,只做增删改查即可. #步骤:(0)引用库 -->(1)创建连接 -->(2)创建游标 -- ...

ImageLoder配置以及使用&lpar;个人阅读使用&rpar;

http://blog.csdn.net/vipzjyno1/article/details/23206387 在gradle添加: compile 'com.nostra13.universalim ...

【转】正确理解PHP程序编译时的错误信息

我们编写程序时,无论怎样小心谨慎,犯错总是在所难免的.这些错误通常会迷惑PHP编译器.如果开发人员无法了解编译器报错信息的含义,那么这些错误信息不仅毫无用处,还会常常让人感到沮丧. 编译PHP脚本时, ...

HA高可用配置

HA 即 (high available)高可用,又被叫做双机热备,用于关键性业务. 简单理解就是,有两台机器A和B,正常是A提供服务,B待命闲置,当A宕机或服务宕掉,会切换至B机器继续提供服务. 下 ...

C&plus;&plus;赋值函数详解

赋值函数        每个类只有一个赋值函数         由于并非所有的对象都会使用拷贝构造函数和赋值函数,程序员可能对这两个函数有些轻视.  1,如果不主动编写拷贝构造函数和赋值函数,编译器将 ...

原子操作(atomic operation)

深入分析Volatile的实现原理 引言 在多线程并发编程中synchronized和Volatile都扮演着重要的角色,Volatile是轻量级的synchronized,它在多处理器开发中保证了共 ...

ER图,以及转化成关系模式

1.找出条件中的实体(矩形),属性(椭圆),关系(菱形)关系分为1:1,1:N,M:N,列出ER图 2. -1:1联系的转换方法 -两个实体分别转化为一个关系模式,属性即是本来的属性 -关系可以与任意 ...

python unittest 测试笔记&lpar;一)

测试最基本的原理就是比较预期结果是否与实际执行结果相同,如果相同则测试成功,否则测试失败. python 单元测试官方文档: [Python: 2.7] (https://docs.python.or ...

&period;28-浅析webpack源码之compiler&period;resolvers

原本该在过WebpackOptionsApply时讲解这个方法的,但是当时一不小心过掉了,所以在这里补上. compiler.resolvers 该对象的三个方法均在WebpackOptionsApp ...

python相关的安装软件

本次安装的系统是WINDOWS系统 一.python3.anaconda和python2 1.准备工具:python3.python2安装包可以直接从官网下载https://www.python.or ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值