Search This Blog

Tuesday, December 23, 2014

Add JavaScript/CSS syntax highlighting in Android Studio

  • From Android Studio Menu, go to File -> Import Settings...
  • Locate the settings.jar file from this repository
  • From "Select Components to Import" make sure you have "File types" checked, then press OK

Download this file:
https://github.com/manifestinteractive/android-studio-filetypes/blob/master/settings.jar



Friday, December 12, 2014

Android: get sha from *.apk file; validate *.apk content; check apk integrity

The apk file might get destroyed when it's transferred through a network. If the file is signed with a certificate (most Android applications are signed by the publisher) you can check the file integrity from the command line before installing the application. The following methods check the certificate validity as well as validate apk file contents.



keytool -list -printcert -jarfile app-sa.apk

(java/jre/bin/keytool)


 Signer #1:  
   
 Signature:  
   
 Owner: CN=Somevalue, OU=Developers, O=Somevalue. Somevalue, L=Somevalue, ST=Somevalue, C=PL  
 Issuer: CN=Somevaluei, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL  
 Serial number: Somevalue  
 Valid from: Thu Jul 17 11:25:00 CEST 2014 until: Mon Jul 11 11:25:00 CEST 2039  
 Certificate fingerprints:  
       MD5: 11:11:11:11:11:11:11:11:11:11:A3:D8:B5:11:11:11  
       SHA1: 11:11:11:11:11:11:11:11:11:0D:42:BC:2D:01:11:11:11:11:11:11  
       SHA256: 11:11:11:11:11:11:11:11:11:11:11:11:D4:7C:B7:1C:C8:14:8E:43:11:11:11:11:11:11:11:11:3E:11:11:11  
       Signature algorithm name: SHA256withRSA  
       Version: 3  
   
 Extensions:   
   
 #1: ObjectId: 2.5.29.14 Criticality=false  
 SubjectKeyIdentifier [  
 KeyIdentifier [  
 0000: 11 11 11 11 11 11 11 11  11 11 11 11 11 11 36 F3 ..]....%.B....6.  
 0010: 11 11 11 11                    ....  
 ]  
 ]  
   



jarsigner -verbose -verify -certs app-sa.apk

(java/jre/bin/jarsigner)


 sm    162096 Thu Dec 11 16:39:46 CET 2014 resources.arsc

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

sm    4416396 Thu Dec 11 16:40:46 CET 2014 classes.dex

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

sm       621 Thu Dec 11 16:40:48 CET 2014 androidannotations-api.properties

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

s      32963 Thu Dec 11 16:40:50 CET 2014 META-INF/MANIFEST.MF

      X.509, CN=Somevalue, OU=Developers, O=Somevalue Somevalue, L=Somevalue, ST=Somevalue, C=PL
      [certificate is valid from 7/17/14 11:25 AM to 7/11/39 11:25 AM]
      [CertPath not validated: Path does not chain with any of the trust anchors]

       32984 Thu Dec 11 16:40:50 CET 2014 META-INF/CERT.SF
        1495 Thu Dec 11 16:40:50 CET 2014 META-INF/CERT.RSA

  s = signature was verified 
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

jar verified.
The latter of the methods verifies apk content as well. 



Monday, December 8, 2014

Android Studio - new Android 5.0 Lollipop emulators; Intel hardware-assisted virtualization; Android Studio Android 5.0 emulator landscape mode


Google has released the new Android Studio 1.0 RC 4. It consists new Android emulators (in the SDK of course) which take full advantage of Intel hardware-assisted virtualization and can use the host GPU.

Here is how to enable these on your Intel machine.


Android Emulator Shortcuts

Ctrl+F11 Switch layout orientation portrait/landscape backwards

Ctrl+F12 Switch layout orientation portrait/landscape forwards

Main Device Keys
Home Home Button

F2 Left Softkey / Menu / Settings button (or Page up)

Shift+f2 Right Softkey / Star button (or Page down)

Esc Back Button

F3 Call/ dial Button

F4 Hang up / end call button

F5 Search Button

Other Device Keys
Ctrl+F5 Volume up (or + on numeric keyboard with Num Lock off) Ctrl+F6 Volume down (or + on numeric keyboard with Num Lock off) F7 Power Button Ctrl+F3 Camera Button

