Reach 4 million Unity developers



Similar documents
Java Interview Questions and Answers

Using Safari to Deliver and Debug a Responsive Web Design

Lecture 32: The Java Virtual Machine. The Java Virtual Machine

Crash Course in Java

HybriDroid: Analysis Framework for Android Hybrid Applications

Multithreading and Java Native Interface (JNI)!

Java Programming Fundamentals

About me. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

To Java SE 8, and Beyond (Plan B)

An Overview of Java. overview-1

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Affdex SDK for Android. Developer Guide For SDK version 1.0

CROSS-PLATFORM MOBILE MALWARE - WRITE ONCE INFECT EVERYWHERE. William Lee & Xinran Wu {william.lee, xinran.wu}@sophos.com.

Build apps your users will love with Xamarin. Mobile Edge 11 Nov 2015

IBM SDK, Java Technology Edition Version 1. IBM JVM messages IBM

Plugin JUnit. Contents. Mikaël Marche. November 18, 2005

- Applet java appaiono di frequente nelle pagine web - Come funziona l'interprete contenuto in ogni browser di un certo livello? - Per approfondire

Spring Design ScreenShare Service SDK Instructions

CS506 Web Design and Development Solved Online Quiz No. 01

Developing multi-platform mobile applications: doing it right. Mihail Ivanchev

International Journal of Advanced Engineering Research and Science (IJAERS) Vol-2, Issue-11, Nov- 2015] ISSN:

JAXB Tips and Tricks Part 2 Generating Java Classes from XML Schema. By Rob Ratcliff

Using EDA Databases: Milkyway & OpenAccess

Android NDK Native Development Kit

University of Twente. A simulation of the Java Virtual Machine using graph grammars

MENDIX FOR MOBILE APP DEVELOPMENT WHITE PAPER

Lecture 1 Introduction to Android

Research and Design of Universal and Open Software Development Platform for Digital Home

RMI Client Application Programming Interface

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Introduction to Android

Mobile App Sensor Documentation (English Version)

Native code in Android Quad Detection

Extending your Qt Android application using JNI

CSC 551: Web Programming. Spring 2004

The Decaffeinated Robot

HTTPS hg clone plugin library SSH hg clone plugin library

With a single download, the ADT Bundle includes everything you need to begin developing apps:

Virtual Machines. Case Study: JVM. Virtual Machine, Intermediate Language. JVM Case Study. JVM: Java Byte-Code. JVM: Type System

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

Lecture 17: Mobile Computing Platforms: Android. Mythili Vutukuru CS 653 Spring 2014 March 24, Monday

QL Integration into Scala and Excel. Martin Dietrich

AAC-ELD based Audio Communication on Android

JavaCard. Java Card - old vs new

Java Cheatsheet. Tim Coppieters Laure Philips Elisa Gonzalez Boix

Rootbeer: Seamlessly using GPUs from Java

BogDan Vatra and Andy Gryc. Qt on Android: Is it right for you?

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

App Events and Facebook Analytics for Apps

This documentation is made available before final release and is subject to change without notice and comes with no warranty express or implied.

Kerberos + Android. A Tale of Opportunity. Slide 1 / 39. Copyright 2012 yassl

How to Run Your Existing Android APK on the Tizen Platform. Chandra Bajpai Matt O Keefe OpenMobile World Wide

Enabling Cordova (aka PhoneGap) on Tizen. René Pourtier / Luc Yriarte

Built-in Concurrency Primitives in Java Programming Language. by Yourii Martiak and Mahir Atmis

ELEC 377. Operating Systems. Week 1 Class 3

EasyPush Push Notifications Extension for ios

02 B The Java Virtual Machine

Cross Platform Mobile. -Vinod Doshi

General Introduction

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Java Universal Binding: Storing Java Objects in Relational and Object-Oriented Databases

Introduction to NaviGenie SDK Client API for Android

WebView addjavascriptinterface Remote Code Execution 23/09/2013

Parameter Passing. Standard mechanisms. Call by value-result Call by name, result

Top 10 Issues for Java in Production. SriSatish Ambati Cliff Click Jr. Azul Systems, Inc

Kotlin for Android Developers

ios Application Development &

How To Develop Android On Your Computer Or Tablet Or Phone

Implementation Aspects of OO-Languages

An Introduction to Android Application Development. Serdar Akın, Haluk Tüfekçi

Frameworks & Android. Programmeertechnieken, Tim Cocx

Mobile Test Automation Framework

Android Hands-On Labs

Android Development. Marc Mc Loughlin

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

HP AppPulse Mobile. Adding HP AppPulse Mobile to Your Android App

WEARIT DEVELOPER DOCUMENTATION 0.2 preliminary release July 20 th, 2013

CSC230 Getting Starting in C. Tyler Bletsch

Computer Graphics on Mobile Devices VL SS ECTS

Tutorial on OpenCV for Android Setup

Using the VMRC Plug-In: Startup, Invoking Methods, and Shutdown on page 4

Extending Tizen Native Framework with Node.js

Using AllJoyn with Apache Cordova, Python & Node

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts

Introduction to Java. CS 3: Computer Programming in Java

Smartphone market share

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

Messing with the Android Runtime

ASM 4.0 A Java bytecode engineering library. Eric Bruneton

Developing Google Android Mobile Clients for Web Services: a Case Study

