2015年7月28日 星期二

eclipse 轉換到 Android Studio 後 Proguard 混淆器 註解掉 util.Log 失效問題

最近開始將 eclipse 轉換到 Android Studio

對於gradle 不是太熟悉

輸出apk 後發覺

之前在eclipse 設定Proguard 

用dex2jax 反編譯apk 之後 還是可以看到 Log.d 程式碼

可以註解掉 程式中所有的 Log.d , Log.i 機制失效了

eclipse proguard 設定

1.project.properties 文件中

proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt


2014年12月8日 星期一

[Android] 讓 Log 訊息不出現在Logcat 且隱藏反編譯後之Log字串

Log.d 幾乎是開發過程中的必用函式

而且在debug過程中,會一直反覆更改訊息

不過Log這個函式 也隱藏了安全性風險


  • 風險1:若發佈成apk供使用者下載後,沒有註解掉 Log 訊息, Logcat視窗會輸出開發時的Log訊息 
  • 風險2:apk若被反解譯 ,Log函式訊息會被看到,程式邏輯可能曝光



2014年12月7日 星期日

[android] proGuard 導致 webview AndroidJSInterface / WebAppInterface 失效問題

開啟 proGuard 混淆器 會導致 webview AndroidJSInterface 失效

第一次發現這個問題是

在使用eclipse debug的時候 AndroidJSInterface 的 function 可以正常執行

[Android] DefaultHttpClient Https 失效 取回值為空

在使用 org.apache.http.impl.client.DefaultHttpClient; 呼叫api時

本來是可以正常回傳資訊內容

不過有時候回傳的值為空

後來發現原來是因為 api 的 通訊協定是 https 造成

2014年8月22日 星期五

[Android] string.xml 的 錯誤訊息 error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?

Android 中 的 String.xml 中

若要使用到 String.format() 的話

例如

想顯示 已經下載了 多少 bit 的 檔案  format 成 數字格式

String.format(getResources().getString(R.string.update_downloaded),currentSize ,totalSize);

String.xml 中

 <string name="update_downloaded">Downloaded %s bit  of %s  bit</string>

會出現錯誤訊息

error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?



2014年8月4日 星期一

java 陣列 不重複的值 (使用ArrayList)

今天在實作  barCode 連續掃描時

發現個問題

須要把 掃描到的 barCode 暫存起來

並且存下來的值不重複

對於一個 php 轉java 的新手

第一個想到就是用陣列

在php中  直接  array_push("value");

最後再   array_unique();   就結束了

不過java 沒這麼簡單

 1.java 沒有直接 array_unique 的 function
 2.java 的 Array 需要先預先宣告 長度

ex String barCode[] = new String(10)