Ctrl+F11 Switch layout orientation portrait/landscape backwards

Ctrl+F12 Switch layout orientation portrait/landscape forwards

F8 Toggle cell network

F9 Toggle code profiling

Alt+Enter Toggle fullscreen mode

F6 Toggle trackball mode



Sunday, December 7, 2014

Ubuntu mount nfs share

Ubuntu does not come with nfs server so we need to install it:

$ sudo apt-get install nfs-kernel-server

Then we can mount nfs shares like this:

$ sudo mount 1.2.3.4:/home /home/user/nfs/home


to check whether the share mounted successfully:

mount -t nfs


more info

Friday, November 28, 2014

Ubuntu 14.04 - how to create shortcuts in unity launcher

To create a shortcut to an application in unity launcher just make in a symlink in one of the following locations:

/home/user/.local/share/applications

or

/usr/share/applications

or

/usr/local/share/applications

Example command:

ln -s /home/user/applicationsFolder/app1 /usr/share/applications/app1






Build Android apps as Chrome apps/extensions, Build Android apps for ChromeOS, configure build server

What I want to accomplish is configure a build server (like TeamCity) to build an Android application from source and convert it to a chrome extension that can be published on Chrome WebStore as an application.

First of all you can read this source which explains how to run android apps in chrome.

1. Download ARChon runtime and install it as an extenion in Chrome.

2. You can convert your apk manually with this chrome extension - Twerk

3. To enable Chrome App Launcher on Ubuntu (speeds up app launching) - follow this link.

4. Install chromeos-apk
asdsa

  1. In a terminal, run the following command: sudo apt-get install npm
  2. (Ubuntu only): Run the following command: sudo apt-get install lib32stdc++6
  3. Download node.js.
  4. Unzip the tar.gz file you downloaded from the above link.
  5. Per the README file, open a terminal to the unzipped folder containing node.js. And run the following commands in order:
    1. ./configure
    2. make
    3. make install
  6. Run the command: sudo npm install chromeos-apk -g
  7. To make sure you're updated to the latest version (now or in the future), run: sudo npm install -g chromeos-apk@latest
5. Convert your compiled application in apk to chrome app with:

chromeos-apk --tablet --scale --name ApplicationName application.apk


5. Remember - to update the chromeos-apk plugin just run:

sudo npm install -g chromeos-apk@latest

Thursday, November 27, 2014

Install CyanogenMod 11 on XPeria P running stock Android 4.1

1. First of all you need to unlock your bootloader. [worked]
Go developer_sony to proceed with unlocking (official SONY's website)

  1. In your device, open the dialler and enter *#*#7378423#*#* to access the service menu.
  2. Tap Service info > Configuration > Rooting Status. If Bootloader unlock allowed says Yes, then you can continue with the next step. If it says No, or if the status is missing, your device cannot be unlocked.


2. Then you need to root your XPeria P [worked]
The following root method worked for me:
DooMLoRD Easy Rooting Toolkit (v17)


3. To install CWM [worked]

CWM xda link
You need to have root access in order to use this method.
It worked fine for me.

CyanogenMod 11 did NOT install from CWM for me. It started fine and then couldn't read the phone model number properly.


4. To install TWRP [did not work as expected]

extract boot.img from cm-11-20141012-SNAPSHOT-M11-nypon.zip and copy it to the main script directory.

flash the boot image in fastboot mode with:
sudo fastboot flash boot boot.img


4. Cyanogemod 11 link

http://forum.xda-developers.com/xperia-u/p-development/rom-cyanogenmod-11-0-t2626639


Workaround:
After 1,2,4 (After flashing boot.img )
enter CWM and try to flash CyanogenMod. The device will restart and enter bootloop. Try pressing power button to enter TWRP.
Then flash cyanogenmod normally.


HOW TO ENTER RECOVERY MODE in Xperia P

howto

CyanogenMod:
1.press power + volume up for 3 seconds until the phone vibrates
2. keep on pressing volume up multiple times until clockworkmod recovery shows

TWRP
1.press power + volume up for 3 seconds until the phone vibrates
2. keep on pressing power until twrp shows