Network Calls from Android Device to Laptop over USB via ADB

I’ve seen a few articles about using the “adb reverse” command which allows you to make specific network calls to your laptop over USB, but when explaining this concept to others, they had a hard time visualizing how it worked.  I’ve put together this post to help illustrate how this works and spotlight some use cases.

Android’s “adb reverse” command is available in Lollipop and higher versions of Android (Platform 21+) and it allows you to access a server running on your computer from your Android device over USB without any network (WiFi or Cellular).  This is done through a technique called a reverse proxy.

What’s a reverse proxy? (via Wikipedia)

A type of proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as though they originated from the proxy server itself.

Use Case 1 : Android -> Server running on laptop

Android Device (localhost:8080) -> Server running on Computer (localhost:8081)

adb reverse tcp:8080 tcp:8081

Screen Shot 2016-02-01 at 2.42.15 PM

Use Case 2 : Android -> WireMock on laptop -> Server accessible only on laptop (i.e. VPN)

Download the WireMock JAR and run it using the following command in a Terminal

java -jar wiremock-standalone-2.0.8-beta.jar --port=8081 --proxy-all="https://internal.myapp.com"

Android Device (localhost:8080) -> WireMock running on Computer (localhost:8081)

adb reverse tcp:8080 tcp:8081

This allows you to have your physical Android device access resources that are only available through your laptop.

When you’re done, turn off all reverse proxy port mappings:

adb reverse --remove-all

Sources:

Contactless Payments on Capital One Wallet for Android!

It’s been super hard to not share this info as I’ve done presentations on Host Card Emulation (HCE) presentations, but on October 14th the feature I’ve been leading Android development efforts on launched! Capital One Wallet – Google Play Store. This is a project I’ve been a part of for almost a year and it’s so cool to see it in the wild and right along side of Android Pay, Samsung Pay and the rest. It supports Visa and Mastercard and is pretty awesome. Capital One was the first bank in the US to support contactless payments in an Android app and it’s super exciting to have been a part of that.

I tried to do my with presentations but it always killed me that I wasn’t able to share what we were doing. I did feel like I was able to explain how HCE works on Android, but wasn’t able to give much more info at the time. Check out my presentation video and slides from Droidcon NYC.

Tap to Pay Screen
Tap to Pay
Payment Sent Screen
Payment Sent

iOS 101 for Android Developers – AnDevCon Boston 2015

by Stephen Barnes (@smbarne), Fitbit iOS Engineer

Sample Project used in talk: https://github.com/smbarne/AndroidForiOS

IMG_20150730_154830

By learning iOS and coming over to the dark side, you can learn from the iOS app, and also help do a quick implementation of a feature you already implemented on Android.

Start Developing iOS Apps Today tutorial

Hamburger menu on Android, not on iOS.

UINavigationController to Push/Pop UIViewControllers
* Use this by default for nested content

Other Extensions
* Custom Keyboards
* Photo/Media Editing
* Storage Provider
* Document picker
More: https://developer.apple.com/app-extensions/

Swift 2.0 was announced for iOS9 and Xcode 7.

App Store approval can take up to 2 weeks. On Android, it’s up within 12 hours.

——
Project Structure
* Swift uses modules
* Note: Objective-C has no namespacing so use class prefixes (recommended to be at least 3 characters, and not something like “FB”)
info.plist is required and similar to AndroidManifest.xml n Android
* No build.gradlew. All build info in *.xcodeproj

Asset Bundles:
* There are 3 buckets. Just @1x, @2x, and 3x
* The iPhone 6 is the first device to have @3x and a non-1:1 or 2:1 pixel ratio.

UIViewControllers <-> Activities (UI Building Blocks)
Fundamental view-management model for all iOS apps.

iOS is strongly architected around the MVC framework.

Fragments don’t exist on iOS, and this sort of concept doesn’t really exist.  You could do it if you use the Child View Controller Containment, but it’s not recommended unless you have significant iOS experience since this is not a common patter.
ListFragment would be done with a UITableViewController on iOS.

Closures are Apple’s Lambda implementation blocks.  These are similar to anonymous functions or AsyncTasks

Main View Components

  • PagerAdapter or NavigationDrawer -> UITabBar
  • ListView -> UITableView
  • GridView -> UICollectionView

iOS Interface Builder is your friend.  AutoLayout is almost a must.

Storyboards are powerful and worthwhile.

Core Data is a ORM with some pluses and minuses.  Designed to be easy to use and reliable.  It is the defacto way to do persistent data as it also has migrations, etc.  Contains grouping, filtering and organizing data in memory and in the UI.

Equivalent libraries:

  • AFNetworking <-> Volley
  • MagicalRecord <-> ActiveAndroid
  • SDWebImage <-> Picasso

MasterCard APIs: Payments, Security and Data – AnDevCon Boston 2015

by: Brien Buckman

global

What is MasterCard?
“We are more than credit cards, we are payment experts. We process transactions 2x quicker than the blink of an eye.”

