proguard-project.txt文件,减少谷歌播放业务“的APK大小的影响
2015-11-13 14:43
465 查看
今天在做admob,由于Google service_lib 太大,引用进来,发现生成的apk实在是太大了,查资料,找到 一点
资料名称:减少谷歌播放业务“的APK大小的影响
连接地址:http://googleadsdeveloper.blogspot.in/2015/01/reducing-google-play-services-impact-on.html
浏览条件:翻墙
里面的有方法。。。。。
遇到第一种方法:Split JAR
Architecture
Beginning with Google Play services 6.5, additional maven artifacts have been added to the Google Repository that contain single domains of functionality. This means that you can include just those portions of Google Play services that your app uses. For example,
here’s how to configure gradle to incorporate the JAR that contains functionality relating to ads:
That line instructs gradle to include everything Mobile Ads developers need, with the exception of the IMA
SDK JAR needed for IMA applications.
Please note that if you currently initialize Mobile Ads SDK banner ads via XML layout files, you should continue including the full Google Play services artifact. See this
blog post for more information.
点进去看一下:发现是要:To prevent ProGuard from
stripping away required classes, add the following lines in the
说一下:
关于使用还是很容易的,只要将eclipse项目中project.properties文件中的
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
前的注释#放开即可,然后右击项目-->Android Tools-->Export Signed/Unsigned Application Package。再慢慢下一步就可以了。
通常情况下,我们只需要作以上几步操作就能满足需求,如果有一些特殊要求,某些类或者jar包不需要混淆,这个时候就需要修改proguard-project.txt文件了。以下是网上搜索的网友分享的经验:
1.在proguard-project.txt文件中添加不需要混淆的类和第三方的jar包
![](https://oscdn.geek-share.com/Uploads/Images/Content/201511/a55302ff514956959af2e6c2b3da6b3b)
这个是保持自己包中不需要混淆的类,如果有些类调用了jni也不需要混淆,不然会出错。还有如果项目中有其他项目作为library引入,那这些项目的一些类也不能混淆。
![](https://oscdn.geek-share.com/Uploads/Images/Content/201511/9cdf793082d113ea89ca1dc4d99e6c00)
这个是保持项目中的第三方jar不混淆
![](https://oscdn.geek-share.com/Uploads/Images/Content/201511/f41213ce39d8c906d7e8424582ef5e90)
另外加上上面几句话,不然会在控制台中报warning警告
2.另外还有其他一些经验:
-injars androidtest.jar【jar包所在地址】
-outjars out【输出地址】
-libraryjars 'D:\android-sdk-windows\platforms\android-9\android.jar' 【引用的库的jar,用于解析injars所指定的jar类】
-optimizationpasses 5
-dontusemixedcaseclassnames 【混淆时不会产生形形色色的类名 】
-dontskipnonpubliclibraryclasses 【指定不去忽略非公共的库类。 】
-dontpreverify 【不预校验】
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 【优化】
-keep public class * extends android.app.Activity 【不进行混淆保持原样】
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep public abstract interface com.asqw.android.Listener{
public protected <methods>; 【所有方法不进行混淆】
}
-keep public class com.asqw.android{
public void Start(java.lang.String); 【对该方法不进行混淆】
}
-keepclasseswithmembernames class * { 【保护指定的类和类的成员的名称,如果所有指定的类成员出席(在压缩步骤之后)】
native <methods>;
}
-keepclasseswithmembers class * { 【保护指定的类和类的成员,但条件是所有指定的类和类成员是要存在。】
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {【保护指定类的成员,如果此类受到保护他们会保护的更好 】
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {【保护指定的类文件和类的成员】
public static final android.os.Parcelable$Creator *;
}
3.http://www.apkbus.com/android-131995-1-1.html
资料名称:减少谷歌播放业务“的APK大小的影响
连接地址:http://googleadsdeveloper.blogspot.in/2015/01/reducing-google-play-services-impact-on.html
浏览条件:翻墙
里面的有方法。。。。。
遇到第一种方法:Split JAR
Architecture
Beginning with Google Play services 6.5, additional maven artifacts have been added to the Google Repository that contain single domains of functionality. This means that you can include just those portions of Google Play services that your app uses. For example,
here’s how to configure gradle to incorporate the JAR that contains functionality relating to ads:
dependencies { compile 'com.google.android.gms:play-services-ads:6.5.+' }
That line instructs gradle to include everything Mobile Ads developers need, with the exception of the IMA
SDK JAR needed for IMA applications.
Please note that if you currently initialize Mobile Ads SDK banner ads via XML layout files, you should continue including the full Google Play services artifact. See this
blog post for more information.
点进去看一下:发现是要:To prevent ProGuard from
stripping away required classes, add the following lines in the
/proguard-project.txtfile:
说一下:
proguard-project.txtfile:
关于使用还是很容易的,只要将eclipse项目中project.properties文件中的
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
前的注释#放开即可,然后右击项目-->Android Tools-->Export Signed/Unsigned Application Package。再慢慢下一步就可以了。
通常情况下,我们只需要作以上几步操作就能满足需求,如果有一些特殊要求,某些类或者jar包不需要混淆,这个时候就需要修改proguard-project.txt文件了。以下是网上搜索的网友分享的经验:
1.在proguard-project.txt文件中添加不需要混淆的类和第三方的jar包
这个是保持自己包中不需要混淆的类,如果有些类调用了jni也不需要混淆,不然会出错。还有如果项目中有其他项目作为library引入,那这些项目的一些类也不能混淆。
这个是保持项目中的第三方jar不混淆
另外加上上面几句话,不然会在控制台中报warning警告
2.另外还有其他一些经验:
-injars androidtest.jar【jar包所在地址】
-outjars out【输出地址】
-libraryjars 'D:\android-sdk-windows\platforms\android-9\android.jar' 【引用的库的jar,用于解析injars所指定的jar类】
-optimizationpasses 5
-dontusemixedcaseclassnames 【混淆时不会产生形形色色的类名 】
-dontskipnonpubliclibraryclasses 【指定不去忽略非公共的库类。 】
-dontpreverify 【不预校验】
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 【优化】
-keep public class * extends android.app.Activity 【不进行混淆保持原样】
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep public abstract interface com.asqw.android.Listener{
public protected <methods>; 【所有方法不进行混淆】
}
-keep public class com.asqw.android{
public void Start(java.lang.String); 【对该方法不进行混淆】
}
-keepclasseswithmembernames class * { 【保护指定的类和类的成员的名称,如果所有指定的类成员出席(在压缩步骤之后)】
native <methods>;
}
-keepclasseswithmembers class * { 【保护指定的类和类的成员,但条件是所有指定的类和类成员是要存在。】
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {【保护指定类的成员,如果此类受到保护他们会保护的更好 】
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {【保护指定的类文件和类的成员】
public static final android.os.Parcelable$Creator *;
}
3.http://www.apkbus.com/android-131995-1-1.html
相关文章推荐
- android 代码混淆示例
- android用eclips混淆打包
- 实现简单购物车功能
- python 99乘法口诀表
- sdk流程图
- 可加载异步图片的圆形imageView结合imageLoader
- Linux J2EE环境搭建 1、U盘/光盘挂载
- Swift
- jquery cookie 删除不了的处理办法
- centos下fail2ban安装与配置详解
- oracle-行转列 oracle11g sql新功能pivot/unpivot
- maya中使用python改变选中物体线框颜色
- Android属性动画完全解析(上)
- 什么是backport
- js封装对象
- 运维 2.0 时代:数据聚合和分组
- java jxl处理Excel学习地址
- 你追我赶进度条
- 为你的linux虚拟机减减肥
- MySQL在字段中使用select子查询