Saturday, January 26, 2013

AdMob 中 AdView 在 Proguard 之下的 "Proguard returned with error code 1"

多手升級一下 App 中的 Proguard version 同 AdMob SDK 立即出了:


Proguard returned with error code 1. See console
Note: there were 160 duplicate class definitions.
Warning: com.google.ads.m: can't find referenced class com.google.ads.internal.state.AdState
Warning: com.google.ads.m: can't find referenced class com.google.ads.internal.state.AdState
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to classes or interfaces.
 You may need to specify additional library jars (using '-libraryjars').

先在 Project -> Build Path -> Export 中手動加入了
GoogleAdMobAdsSdk-6.2.1.jar
但那Error老在
又修改了一下 proguard-project.txt:
加入了:


-keepattributes *Annotation*
-keep public class com.google.ads.** {*;}
-libraryjars /libs/GoogleAdMobAdsSdk-6.2.1.jar

都无功而返:
只好學一下AdView 中的example 加入一些

-dontpreverify -repackageclasses '
-allowaccessmodification 
-optimizations !code/simplification/arithmetic


-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}


但是............
所以話AdMob 是 Google API 中最失敗的一個
次次要Update 都要花費一些時間.
最後只好問問全能的Google.


This problem started with AdMob SDK 6.1.0 and 6.2.1 (for Android). To fix the error, add this to your proguard.cfg file:
中文是叫大家加下會的一句在 proguard.cfg:

-dontwarn com.google.ads.**



Case Close.



Wednesday, January 23, 2013

Hong Kong ID Formula (HKID Number Check Digit)

此文之中文版
http://computerterminal.blogspot.hk/2005/11/hkid-calculation.html


I found out form the Google Analystic that 1/8 of the visitors to this site is to the post HKID Calculation and 1/3 of the visitors are from Russia(!!!) and USA. So i decide to write that post in English for them.

HK ID number starts from Two English Letters plus 6 digits and end with a check digit in bracket
for example: AB987654(3)

Validate the HKID by the following steps:


1) Replace the leading English alphabet with numberic value following the rules below:

Space = 36  A = 10    B = 11   C = 12   D = 13  E = 14    F = 15

G = 16    H = 17   I = 18     J = 19   K = 20    L = 21M = 22    N = 23  O = 24   P = 25   Q = 26    R = 27S = 28    T = 29   U = 30   V = 31   W = 32   X = 33Y = 34     Z = 35

2) Weighted Total 
Calculation 
   A)If double english alphabet digit,e.g. AB987654(3):
           Total = 1st Digit x9 + 2nd Digit x8 + 3rd Digit x7 + 4th Digit x6 + 5th Digit x5 + 6th Digit x4 + 7th Digit x3 +8th Digit x2

   B) Else if single english alphabet digit,e.g. E364912(5):
           E364912(5) = (Space)E364912(5)
           Total = 36 x 9 + 1st Digit x8 + 2nd Digit x7 + 3rd Digit x6 + 4th Digit x5 + 5th Digit x4 + 6th Digit x3 + 7th Digit x2 

3) CheckDigit Calculation

Remaining= Total modulo 11 

IF
a)Remaning = 0:
   CheckDigit = 0

b)Remaning = 1:
   CheckDigit = A

c)Remaning = [2-10]:
   CheckDigit = 11 - Remaining


Example:
HKID:E364912(5)
(PS:E is equal to 14 according to step 1)

324 + 14x8 + 3x7 + 6x6 + 4x5 + 9x4 + 1x3 + 2x2 = 556

556 % 11 = 68

11 - 6 = 5

So E364912(5) is a Valid HKID