“We <3 Android”

MasterCard is part of Android Pay, but he can’t speak much about that.

MasterCard developer zone
You can play with all of their SDKs and each one has a Sandbox available. There is also documentation and support forums.  Go to “Services” and there are about 20 on there.

MasterPass – Digital Wallet Network
A digital Wallet Service that allows consumers pay with any payment card anywhere on any connected-device.

Simplify Commerce – Accepting Payments
Makes it easy for small businesses to accept payments.

“Low, Fixed Pricing – SDKs – Plugins

Merchant Identifier – Rich Merchant Data

“Provides rich merchant descriptions based on a merchant’s acquiring name.” This makes the credit card statement entry human readable instead of “JOE COFFE 342”, it would be “Joe’s Coffee on 2nd Street”, etc.

*NEW* – “Places” aggregate anonymous spend data to give you relevant merchant-focused information.”
“Say you are traveling to the middle of no where Utah, and you want a good restaurant. They use anonymous transaction data to see what the most popular payments are.

Masters of Code” is their global hackathon. Running a lot of these events.  One is in NYC November 7-8 this year.  Get one quick, because it will sell out.

Locations API” – For determining where MasterCard is accepted.

Publishing Android Libraries to Maven Central Using Gradle – AnDevCon Boston 2015

by: James Harmon (contact info in etherpad document)

Resources from Presentation: https://etherpad.mozilla.org/android-publish

IMG_20150730_115808

JCenter is run by Bintray.  Their tagline is:

“Forget about Maven Central”

Artifactory is a good option if you want an internally hosted repository.  JCenter also can provide a private hosted repository.

If you publish to mavenCentral(), it will be available on jcenter() as well.

Sign up for a SonaType Acount (mavenCentral()) or a JCenter account. Jcenter seems to be easier and is the default these day for Android libraries, but this example is for SonaType:

You’ll get an email back from SonaType approving you.

Create and Publish Key

Create PGP Key
gpg -gen-key

Find you Key ID:
gpg –list-keys
Key will look like: XXXXXX/YYYYYYYY <date>
YYYYYYYY is they key ID.

Now that you have the key, you can sign the library.

maven-push.gradle (you can include gradle files, so he separated this out)
Separate gradle file for pushing release and snapshot builds to repository.

Generate a pom.xml file using the ‘maven’ gradle plugin. This is useful for some repositories.

Check out your project’s depdencies using:

./gradlew app:dependencies

Example:

_releaseApk - ## Internal use, do not manually configure ##
+--- com.android.support:appcompat-v7:22.2.0
| \--- com.android.support:support-v4:22.2.0
| \--- com.android.support:support-annotations:22.2.0
+--- com.jakewharton:butterknife:7.0.1
+--- com.jakewharton.timber:timber:3.1.0
\--- com.arcao:slf4j-timber:2.0
+--- org.slf4j:slf4j-api:1.7.12
\--- com.jakewharton.timber:timber:3.0.1 -> 3.1.0

 

Plugin for deploying gradle builds to jcenter from Nodovahttps://github.com/novoda/bintray-release

 

The Yin and Yang of NDK Development – AnDevCon Boston 2015

by: Konstantin Mandrika (@kmandrika) and Matt Willis (@mattwillis) from Twitter

IMG_20150730_112432

Make sure you are using the NDK when you actually need it.  If you are making a Pong app or a Chess app, you probably don’t need the NDK.

By default, you will build for 7 types of processor architectures.

armeabi and x86 are generally good bases and will cover the majority of all processor types for android devices.

AAR libraries typically are compiled for all processor types, this can cause unsatisfied link errors when you pull in an AAR file from gradle and it won’t make much sense.  It can do this if you are compiling for the base types (armeabi and x86) because it will try to use a 64 bit version, or an armeabi-v7 version which will cause a processor type mismatch.

Tip for AAR files: You can split AARs into different runtime builds in order to fix this.

Developer Experience: They traced down a bug that only happened on one device and one version of Android. It was due to an error in Libc.  Yuck.  This is something you can’t control, so this illustrates one of the issues with Android fragmentation.

C++ STL (Standard Template Library)

  • Small and very useful.  Less complete than java.util.*
  • Most implementations are incomplete
  • Tip: Take a copy of the STL, put it in your app, that will avoid issues for different implementations on different devices.

NDK Crash handling is EXTREMELY CHALLENGING
* Try out crashlytics: https://dev.twitter.com/crashlytics/android/ndk

About Me

I have been creating web pages since 1997 and writing software professionally since 2004.  I started a company called Handstand Technologies in 2010 so I could build awesome mobile and web applications for clients.  I now also work at Capital One and specialize in Android development on their Mobile Payments team.  You can find me at meetups, conferences and hackathons as an attendee or as a presenter.

When I’m not working, I enjoy traveling and doing Handstands in new places.

Connect with me on Twitter, LinkedIn.

Cheers,
-Sam Edwards