Wednesday, 17 May 2017

在 fb 分享 app 链接的误区。

看到人家在 fb 推介自己的 app,突然间觉得有些话想说。




你按进去看到的不是 google play app, 而是 fb web browser。




解决方法是有的,让我们来做个实验。




按第一条 link(不是按图),你进到的就是 fb web browser。




按 "Install" 就会要求你 login, 不过我发现就算 login 了按 Install 也没反应。(按多几次出现叫我 install 在别的 device 的 dialog... 总之不稳定就是了)
[更新] 现在可以在右上角选在 play store 打开,不过仍然是麻烦, 多了一个步骤。




然而,如果按第二条 link, 就会先跳去 fb web browser 一秒, 再重定向去 google play app。




区别是什么 ? 分享链接的 https 的 s 字啦,丢掉它就可以 liao la。

还有一点,按预览图会直接跑 app(如果已安装),但如果你的目的是希望用户更新,那就应该把预览图关掉。

Tuesday, 16 May 2017

How to fixed - Not able to decompile apk in Ubuntu 17.04

I already knew that Oracle JDK is prefer over than OpenJDK long time ago, and now it give the solution of unable to decompile apk in Ubuntu 17.04.

xb@dnxb:~/Downloads$ java -jar ClassyShark.jar -open app-release.apk 
Exception in thread "main" java.lang.ExceptionInInitializerError
        at java.base/javax.crypto.JceSecurityManager.(JceSecurityManager.java:66)
        at java.base/javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2610)
        at java.base/javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2634)
        at java.base/sun.security.ssl.CipherSuite$BulkCipher.isUnlimited(CipherSuite.java:602)
        at java.base/sun.security.ssl.CipherSuite$BulkCipher.(CipherSuite.java:574)
        at java.base/sun.security.ssl.CipherSuite$BulkCipher.(CipherSuite.java:460)
        at java.base/sun.security.ssl.CipherSuite.(CipherSuite.java:1074)
        at java.base/sun.security.ssl.SSLContextImpl.getApplicableSupportedCipherSuiteList(SSLContextImpl.java:354)
        at java.base/sun.security.ssl.SSLContextImpl.access$100(SSLContextImpl.java:42)
        at java.base/sun.security.ssl.SSLContextImpl$AbstractTLSContext.(SSLContextImpl.java:590)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:292)
        at java.base/java.security.Provider$Service.getImplClass(Provider.java:1844)
        at java.base/java.security.Provider$Service.newInstance(Provider.java:1820)
        at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
        at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
        at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:169)
        at okhttp3.OkHttpClient.(OkHttpClient.java:176)
        at okhttp3.OkHttpClient.(OkHttpClient.java:151)
        at retrofit2.Retrofit$Builder.build(Retrofit.java:551)
        at com.google.classyshark.updater.networking.NetworkManager.getGitHubApi(NetworkManager.java:29)
        at com.google.classyshark.updater.networking.AbstractDownloader.checkNewVersion(AbstractDownloader.java:35)
        at com.google.classyshark.updater.UpdateManager.checkVersion(UpdateManager.java:49)
        at com.google.classyshark.updater.UpdateManager.checkVersionGui(UpdateManager.java:45)
        at com.google.classyshark.gui.GuiMode.with(GuiMode.java:42)
        at com.google.classyshark.Main.main(Main.java:44)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
        at java.base/javax.crypto.JceSecurity.(JceSecurity.java:118)
        ... 26 more
Caused by: java.lang.SecurityException: Can't read cryptographic policy directory: unlimited
        at java.base/javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:324)
        at java.base/javax.crypto.JceSecurity.access$000(JceSecurity.java:73)
        at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:109)
        at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:106)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/javax.crypto.JceSecurity.(JceSecurity.java:105)
        ... 26 more
xb@dnxb:~/Downloads$ echo $JAVA_HOME #useless :(
/usr/lib/jvm/java-1.9.0-openjdk-amd64
xb@dnxb:~/Downloads$ l /usr/lib/jvm/
total 32K
8792676 lrwxrwxrwx   1 root root ?   24 Mei  25  2016 default-java -> java-1.8.0-openjdk-amd64/
8792674 lrwxrwxrwx   1 root root ?   20 Mac   4 01:46 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
8792533 -rw-r--r--   1 root root ? 2.7K Mac  17 07:09 .java-1.9.0-openjdk-amd64.jinfo
8792634 lrwxrwxrwx   1 root root ?   20 Mac  17 07:09 java-1.9.0-openjdk-amd64 -> java-9-openjdk-amd64/
8792534 drwxr-xr-x   8 root root ? 4.0K Apr  18 22:31 java-9-openjdk-amd64/
8792677 -rw-r--r--   1 root root ? 2.6K Mei   2 10:51 .java-1.8.0-openjdk-amd64.jinfo
8792673 drwxr-xr-x   7 root root ? 4.0K Mei  12 15:38 java-8-openjdk-amd64/
8792532 drwxr-xr-x   4 root root ? 4.0K Mei  12 15:38 ./
8650757 drwxr-xr-x 169 root root ?  12K Mei  17 02:53 ../
xb@dnxb:~/Downloads$ 
xb@dnxb:~/Downloads$ sudo tar xvzf jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm #download latest oracle jdk from http://www.oracle.com/technetwork/java/javase/downloads/
jdk1.8.0_131/
jdk1.8.0_131/javafx-src.zip
...
xb@dnxb:~/Downloads$ cat /etc/environment #add JAVA_HOME="/usr/lib/jvm/Your_jdk_directory_name/"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_131/"
xb@dnxb:~/Downloads$ grep '/etc/environment' ~/.bashrc #ensure got `source /etc/environment`, if no, `sudo vim /etc/environment` add that line.
source /etc/environment
xb@dnxb:~/Downloads$ . ~/.bashrc #reload ~/.bashrc
xb@dnxb:~/Downloads$ echo $JAVA_HOME #ensure $JAVA_HOME is printable
/usr/lib/jvm/jdk1.8.0_131/
xb@dnxb:~/Downloads$ sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000 #credit: https://askubuntu.com/a/764914/265303
update-alternatives: using /usr/lib/jvm/jdk1.8.0_131/bin/java to provide /usr/bin/java (java) in auto mode
xb@dnxb:~/Downloads$ sudo update-alternatives --install /usr/bin/javac javac ${JAVA_HOME%*/}/bin/javac 20000
update-alternatives: using /usr/lib/jvm/jdk1.8.0_131/bin/javac to provide /usr/bin/javac (javac) in auto mode
xb@dnxb:~/Downloads$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk1.8.0_131/bin/java               20000     auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode
  3            /usr/lib/jvm/jdk1.8.0_131/bin/java               20000     manual mode

Press  to keep the current choice[*], or type selection number: 0
xb@dnxb:~/Downloads$ java -version #now it did changed to "1.8.0_131", originally is "9-Ubuntu"
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
xb@dnxb:~/Downloads$ java -jar ClassyShark.jar -open app-release.apk #now it should works, cheers :)
...
xb@dnxb:~/Downloads$ java -jar /opt/jd-gui/jd-gui-1.4.0.jar <Your class file> #is working too

[UPDATE]: I found this thread, he's right, if I select downgraded version
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java on `sudo update-alternatives --config java` above, can solve the problem too.