當前位置:首頁 » 安卓系統 » android第三方混淆

android第三方混淆

發布時間: 2022-07-12 02:01:28

Ⅰ android 代碼混淆的時候,怎麼排除第3方Jar包,求教

Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }
這行代碼排除 google的json解析包gson

-keep class 包名.** {*; }
排除自己項目的某個包名,當然可以用來排除第三方jar包的
如-keep class com.yangfuhai.http.** {*; }

Ⅱ Android 類中有第三方是implements方法,怎麼混淆

ndroid工程會看到項目有
project.properties 這個文件就是用來開啟項目是否混淆
proguard-project.txt 這個文件就是記錄了代碼混淆的屬性
要開啟混淆,只需要將project.properties 文件中的
# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt」的「#」去掉就可以了。

Ⅲ 求解:在Android中無法使用混淆後的第三方包問題

本應該暴露出來的參數或者類名被你混淆了,或者你把原來的變數類型改變了 造成變數類型不匹配

Ⅳ android中為什麼要指定第三方包的中內容不混淆呢/

其實第三方jar包是不能混淆,這里指定第三方jar包不混淆的意思是,在你的項目中的調用到第三方jar包的語句不被混淆,你想想,如果jar包是com.umeng,你調用的地方被混淆成了a.b,這樣你生成的apk裡面不是找不到a.b了么,肯定會報錯撒

Ⅳ 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

Ⅵ android 怎麼實現只混淆自己的代碼,而不混淆第3方

混淆打包流程: 1在proguard-projecttxt文件中添加不需要混淆的類和第三方的jar包 這個是保持自己包中不需要混淆的類,如果有些類調用了jni也不需要混淆,不然會出錯。還有如果項目中有其他項目作為library引入,那這些項目的一些類也不能混淆android 怎麼實現只混淆自己的代碼,而不混淆第3方

Ⅶ android gradle混淆第三方jar的問題

好像不行。。。
換個工具吧

Ⅷ 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.**

Ⅸ android代碼混淆時,如何防止第三方jar包被

rules文件加上類似: -keep public class * extends android.app.Fragment
可以選擇不混淆哪些類

Ⅹ android代碼混淆以及怎麼判斷一個apk代碼是否被混淆過

1、proguard原理
java代碼編譯成二進制class文件,這個class文件也可以反編譯成源代碼,除了注釋外,其他的code基本都可以看到。為了防止重要code被泄露,我們往往需要混淆,即把方法名,變數名,類名,包名等這些java元素的名稱改成讓人意想不到的名稱,這樣代碼結構就沒有變化,還可以運行,但是想弄懂代碼的架構卻很難。proguard就起到了這樣的作用:
一、它可以分析一組class的結構,根據用戶的配置,然後把這些class文件中可以混淆的java元素進行混淆

二、刪除無效的代碼

三、對代碼進行優化(使用adt插件導出的apk,還進行zipalign優化)

預設情況下,proguard會混淆所有代碼,但是下面幾種情況是不能改變java元素的名稱,否則就會導致程序出錯。
一、用到反射的地方(android中的api常用@hide注釋掉,開發者在調用相應的方法時,需要用到反射)

二、當app的代碼要依賴於系統的介面時,如被系統代碼調用的回調方法,這種方法比較復雜

三、java元素名稱是配置文件中配置好的

所以在使用proguard時,我們需要有個配置文件告訴proguard,哪些java元素是不能混淆的。

2、proguard配置

-dontwarn預設proguard會檢查每一個引用是否正確,但是第三方庫里往往有些不會用到的類,沒有正確引用,如果不配置的話,系統就會報錯。

-keep指定的類和類成員被保留作為入口

-keepclassmembes指定的類成員被保留。

-keepclasswithmembers指定的類和類成員被保留,假如指定的類成員存在的話。

熱點內容
php對象編程 發布:2025-04-01 06:38:41 瀏覽:332
c語言了5 發布:2025-04-01 06:36:19 瀏覽:143
演算法抖動 發布:2025-04-01 06:30:14 瀏覽:113
ssd做m2的緩存 發布:2025-04-01 06:26:28 瀏覽:542
安卓下載軟體沒有內存怎麼辦 發布:2025-04-01 06:08:36 瀏覽:61
龍珠怎麼上傳視頻 發布:2025-04-01 06:08:24 瀏覽:760
公司代理伺服器地址 發布:2025-04-01 06:05:32 瀏覽:220
minecraftpe戰牆伺服器ip 發布:2025-04-01 06:03:58 瀏覽:913
訪問虛擬機tomcat 發布:2025-04-01 06:02:32 瀏覽:68
linux系統密碼 發布:2025-04-01 06:01:04 瀏覽:977