Libgdx启用proguard
我一直想启用proguard已有很长一段时间了,但这似乎很麻烦 但我在想,如果只允许proguard删除程序不使用的类,我有一个重量接近25mb的简单游戏,我甚至没有2mb的资产,我不关心混淆 这应该更容易实现,对吗?因为启用proguard时的大多数错误都是由于混淆造成的 我能做这个吗?怎么做 谢谢 编辑:Libgdx启用proguard,libgdx,proguard,Libgdx,Proguard,我一直想启用proguard已有很长一段时间了,但这似乎很麻烦 但我在想,如果只允许proguard删除程序不使用的类,我有一个重量接近25mb的简单游戏,我甚至没有2mb的资产,我不关心混淆 这应该更容易实现,对吗?因为启用proguard时的大多数错误都是由于混淆造成的 我能做这个吗?怎么做 谢谢 编辑: buildscript { repositories { mavenLocal() mavenCentral() maven { u
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"
}
我使用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"
}
将此添加到android应用程序模块中。具有预构建
proguard project.txt
文件的应用程序模块,该文件具有适用于libgdx项目的proguard规则
buildTypes {
release {
minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
proguardFile 'proguard-project.txt'
}
}
在project.properties文件中取消提交此行
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
希望你不使用皮肤,有些时候皮肤会产生问题,因为从jj../p>PROGORD中提取的对象主要用于混淆,但是如果你考虑它的大小,它只会减少2-3兆字节。如何使用25 mb和2 mb的资产。我有10 mb的.apk和7.5 mb的资产。@AbhishekAryan我不知道,我猜google play服务lib add大约7mb,我只在admob ads上使用它。我也在使用google play服务的ads子模块,
com.google.android.gms:play services ads:10.0.1
,但对于libGDX项目仍然有25MB的问题。@AbhishekAryan好的,所以我现在仔细检查了一下,当我从google play下载应用程序时,它显示为5.96mb,当安装在应用程序信息中时显示为15.96mb,我90%确定我看到它是25mb,所以这将是数据保存,但仍然是15.96mb和1.76mb的内存assets@AbhishekAryan你所说的google play服务的子模块是什么意思?我刚才把整个库都扔进去了,对不起,如果我听起来很傻,英语不是我的第一语言我正在使用Skin,你能添加如何添加google play服务的子模块而不是所有库吗?告诉我你正在使用google play服务的哪个模块?我如何检查?在哪里?我认为proguard将消除所有不必要的google play服务类,对吗?所以没有必要只添加我使用的google play服务模块。你在google play服务中使用的是什么,比如你在使用广告、google游戏服务或其他什么