当前位置:首页 » 安卓系统 » android不混淆包

android不混淆包

发布时间: 2022-04-23 21:17:14

A. android中为什么要指定第三方包的中内容不混淆呢/

其实第三方jar包是不能混淆,这里指定第三方jar包不混淆的意思是,在你的项目中的调用到第三方jar包的语句不被混淆,你想想,如果jar包是com.umeng,你调用的地方被混淆成了a.b,这样你生成的apk里面不是找不到a.b了么,肯定会报错撒

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

为了解决第三方包不被混淆,第三方包在混淆后,运行的时候会挂掉。我的错误是java.lang.ExceptionInInitializerError

[java] E/AndroidRuntime( 9608):
java.lang.ExceptionInInitializerError
E/AndroidRuntime( 9608): at
a.a.b.f.<init>(Unknown Source)
E/AndroidRuntime( 9608): at
a.a.b.e.<init>(Unknown Source)
E/AndroidRuntime( 9608): at
a.a.c.dg.b(Unknown Source)
E/AndroidRuntime( 9608): at
a.a.c.dg.a(Unknown Source)
E/AndroidRuntime( 9608): at
a.a.c.b.a(Unknown Source)
E/AndroidRuntime( 9608): at
a.a.c.ad.a(Unknown Source)

………………………………………………………………………………中间部分省略
最终我通过 加LOG的调试方法定位到是由于第三方jar包被混淆后的原因导致的。

解决方法:
在proguard-android.txt文件最后加入了-keep class org.jsoup.**这样一句代码,就是保持这个类不被混淆

附上proguard-android.txt源文件[html] # This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

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

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

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

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

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**

-keep class org.jsoup.**

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

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

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

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

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

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**

-keep class org.jsoup.**

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

第三方jar包避免混淆用下面的方法:
在proguard-project.txt 文件中加入:
-ignorewarnings
-libraryjars libs/XX (“XX”是jar包名)
-libraryjars libs/XX
-libraryjars libs/XX



例如:混淆android-support-v4.jar
-ignorewarnings
-libraryjars libs/android-support-v4.jar

D. android 怎么实现只混淆自己的代码,而不混淆第3方

混淆打包流程: 1在proguard-projecttxt文件中添加不需要混淆的类和第三方的jar包 这个是保持自己包中不需要混淆的类,如果有些类调用了jni也不需要混淆,不然会出错。还有如果项目中有其他项目作为library引入,那这些项目的一些类也不能混淆android 怎么实现只混淆自己的代码,而不混淆第3方

E. android 不混淆代码要怎么使用Robust

什么是代码混淆:
    Android SDK 自带了混淆工具Proguard。它位于SDK根目录\tools\proguard下面。如果开启了混淆,Proguard默认情况下会对所有代码,包括第三方包都进行混淆,可是有些代码或者第三方包是不能混淆的,这就需要我们手动编写混淆规则来保持不能被混淆的部分。

为什么要混淆:
优化java的字节码
减小apk文件的大小,在混淆过程中会删除未使用过的类和成员
代码安全,使类、函数、变量名随机变成无意义的代号形如:a,b,c...之类。防止app被反编译之后能够很容易的看懂代码

F. Android如何保持指定类不被混淆

包名 package com.example.test
类名 public class WebAppInterface{}
加上完整的包名才行。
-keep class com.example.test.WebAppInterface {*;}

G. 为什么这么多商业Android开发者不混淆代码

代码混淆技术基本原理是使反编译工具反编译出来的代码人难以阅读,从而达到防止被逆向破解的目的。PC上的代码混淆技术已经很成熟,有加花指令、多态变形等技术手法,Android代码混淆技术才刚刚起步,目前已知的技术手法如下。
Java类名、方法名混淆
Dalvik字节码包含了大量的调试信息,如类名、方法名、字段名、参数名、变量名等,使用反编译工具可以还原这些信息。由于类名、方法名等通常都会遵循一定的命名规范,破解者很容易根据这些信息来猜测代码功能,阅读起来就跟查看源代码一样。从Android 2.3开始,Google在SDK中加入了一款叫ProGuard的代码混淆工具,ProGuard会删除这些调试信息,并用无意义的字符序列来替换类名、方法名等,使得使用反编译出来的代码难以阅读,提升逆向难度。使用ProGuard混淆过过后,反编译出来的类名和方法名无法阅读,但是反编译出来的功能代码仍然是非常容易阅读的,和源代码差不多,破解者仍通过阅读功能代码来自行标记类名、方法名等,然后逆向破解。[2]
Java代码混淆
通过对功能代码流程进行乱序混淆,实际运行时乱序混淆后的代码流程却和原始代码流程是一样的,但反编译出来的代码流程静态阅读时与原始流程有很大差异,使破解者很难通过静态分析理解代码功能,从而保护代码不被逆向分析。比如,原始的代码流程是1->2->3->4->5->6->7,经过乱序混淆后静态反汇编查看到的代码流程可能变成2->7->5->1->6->4->3,实际运行时代码流程仍然是1->2->3->4->5->6->7。目前使用这种代码混淆技术的Android保护工具有APKProtect。[1]

H. 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.** 警告信息并没有减少,打包会失败。

I. android 不混淆可以打包吗

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

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

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

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

J. android 不混淆类和类中的变量名

指定某个包下的所有class不混淆
-keep class com.custom.view.** { *; }

热点内容
编译器对系统的依赖 发布:2025-05-16 08:37:29 浏览:709
javamap数组 发布:2025-05-16 08:37:28 浏览:450
移动光猫如何自行修改密码 发布:2025-05-16 08:20:15 浏览:124
作为基线存储 发布:2025-05-16 08:15:22 浏览:858
安卓怎么关闭手机应用推荐 发布:2025-05-16 08:03:38 浏览:929
sql内置函数 发布:2025-05-16 08:03:34 浏览:922
怎么看服务器内存型号 发布:2025-05-16 08:03:30 浏览:812
哪里修安卓手机最好 发布:2025-05-16 07:58:25 浏览:825
服务器和电脑是什么区别 发布:2025-05-16 07:58:24 浏览:720
安卓116是什么意思 发布:2025-05-16 07:44:59 浏览:591