标签: android-proguard

如何使用Proguard缩小Android代码

由于我在我的应用程序中使用了很多依赖项,因此我达到了65k方法限制(我达到了76k方法).我在android.developer上读过,proguard用于缩小代码.

那么 - proguard只会缩小我的应用程序代码还是缩小我的依赖项代码呢?使用proguard缩小代码时,是否需要警惕某些事情?我怎么做?

我的Gradle Build:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "some.Path"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
}

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

configurations {
compile.exclude group:  'org.apache.xmlbeans'
}

repositories {
maven { url "https://jitpack.io" } …
Run Code Online (Sandbox Code Playgroud)

android dex-limit android-proguard

0
推荐指数
1
解决办法
3118
查看次数

如何在发布模式下导出APK时解决以下错误?

    :app:proguardDebug
Warning:com.google.common.base.Absent: can't find referenced class javax.annotation.Nullable

Warning:com.google.common.collect.Collections2: can't find referenced class javax.annotation.Nullable

Warning:com.google.common.collect.Tables$UnmodifiableTable: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeBasedTable$TreeRow: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultimap: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultiset: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultiset$Aggregate: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultiset$Aggregate$1: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultiset$Aggregate$2: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultiset$AvlNode: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeMultiset$Reference: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeRangeMap: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeRangeMap$1: can't find referenced class javax.annotation.Nullable
Warning:com.google.common.collect.TreeRangeMap$AsMapOfRanges: …
Run Code Online (Sandbox Code Playgroud)

android android-proguard

0
推荐指数
1
解决办法
2746
查看次数

如何判断我是否使用 Proguard 来混淆我的代码?

我有一个从 Eclipse 迁移到 Android-Studio 的应用程序。我想确保我在发布版本中使用 Proguard。我在 build.gradle 文件中看到:

 buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
Run Code Online (Sandbox Code Playgroud)

但是,我的项目文件夹中没有 proguard-android.txt 或 proguard-rules.txt。我的代码被混淆了吗?

android proguard android-proguard

0
推荐指数
1
解决办法
1655
查看次数

如何保留类具有本机函数

如果类中有本机函数,是否可以告诉 ProGuard 完全跳过该类?

-keepclasseswithmembernames class * { native <methods>; }
Run Code Online (Sandbox Code Playgroud)

上面对我不起作用,因为它保留了类名称和本机函数名称,但混淆了其他成员

我想知道是否可以将所有内容保留在此类中,而无需显式指定每个类

谢谢

android proguard android-proguard

0
推荐指数
1
解决办法
3388
查看次数

应用程序崩溃时将minifyEnabled设置为true

我正在使用greendao + sqlcipher并helper.getEncryptedWritableDb("sdfbdfsjkdjkf"); 使用proguard 创建加密数据库并添加了规则

### greenDAO 3
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties

# If you do not use SQLCipher:
-dontwarn org.greenrobot.greendao.database.**
# If you do not use RxJava:
-dontwarn rx.**

### greenDAO 2
-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties




#######################################################################






-keep public class net.sqlcipher.** {
    *;
}

-keep public class net.sqlcipher.database.** {
    *;
}
Run Code Online (Sandbox Code Playgroud)

我将minifyEnabled设置为true的那一刻.我的应用程序在安装后启动时崩溃.

debug {


            shrinkResources false
            minifyEnabled false …
Run Code Online (Sandbox Code Playgroud)

java-native-interface android sqlcipher greendao android-proguard

-1
推荐指数
1
解决办法
844
查看次数