androidjar下載地址
❶ 如何使用Android Studio打包混淆的Jar
使用AS打包混淆Jar包,網路一下,一片一片的,但是很多都是零零散散的寫得不是很詳細或是直接拷貝,按照他們的教程測試總不是很順利,所以這里我就把我個人學習AS打包混淆Jar的成果總結出來,希望對大家有幫助。個人覺得寫得還是比較詳細的
使用gradle混淆打包Jar
使用AS開發項目,引入第三方庫是非常方便的,我們只需要在build.gradle中配置一行代碼就可以輕松引入我們需要的開發庫。那麼gradle可以幫我們混淆打包Jar嗎?答案是當然可以!
那麼我們如何打包Jar呢?其實我們在編譯項目的時候,AS已經幫我們在目錄build/intermediates/bundles/release/classes.jar打好了Jar。那麼我們需要做的就是把Jar進行混淆的工作了。這里以個人項目bannerDemo為例,混淆步驟如下:
在你的library的build.gradle文件中加入如下代碼:
task makeJar(type: proguard.gradle.ProGuardTask, dependsOn: "build") {
// 未混淆的jar路徑
injars 'build/intermediates/bundles/release/classes.jar'
// 混淆後的jar輸出路徑
outjars 'build/outputs/cocolove2-banner-1.1.0.jar'
// 混淆協議
configuration 'proguard-rules.pro'}
配置混淆協議
1.我們先把AS自帶的協議配置進來中文注釋,筆者添加
# This is a configuration file for ProGuard.# http://proguard.sourceforge.net/index.html#manual/usage.html## Starting with version 2.2 of the Android plugin for Gradle, these files are no longer used. Newer# versions are distributed with the plugin and unpacked at build time. Files in this directory are# no longer maintained.#表示混淆時不使用大小寫混合類名-dontusemixedcaseclassnames#表示不跳過library中的非public的類-#列印混淆的詳細信息-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##表示不進行校驗,這個校驗作用 在java平台上的-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);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator 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.**# Understand the @Keep support annotation.-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>(...);
}
2.AS自帶的配置文檔還是不夠的,我們還需要加入如下配置
這里只展示基本操作,在實際開發中可能需要更多依賴,要根據具體情況引入自己需要的依賴包
#下面代碼中的xx是指我個人的配置路徑,涉及個人信息,這里以xx代替
#引入依賴包rt.jar(jdk路徑)
-libraryjars /xxx/xx/xx/jdk1.8.0_77.jdk/Contents/Home/jre/lib/rt.jar
#引入依賴包android.jar(android SDK路徑)
-libraryjars /xx/xx/xx/Android/sdk/platforms/android-24/android.jar
#如果用到Appcompat包,需要引入
-libraryjars /xxx/xxx/xx/xxx/MyApplication/library-banner/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.1.1/jars/classes.jar
-libraryjars /xx/xx/xx/xx/MyApplication/library-banner/build/intermediates/exploded-aar/com.android.support/support-v4/24.1.1/jars/classes.jar
#忽略警告
-ignorewarnings
#保證是獨立的jar,沒有任何項目引用,如果不寫就會認為我們所有的代碼是無用的,從而把所有的代碼壓縮掉,導出一個空的jar
-dontshrink
#保護泛型
-keepattributes Signature
3.加入自己不想混淆的配置根據實際需求配置
-keep class com.cocolove2.library_banner.view.**{*;}
在命令行執行命令混淆Jar,提示BUILD SUCCESFUL表示成功!
//mac./gradlew makeJar//windowsgradlew makeJar
示例展示
我這里以混淆library-banner庫為例
- #log提示缺少依賴Jar,或者路徑不對
- 解決辦法:乖乖的引入缺少的依賴jar和修改路徑
- #提示如下異常[INFO] java.io.IOException: Can't read [D:Program
- FilesJavajdk1.8.0_91jrelib t.jar] (Can't process class [com/oracle/net/Sdp$1.class] (Unsupported class version number
- [52.0] (maximum 51.0, Java 1.7)))
- 解決辦法:
- 下載最新proguard(支持Java 8的版本),然後將下載的文件解壓。
- 將andorid sdk/tools/proguard/lib中的jar包,替換為剛下載解壓文件中的lib包。
proguard5.2.1下載地址
1.首先我們要看看下我們的buildTool的配置,如下圖:
混淆報錯解決辦法個人遇到的
閱讀
❷ 如何反編譯android的apk文件得到資源文件
您好,很高興能幫助您
一.反編譯Apk得到Java源代碼
轉載自:http://hi..com/%CB%BF%D4%B5%CC%EC%CF%C2/blog/item/2284e2debafc541e495403ec.html
工具下載:需用到dex2jar和JD-GUI這2個工具
dex2jar下載地址:http://laichao.googlecode.com/files/dex2jar-0.0.7-SNAPSHOT.zip
JD-GUI下載地址:
windows版JD-GUI:http://laichao.googlecode.com/files/jdgui.zip
linux版JD-GUI:http://laichao.googlecode.com/files/jd-gui-0.3.2.linux.i686.tar.gz
步驟:
1.首先找到Android軟體安裝包中的classes.dex
把.apk文件改名為.zip,然後解壓縮,得到其中的classes.dex文件,它就是java文件編譯再通過dx工具打包成的,所以現在我們就用上述提到的2個工具來逆方向導出java源文件
2.把classes.dex拷貝到dex2jar.bat所在目錄。
在命令行模式下定位到dex2jar.bat所在目錄,運行 dex2jar.bat classes.dex ,生成classes.dex.dex2jar.jar
3.運行JD-GUI工具(它是綠色無須安裝的)
打開上面的jar文件,即可看到源代碼
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
二.反編譯apk生成程序的源代碼和圖片、XML配置、語言資源等文件。
轉載自:http://blog.sina.com.cn/s/blog_5752764e0100kv34.html
工具下載:
在http://code.google.com/p/android-apktool/下 載獲得,apktool-1.0.0.tar.bz2和apktool-install-windows-2.1_r01-1.zip兩個包都要下。
步驟:
1.解壓縮下載的兩個文件包,apktool-install-windows-2.1_r01-1.zip解壓縮後得到的包里有aapt.exe 和apktool.bat.(注意要把apktool-1.0.0.tar.bz2解壓後的一個.jar 文件進來)
2.打開命令窗口 (開始 > 運行,輸入cmd,回車。)進入到apktool.bat的文件夾里。
輸入:
apktool d C:\***.apk C:\***文件夾
(命令行解釋:apktool d 要反編譯的文件 輸出文件夾)
特別注意:你要反編譯的文件一定要放在C盤的根目錄里,
3.打開 C:\***文件夾 就可以得到我們學院的各種資源了。
三.將反編譯完的文件重新打包成apk
很簡單,只要輸入:
apktood b c:***文件夾(你編譯出來文件夾)
你的採納是我前進的動力,
記得好評和採納,答題不易,互相幫助,
❸ (android) 請問'javax.naming.StringRefAddr'這個類的jar包在哪裡可以下載
JRE的 rt.jar 里帶的。
❹ android第三方jar包從哪裡下載
網路,谷歌,CSDN裡面收索就是了,一大把的