使用谷歌播放的,services_lib加入AdMob的广告后,Android应用程序的大小增加 [英] Android app size increased after adding admob ads using google-play-services_lib

查看:184
本文介绍了使用谷歌播放的,services_lib加入AdMob的广告后,Android应用程序的大小增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要发布两个版本我的应用程序,免费或付费(与AdMob的广告)。
这两个版本除了谷歌播放-service_lib,我在免费版本AdMob的服务中使用完全相同。

I'm gonna publishing my app in two versions, both paid and free (with AdMob ads).
The two versions are exactly identical except for the google-play-service_lib that i use in the free version for AdMob services.

使用的ProGuard后的最终apk文件大小:
1.301.435字节为付费版本
1.946.634字节为广告版本

The final apk sizes after using proguard are:
1.301.435 bytes for paid version
1.946.634 bytes for ads version

在免费版本我展示插播式广告而已。

In free version i show interstitial ads only.

下面是我的相对于谷歌的播放,service_lib

Here's my proguard settings relative to the google-play-service_lib

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

有什么我可以做,以减少类似删除一些-keep标志还是什么文件的大小?

Is there something i can do to reduce file size like removing some -keep flags or what?

修改

使用 apktool 我发现的类都从谷歌Play业务包已收缩(包括 com.google.android.gms.maps。* com.google.android.gms.games。* 和许多其他人,我不需要为广告管理认为)。

Using apktool i discovered that none of the classes from the Google Play Service package has been shrinked (including com.google.android.gms.maps.*, com.google.android.gms.games.* and many others that i think are not needed for Ads management).

如何强制收缩类或A类组?

How to force shrink a class or a class group?

编辑(再次)

它看起来像Eclipse不守Proguard的输出,至少我看不到它的任何地方。然后我配置我的项目和库使用Ant看到一些输出为建立,但它几乎是薄弱的,这有两种情况:

It looks like Eclipse doesn't keep Proguard output, at least i couldn't see it anywhere. I then configured my projects and libs to be build using Ant to see some output, but it's almost unsubstantial, these are two cases:

 -whyareyoukeeping class com.google.android.gms.maps.GoogleMap

 [proguard] Explaining why classes and class members are being kept...
 [proguard] Printing usage to [...../bin/proguard/usage.txt]...
 [proguard] com.google.android.gms.maps.GoogleMap
 [proguard]   is not being kept.

(至少我读了类没有兑现,但我可以看到它使用apktool!)和

(at least i read that class is not been kept, although i can see it using apktool!) and

 -whyareyoukeeping class com.google.android.gms.games.Games

 [proguard] Explaining why classes and class members are being kept...
 [proguard] Printing usage to [...../bin/proguard/usage.txt]...

在这里什么也没有说,大约给定的类。

here nothing is said about given class.

我放弃,换单间我的应用程序由50%增加他的身材,虽然谷歌关于GPS 状态:

I'm giving up, for a single interstitial my app increases his size by 50%, although Google about GPS states:

客户端库有一个光的足迹,如果您使用的ProGuard的一部分   你的构建过程中,所以不会有产生不利影响您的   应用程序的文件大小。

The client library has a light footprint if you use ProGuard as part of your build process, so it won't have an adverse impact on your app's file size.

和没有在那里我能找到一个指导吧!

and no-where i could find a guide for it!

推荐答案

这是没有任何关系的ProGuard。 如你所知,谷歌Play业务已经接近源头。没有源ProGuard的不能处理它 code。但您可以手动缩水了。

it is nothing to do with proguard. as you know, google play service is close source. proguard can't handle it without source code. but you can shrink it manually.

1,从jar文件中删除未使用的类

1, remove unused class from jar file

的谷歌播放服务的文件夹中,通常SDK \演员\谷歌\ google_play_services \ libproject \谷歌播放services_lib \库\ 打开谷歌播放services.jar 与压缩文件管理器,如7zip的,你可以找到许多 文件夹,例如地图,游戏等等巫是没有用的你,如果你只使用广告。所以只 删除它们。谨守遵行的广告,常见的,动态的,内部位置的NoClassDefFoundError的文件夹中,否则你将得到FC时显示的广告。

in the folder of google play service, typically sdk\extras\google\google_play_services \libproject\google-play-services_lib\libs\, open google-play-services.jar with zip file manager such as 7zip, you can find many folder such as maps, games and so on witch is no use for you if you only use ads. so just delete them. be careful to keep ads, common, dynamic, internal and location folder otherwise you will get fc of NoClassDefFoundError when show ads.

2,从资源文件夹中删除未使用的资源,如果你只使用广告。

2, remove unused resource from res folder if you only use ads.

在谷歌播放,services_lib \ res文件夹多的资源是没有用的,你可以将其删除。如价值观-AF,价值观时许,......你需要保持的是颜色,绘制,绘制,华电国际文件夹。

many resource in google-play-services_lib\res folder is no use for you, you can remove it. such as values-af, values-am, .... what you need to keep is color, drawable, drawable-hdpi and values folder.

3,现在刷新并建立在Eclipse的谷歌播放的,services_lib项目,然后刷新 并重新生成项目。现在你shold找到APK尺寸变得越来越小。的大小我 APK从 902KB 去到 480KB ProGuard的面前,和 330KB 的ProGuard后。

3, now refresh and build the google-play-services_lib project in your eclipse, then refresh and build your project again. now you shold find the apk size get smaller. the size of my apk go down from 902kb to 480kb before proguard, and 330kb after proguard.

这篇关于使用谷歌播放的,services_lib加入AdMob的广告后,Android应用程序的大小增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