导航:首页 > 操作系统 > androidstudio不混淆类

androidstudio不混淆类

发布时间:2023-06-27 06:06:06

android-android怎么实现只混淆自己的代码,而不混淆第3方jar包

当项目中有第3方jar包时,怎么实现混淆打包,而不对第3方包混淆
在项目中有第3方包时打包出错日志:

[2012-06-14 14:14:28 - humei_cc] Proguard returned with error code 1. See console

[2012-06-14 14:14:28 - humei_cc] Note: there were 2068 plicate class definitions.

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard

[2012-06-14 14:14:28 - humei_cc] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans

[2012-06-14 14:14:28 - humei_cc] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans

[2012-06-14 14:14:28 - humei_cc] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException

[2012-06-14 14:14:28 - humei_cc] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.datatransfer.DataSource: can't find referenced class java.awt.datatransfer.DataFlavor

………………………………………………………………………………中间部分省略

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find referenced class java.awt.datatransfer.Clipboard

[2012-06-14 14:14:28 - humei_cc] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find referenced class java.awt.datatransfer.Clipboard

[2012-06-14 14:14:28 - humei_cc] Warning: there were 288 unresolved references to classes or interfaces.

[2012-06-14 14:14:28 - humei_cc] You may need to specify additional library jars (using '-libraryjars'),

[2012-06-14 14:14:28 - humei_cc] or perhaps the '-' option.

[2012-06-14 14:14:28 - humei_cc] java.io.IOException: Please correct the above warnings first.

[2012-06-14 14:14:28 - humei_cc] at proguard.Initializer.execute(Initializer.java:308)

[2012-06-14 14:14:28 - humei_cc] at proguard.ProGuard.initialize(ProGuard.java:210)

[2012-06-14 14:14:28 - humei_cc] at proguard.ProGuard.execute(ProGuard.java:85)

[2012-06-14 14:14:28 - humei_cc] at proguard.ProGuard.main(ProGuard.java:499)
我的proguard.cfg 文件时这样的

-optimizationpasses 5

-dontusemixedcaseclassnames

-

-verbose

-ignorewarnings

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-libraryjars libs/bcprov-jdk15on-147.jar

-libraryjars libs/PanoramaGL.jar

-libraryjars libs/activation.jar

-libraryjars libs/additionnal.jar

-libraryjars libs/mail.jar

-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

-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 *;

}
已经尝试的方案:方案一: 加入-ignorewarnings 可以正常打包了。 能过滤掉警告信息。但是治标不治本,打好的包,在实际运行中用到过的第3方包类库时,均报空指针。方案二:不使用-ignorewarnings 添加-dontwarn java.awt.datatransfer.Transferable.** 警告信息并没有减少,打包会失败。

⑵ Android Studio在真机上运行的APP启动速度特别慢,而通过签名打出的apk安装后app速度却很快怎么回事

Android Studio提供debug和release两种构建类型,默认采用debug类型调试Android项目,debug和release的区别有几个方面:

debug模式的几个特点:

1. 支持断点调试和log信息打印,debuggable属性值为true
2. 使用系统默认的密钥库签署apk文件
3. 没有对apk文件进行代码和资源文件的优化(包括文件压缩、冗余文件删除)
4. 没有对代码进行混淆

release模式需要注意的几个特点:

1. 不支持断点调试,debuggable默认为false
2. 没有压缩类文件代码,minifyEnabled,默认为false
3. 没有压缩资源文件,shrinkResources,默认为false
4. 没有指定自定义签名文件,默认使用系统的密钥库签署apk

真机上直接连接调试,因为没有代码、资源文件进行压缩,同时支持断点调试等原因造成运行缓慢;相反,签名后的apk文件,相对来说比较快,可以深入理解Android Studio构建文件build.gradle配置相关资料

⑶ android 不混淆可以打包吗

可以。
混淆打包流程:
1.在proguard-project.txt文件中添加不需要混淆的类和第三方的jar包

这个是保持自己包中不需要混淆的类,如果有些类调用了jni也不需要混淆,不然会出错。还有如果项目中有其他项目作为library引入,那这些项目的一些类也不能混淆。

这个是保持项目中的第三方jar不混淆

另外加上上面几句话,不然会在控制台中报warning警告

⑷ android studio怎么混淆代码

Android Studio上混淆打包apk方法:
//混淆,新版本是ninifyEnabled不再是runproguard
minifyEnabled true
//加载默认混淆配置文件及自定义混淆 配置
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard.cfg'
设置minifyEnabled true,就会在打包的时候进行代码混淆处理. 其中proguard-android.txt不用管,在sdk目录里面,主要是配置了proguard.cfg文件。
直接在android studio创建项目不会有这个文件,而是 proguard-rules.pro文件,其实一样的,因为项目是从eclipse迁移过来的,之前在eclipse上混淆是 proguard.cfg文件.

⑸ AndroidStudio自带的混淆配置

###########################以下是AndroidStudio自尺液带的混淆配好嫌置协议###############################

-dontusemixedcaseclassnames

-

-verbose

-dontoptimize

-dontpreverify

-keepattributes Annotation
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclassmembers public class * extends android.view.View {
void set ( * );
*** get
();
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class * .R$ {
public static <fields>;
}

-dontwarn android.support.**

-keep class android.support.annotation.Keep

-keep @android.support.annotation.Keep class * {*;}

-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}

-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}

-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}

###########################以友困手下是需要手动的混淆配置协议###############################

-libraryjars "C:Program FilesJavajre1.8.0_151lib t.jar"

-optimizationpasses 5

-dontusemixedcaseclassnames

-ignorewarnings

-keep class com.zhuge.analysis.stat.ZhugeParam{
*;
}
-keep class com.zhuge.analysis.listeners.ZhugeInAppDataListener{
*;
}

阅读全文

与androidstudio不混淆类相关的资料

热点内容
android获取apn 浏览:69
phpfpm进程池 浏览:791
解压掏耳朵音频 浏览:670
爬香山解压 浏览:948
算法导论回溯 浏览:339
开盘指标源码查询 浏览:526
有道云保存服务器出错 浏览:639
生成360文件夹 浏览:1004
图库的文件夹是哪个 浏览:505
程序员为什么药学日语 浏览:423
熟悉linux常用命令 浏览:860
印度外卖小哥是程序员 浏览:413
绍兴程序员开发驻场流程 浏览:546
索纳塔8的压缩比 浏览:16
私有云主要服务器 浏览:939
为什么主题解压那么慢 浏览:862
怎么下载扫描二维码的手机app 浏览:729
云服务器创建私有镜像的时候一定要关机吗 浏览:117
php开发学习门户 浏览:387
传奇游戏服务器怎么设置 浏览:825