【发布时间】:2017-04-10 08:47:38
【问题描述】:
我一直想启用 proguard 很长一段时间,但这似乎很麻烦。
但我在想是否可以只启用 proguard 来删除程序不使用的类,我有一个简单的游戏,重量接近 25mb,我什至没有 2mb 的资产,我不在乎混淆。
这应该更容易实现吧?因为启用 proguard 时的大多数错误都是由于混淆引起的?
我可以这样做吗?怎么样?
谢谢
编辑:
我用 eclipse
build.gradle 文件:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "test"
gdxVersion = '1.9.5'
roboVMVersion = '2.3.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
admobVersion = '10.2.1';
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile "com.google.android.gms:play-services-ads:$admobVersion"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile fileTree(dir: 'libs', include: '*.jar')
}
}
tasks.eclipse.doLast {
delete ".project"
}
【问题讨论】:
-
proguard 主要用于混淆,但如果你考虑它的大小,它只会减少 2-3 mb。 2 mb 的资产如何 25 mb。我有 10 mb 的 .apk 和 7.5 mb 的资产。
-
@AbhishekAryan 我不知道,我猜 google play service lib 添加了 7mb 之类的东西,我只将它用于 admob 广告
-
我也在使用
com.google.android.gms:play-services-ads:10.0.1的 google play 服务的 ads 子模块,但 libGDX 项目仍然需要 25 mb。 -
@AbhishekAryan 好的,所以我现在仔细检查了,当我从 Google Play 下载应用程序时,它显示 5.96 mb,安装在应用程序信息中时显示 15.96mb,我 90% 确定我已经看到它是 25mb,所以这将是数据节省,但仍然是 15.96mb 和 1.76mb 的资产
-
@AbhishekAryan
sub module of google play service是什么意思我只是把整个库扔在那里,对不起,如果我听起来很愚蠢,英语不是我的第一语言