Roughly there are two types of JAR files: JAR files that act like a stub and JAR files that contain an actual implementation.
We already support this type of JAR file. When you right-click your project in Visual Studio, you will see a menu item 'Add Jar Reference...'. This will generate some C# code in the background that reflects the API of the stub JAR. You can code against it and dot42 will link this accordingly during compilation. In order to link to the actual implementation, you had to enter the library name in the "Add Jar Reference..." dialog. This library name is used in the generated C# code in an assembly attribute like this:
When we open the Google Cloud Messaging gcm.jar and navigate to onReceive, we see that there is actual code:
So, this is a JAR that contains the actual implementation.
But if we then open the Google Maps maps.jar, and navigate to method Overlay.draw, we see the following:
It has no implementation. It just throws a runtime exception. Also note the "stub" in the code. This is a stub JAR.
Stub JAR
The Google maps API (v1) is a good example of a stub JAR. The maps funtionality is implemented elsewhere and the stub basically forwards calls to it.We already support this type of JAR file. When you right-click your project in Visual Studio, you will see a menu item 'Add Jar Reference...'. This will generate some C# code in the background that reflects the API of the stub JAR. You can code against it and dot42 will link this accordingly during compilation. In order to link to the actual implementation, you had to enter the library name in the "Add Jar Reference..." dialog. This library name is used in the generated C# code in an assembly attribute like this:
[assembly: UsesLibrary("com.google.android.maps")]
This assembly attribute is the equivalent of the uses-library element as in the following application's manifest file:<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package.name">
...
<application android:name="MyApplication" >
<uses-library android:name="com.google.android.maps" />
...
</application>
...
</manifest>
Implementation JAR
The second type contains an actual implementation. The Google Cloud Message JAR (gcm.jar) falls under this category. Unfortunately we do not support this one yet. The good news is that it is not on our 5-years roadmap but is being implemented right now. It involves converting Java byte code to Dex just like we already convert IL code to Dex. We expect to release it in the next 4 weeks.How to determine the type of JAR?
So, how to tell what type a given JAR file is? dot42 ships with a handy tool: dot42ApkSpy. Although its name suggests differently, it allows you to inspect both APK and JAR files. You can find this tool at "c:\Program files\dot42\dot42ApkSpy.exe".When we open the Google Cloud Messaging gcm.jar and navigate to onReceive, we see that there is actual code:
So, this is a JAR that contains the actual implementation.
But if we then open the Google Maps maps.jar, and navigate to method Overlay.draw, we see the following:
It has no implementation. It just throws a runtime exception. Also note the "stub" in the code. This is a stub JAR.









