Strong
Soft
Weak
Phantom
it is important to avoid memory leak
Android’s LruCache uses strong references
2015年4月7日 星期二
2015年3月26日 星期四
[Design Partern] Strategy pattern case 1: Android load NDK library
在 Android 的開發中使用 NDK 最佳化的時候,可能會因為平台的差異,導致 native code 無法執行,這時候必須提供 Java 版本的 solution。
Design Pattern 裡面有一個Strategy pattern,他的特性如下:
In computer programming, the strategy pattern (also known as the policy pattern) is a software design pattern that enables an algorithm's behavior to be selected at runtime. The strategy pattern
1. defines a family of algorithms,
2. encapsulates each algorithm, and
3. makes the algorithms interchangeable within that family.
載入 native library 的時機點也是在 runtime,剛好符合 Startegy pattern 的 case:
載入 native library 的時機點也是在 runtime,剛好符合 Startegy pattern 的 case:
例子如下:
2015年3月20日 星期五
[Performance] Fibonacci演算法探討演算法最佳解
2014年12月29日 星期一
[Android] 可以 count Jar 檔案的 method 數量的 script
dx --dex --output=temp.dex $1
cat temp.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
rm temp.dex
dx 要用
/home/charles_lo/Program/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.1
不要用 apt-get 去安裝
實測效果
cat temp.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
rm temp.dex
dx 要用
/home/charles_lo/Program/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.1
不要用 apt-get 去安裝
實測效果
2014年12月12日 星期五
[Android] Eclipse ADT budle download link
最近eclipse ADT bundle download link 官方網站已經找不到了,所以備份一下連結
linux 64 bit vm: http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20140702.zip linux 32 bit vm: http://dl.google.com/android/adt/adt-bundle-linux-x86-20140702.zip mac: http://dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip win32: http://dl.google.com/android/adt/adt-bundle-windows-x86-20140702.zip win64: http://dl.google.com/android/adt/adt-bundle-windows-x86_64-20140702.zip 還有一個更新失敗的 issue 連結 https://code.google.com/p/android/issues/detail?id=73102
2014年11月18日 星期二
[Android][Proguard]android 程序代码混淆 proguard 脚本 proguard.cfg
从script中可以看到,混淆中保留了继承自Activity、Service、Application、BroadcastReceiver、ContentProvider等基本组件。
并保留了所有的Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举等等。(详细信息请参考<proguard_path>/examples中的例子及注释。)
2 在工程的"default.properties"中添加这样一句话“proguard.config=proguard.cfg”
打包签名后的.apk就是混淆的,其实我们只要做一步就可以了就是在"default.properties"中添加这样一句话“proguard.config=proguard.cfg”就可以了。
出现错误:
[INFO] Warning: there were 294 unresolved references to classes or interfaces.
[INFO] You may need to specify additional library jars (using '-library
jars').
[INFO] Warning: there were 3 unresolved references to program class members.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
[INFO] Your input classes appear to be inconsistent.
[INFO] You may need to recompile them and try again.
[INFO] Alternatively, you may have to specify the option
[INFO] '-dontskipnonpubliclibraryclassmembers'.
[INFO] java.io.IOException: Please correct the above warnings first.
[INFO] at proguard.Initializer.execute(Initializer.java:321)
[INFO] at proguard.ProGuard.initialize(ProGuard.java:211)
[INFO] at proguard.ProGuard.execute(ProGuard.java:86)
[INFO] at proguard.ProGuard.main(ProGuard.java:492)
并保留了所有的Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举等等。(详细信息请参考<proguard_path>/examples中的例子及注释。)
2 在工程的"default.properties"中添加这样一句话“proguard.config=proguard.cfg”
打包签名后的.apk就是混淆的,其实我们只要做一步就可以了就是在"default.properties"中添加这样一句话“proguard.config=proguard.cfg”就可以了。
出现错误:
[INFO] Warning: there were 294 unresolved references to classes or interfaces.
[INFO] You may need to specify additional library jars (using '-library
jars').
[INFO] Warning: there were 3 unresolved references to program class members.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
[INFO] Your input classes appear to be inconsistent.
[INFO] You may need to recompile them and try again.
[INFO] Alternatively, you may have to specify the option
[INFO] '-dontskipnonpubliclibraryclassmembers'.
[INFO] java.io.IOException: Please correct the above warnings first.
[INFO] at proguard.Initializer.execute(Initializer.java:321)
[INFO] at proguard.ProGuard.initialize(ProGuard.java:211)
[INFO] at proguard.ProGuard.execute(ProGuard.java:86)
[INFO] at proguard.ProGuard.main(ProGuard.java:492)
解决方法如下:解决方法找到了,在proguard.cfg文件中加入-ignorewarnings就可以跳过这个错误了
2014年11月16日 星期日
訂閱:
文章 (Atom)