Monthly Archives: March 2016

XCode and the App Store!

While getting ready to update an old App, I realized I needed to update XCode to build to the latest iOS release I’d installed on my phone…

After lots of waiting, watching, clicking and hair pulling, I’ve decided to never ever never update XCode via the App Store again…

Just go to https://developer.apple.com/downloads/ and download it from there – much better and pretty straight forward.¬† Trust me, you’ll be a lot happier for it.

Ok – FAIR WARNING – XCode 7.3 requires OSX 10.11 or higher (El Capitan), that’s a real bummer for me as I’d been holding off upgrading my Mac – guess I’ve no option now ūüė°ūüė°ūüė°.

JNI Type signatures

For my future reference, one of the things that will show up when you’re debugging your java stuff are functions with signatures.

The official documentation is here: http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/types.html#wp16432

But for quicker access, here’s what matters:

Type Signature

Java Type

Z

boolean

B

byte

C

char

S

short

I

int

J

long

F

float

D

double

L fully-qualified-class ;

fully-qualified-class

[ type

type[]

( arg-types ) ret-type

method type

For example, the Java method:

long f (int n, String s, int[] arr); 

has the following type signature:

(ILjava/lang/String;[I)J 

 

More Java issues

I’ve upgraded some of the projects I’ve been working on to Unity 5 and at the same time, I upgraded the Google Play Unity plugin to the latest version.

The GP plugin now uses AAR files (a android library file) instead of JARs (a standard java library file).¬† Unity 5 prefers AAR’s so that makes sense.¬† However, I ran into a headscratcher when my plugins (JAR files) started giving me the ‘java.lang.NoSuchMethodError’ errors again.

I verified I had all the libraries I needed in my Plugin folder so I couldn’t see what the problem was.¬† As I was messing with various debug additions I noticed the the standard GooglePlay folder was being deleted by something in Unity from my Plugin folder, and that this was the root of the problem.

A little more digging and I discovered that the new version of the GPlay plugin will remove that folder from Plugin/Android and then includes the ‘referenced’ parts of the library when you compile it for your android build.¬† As their plugin didn’t use the advertising or analytic’s part of the GPlay libraries, it was not including it in the final APK, and my plugins would then fail as I use both of those.

They have a mechanism to create a c# class that their code will pull in and let you add additional dependencies, which in turn enables those sections to be included in the APK.¬† I wasn’t able to figure that out, and in frustration (I’d already spent several hours tracking this down) I just modified a file in their plugin to include the dependencies I wanted.

I modified the static constructor by adding two lines to PlayServicesResolver.cs

        static PlayServicesResolver()
        {
            svcSupport = PlayServicesSupport.CreateInstance(
                PlayServicesResolver,
                EditorPrefs.GetString(AndroidSdkRoot),
                ProjectSettings);
            //CG  added the following two lines
            svcSupport.DependOn(com.google.android.gms, playservicesads, GooglePlayGames.PluginVersion.PlayServicesVersionConstraint);
            svcSupport.DependOn(com.google.android.gms, playservicesanalytics, GooglePlayGames.PluginVersion.PlayServicesVersionConstraint);

        }

These two lines keep the analytics and AdMob modules in the final APK and most importantly, let my plugins function as expected.¬† When I have time, I’ll figure out the correct way to do this.