jcardsim Java Card is simple!

BERLIN. 2015, Amazon Web Services, Inc. or its affiliates. All rights reserved

Universal Mobile Ads is a plugin for Unreal Engine 4 that enables the MoPub ad mediation system for ios & Android.

A Native Client for the Hadoop Distributed Filesystem by Colin P. McCabe

OpenCV on Android Platforms

DEVELOPING NFC APPS for BLACKBERRY

Transcription:

Reach 4 million Unity developers with your Android library Vitaliy Zasadnyy Senior Unity Dev @ GetSocial Manager @ GDG Lviv Ankara Android Dev Days May 11-12, 2015

Why Unity?

Daily Users 0 225 M 450 M 675 M 900 M Source: Unreleased McKinsey report; Facebook http://newsroom.fb.com/company-info/

Daily Users 0 225 M 450 M 675 M 900 M Source: Unreleased McKinsey report; Facebook http://newsroom.fb.com/company-info/

Unity Developers 4M Unity Source: Unity Technologies

Unity Developers 18M Worldwide 4M Unity Source: Global Developer Population and Demographic Study 2014

Unity Developers Source: Unity Technologies

Unity is Android in game engine world

GetSocial Unity SDK Architecture Unity SDK C# API ios Bridge Android Bridge ios SDK Android SDK Java Objective C C#

During Android Build Unity SDK C# API ios Bridge Android Bridge ios SDK Android SDK

Unity Game Structure C# Scripts Unity Mono VM Apk Unity Core OS Android

Unity Game Structure? C# Scripts Unity Mono VM Java Code Apk Unity Core OS Android

Provided Wrappers Android / Java Unity / C# primitive types java.lang.string java.lang.object java.lang.class java.lang.runnable java.lang.proxy primitive types string AndroidJavaObject AndroidJavaClass AndroidJavaRunnable AndroidJavaProxy

Provided Wrappers Android / Java Unity / C# primitive types java.lang.string java.lang.object java.lang.class java.lang.runnable java.lang.proxy primitive types string AndroidJavaObject AndroidJavaClass AndroidJavaRunnable AndroidJavaProxy

Two-way communication C# Java

Two Way Communication C# Java AndroidJavaObject Pure JNI (Java Native Interface) Java C# Unity Messaging AndroidJavaProxy

Sample Java class Java public class Speaker { private String name; public Speaker(String name) { } } public static Speaker copy(speaker speaker) { } public String askquestion(string question) { }

AndroidJavaObject Wrapper around java.lang.object C# var jspeaker = new AndroidJavaObject( com.zasadnyy.speaker, Vitaliy ); var jclone = jspeaker.callstatic<androidjavaobject>( copy, jspeaker); var answer = jspeaker.call<string>( askquestion, HDYD? );

Pure JNI C# // var jspeaker = new AndroidJavaObject( // com.zasadnyy.speaker, Vitaliy ); IntPtr classid = jni.findclass("com.zasadnyy.speaker"); IntPtr constructorid = jni.getmethodid(classid, "<init>", "(Ljava/lang/String;)V"); IntPtr javastring = jni.newstringutf("vitaliy"); IntPtr objectid = jni.newobject(classid, constructorid, javastring);

JNI Cheatsheet B byte S short C char V void F float Z boolean I int Lclass; class J long [type> array of type

JNI Cheatsheet / Example long mymethod(int n, String s, int[] arr) (ILjava/lang/String;[I>)J B byte S short C char V void F float Z boolean I int Lclass; class J long [type> array of type

JNI is slooooow! Respect 16ms rule

Conclusion Use AndroidJavaObject: Less boilerplate Less error prone Faster (caching) But: JNI is more flexible AndroidJavaObject has bugs

AndroidJavaObject Bugs * C# var result = javaobject.call<tresult>(tparam param); we can t pass string[] as TParam (NoSuchMethodException) we can t return null objects from Java (Exception: JNI: Init'd AndroidJavaObject with null ptr!) * Tested on Unity 5.0.1f1

Two Way Communication C# AndroidJavaObject Pure JNI (Java Native Interface) Java C# Unity Messaging AndroidJavaProxy

Unity Messaging

Unity Messaging UnityPlayer.UnitySendMessage( Java "GameController", "OnPushMessage", "New gift");

Unity Messaging Pros: Quick to implement Cons: Always 1 frame late Only string parameters Requires GameObject Requires unity-classes.jar in classpath

AndroidJavaProxy Wrapper around java.lang.proxy Java public interface IPushMessageListener { } void onpushmessage(string message);

AndroidJavaProxy Java public interface IPushMessageListener { } void onpushmessage(string message); C# public class PushMessageListener : AndroidJavaProxy { public PushMessageListener() : base("com.zasadnyy.ipushmessagelistener") { } } void onpushmessage(string message) { }

AndroidJavaProxy Pros: Immediate result No type restriction on parameters No extra dependencies on Java side Cons: Bug with null string parameter Local reference table is limited to 512 entries

Devil is in the details

Details Unity is single threaded Unity main thread!= Android main thread Implement equals() in all AndroidJavaProxy ies Differences between GameObject and Activity lifecycle Keep calm and signal 11

Thank you! Vitaliy Zasadnyy @zasadnyy Presentation will be available at: v.zasadnyy.com/slides/