So I’ve used iAd’s before with Unity iPhone. With iPhone the build process makes you an Xcode project so it’s really easy to load in Xcode. =)
But with Android? I’m not sure what I’m doing so I’m wondering if anyone can point me in the right direction. If you do a build from Unity Android… can you open the project in Eclipse? I have the Android SDK and the Mobclix SDK… but can’t seem to put ads into even the simplest “Hello World” program. I just hit a brick wall trying to get ads running on any Android build. I’m still fighting with configs right now so I don’t have one specific problem. I’m really just wondering if it’s even possible or supported at this time. Any suggestions? I can’t seem to find any good info in a general Google search so I thought I’d post here to see if anyone is doing something similar.
The problem is that most (all?) ad services provide an SDK written in Java and while that is fine for a developer that wrote most of his/her code in Java from the start (makes it reasonably easy to integrate) it’s a bit harder for developers not fluent in Java (Unity developers) to understand how it can be integrated into Unity. It’s obviously necessary to have some knowledge how Java works generally and, in some cases, also how Java works specifically on Android to integrate third party services into your Android product (similar to the problems with Objective C on iPhone). We are striving to make this hurdle a little bit easier in the future, and we aim to have a better/more generic plugin support to make it easier both for Unity developers but also third party developers to create the necessary “glue-code”.
Yes, unfortunately our developers aren’t familiar enough with the Unity engine to provide support.
You might try Prime31, he’s the brains behind the iOS plug-in. Perhaps you could lobby for an Android version?
So I tried just using the simple “hello world” walkthrough about exporting a class as a .JAR file. Then using a little app called IKVM…
You can convert that .JAR over to a .DLL. Then drop it in your plugins folder along with all the other IKVM files. Then you can access it with a C# script. Not an easy feat for a guy who ran out and bought Unity cause it was cool… and really isn’t a groomed developer. But yes, it DOES seem there is a way to get a Java class over to Unity for use.
The hello world demo was easy enough to do and did work in Unity3 and ran like a charm on my Nexus One. But the same thing does not work when trying to use the mobclix.jar file from the Mobclix SDK. When I try to make the conversion, I get spammed with errors like… let me just paste a few of them here.
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in “com.mobclix.android.sdk.Mobclix$FetchRemoteConfig.run()V”
(“android.content.Context”)
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in “com.mobclix.android.sdk.Mobclix$FetchRemoteConfig.downloadCustomImages()V”
(“org.apache.http.impl.client.DefaultHttpClient”)
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in “com.mobclix.android.sdk.Mobclix$LogEvent.run()V”
(“org.json.JSONObject”)
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in “com.mobclix.android.sdk.Mobclix$SessionPolling.isTopTask()Z”
(“android.content.Context”)
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in “com.mobclix.android.sdk.Mobclix$Sync.run()V”
(“android.content.Context”)
And there’s plenty more where those came from. I feel I’m close, but this kind of thing is way over my head.
I’m really hung out to dry with getting an Android App with ads on it. I don’t really care which AD network I use. I took a brief look at ad mob. Couldn’t seem to figure that out. Mobclix seemed to be the best chance because I am most familiar with Java. I’m a QA Tech by day and use Eclipse for some basic Selenium and JUnit scripts. But trying to do this conversion… I’m not that confident I’ll get it to work. Eh, still won’t stop me from trying though. Thanks for the replies though.
Wow, so I can access a .Jar file directly from the Plugins folder? But I guess I have to make my own .Jar file and can’t just drop in the mobclix.jar and expect it to work. I’ll def take a stab at this Java example that you provided.
I still wish that Unity Android had an option to export a project that I can run in Eclipse. Much like Unity iPhone exports to Xcode. I was really expecting that would be included as an option in Unity Android and still kind of surprised I can’t do it. It just feels like a lot of redundant work. Wouldn’t it make integration with other ad networks easier, who are Java based, rather than have me write my own plugin to keep everything inside of Unity?
It will pick up any .jar file, including the mobclix.jar.
Actually it would not, once the support for Android project layout is included (which it will be in 3.1). If you want to call Java from C# you would still have to go through a native call. You can set up the eclipse project in the plugins folder to deal with any customization.
That said; Unity Android is still preview, and as such will not have all of the features available on iPhone just yet.
Hey, was anyone able to package an easy to use jar file to run Mobclix ad’s in Unity?
I’ve been working on one myself, but still have more work to do on it. I started off using apktool to unpack the Unity Android build project, but you cannot add an ad that way due to the way Unity sets up it’s files.
Like you guys have already mentioned, making a jar file in the plugins folder is the best bet to get them working. I got mobclix ad’s to work in my Unity apps by creating a class that extends UnityPlayerActivity and implements MobclixAdViewListener, but by doing this it overrides the icon, the app_name string, and some other fields that I would rather it not override so I don’t have to make a custom jar for each one of my apps. Also, the only way I’ve been able to get it to work is copying the entire contents of my Eclipse project folder with the jar file in the bin directory into the plugins folder. I would much rather have a build script call my jar file like this thread talks about: http://forum.unity3d.com/threads/64680-Android-Admob-Problems I haven’t had a chance to play around with this idea yet though.
Anyway, just checking in to see if anyone else has got them working in a nice package. I’m brand new to Unity and fairly new to Android, so I’m a little stumped on where to go from here hehe
Basically I just gave up and kept high hopes that someone who knew what they were doing would code up a plugin. =) I gotta focus on what I can make progress at. Getting into the nitty gritty of writing Java plugins? Not this guy.