How does dalvikvm understand the starting point of android application - dalvik

I can successfully run a simple java program in dalvikvm by converting the java class into dex file. But when I try to run android application by converting its class files into dex, it says static main(String args[]) not found.
Android application does not contain static main() method.
So where does dalvikvm start executing an android application or how does it find the static main() method in android application???

Android determines your app's entry point based on the AndroidManifest.xml shipped with your app. Specifically, Android determines which intent was sent to the app (to cause it to launch), and will instantiate the appropriate Activity and call its onCreate method. This creation process is overseen by a wrapper process called app_process, which calls into dalvik directly and sets up the app execution environment.
Dalvik itself behaves like a normal Java JVM in most regards; therefore, running a jar or dex with Dalvik will still expect a main method, as with normal Java.

Related

java.lang.NoClassDefFoundError on Android 4.4 or lower

I've got an Android application that I recently upgraded to the Gradle build system among other things, such as using a newer version of build tools, etc.
My targetSdkVersion is 19, so I should be good to go on Android 4.4 and higher. When I run using a 5.0+ device, all is well; however Android 4.4 always crashes with a java.lang.NoClassDefFoundError error of some sort.
As a test, I removed original class that it complained about missing only to have it crash while pointing at a different class.
The first class that it crashed on was an internal private class in a 3rd party library. After removing that library, it pointed to a internal private class in the app itself.
In summary:
the app runs fine on Android 5.0+. It crashes with java.lang.NoClassDefFoundError on anything less than 5.0.
In tests so far, the NoClassDef always seems to refer to an inner class - this is just based on two tests, so it may not be anything concrete.
Here's my android.manifest file: https://gist.github.com/rscott78/19dd88ccde66172d9332
For what it's worth, this can happen when you enable multi-dex support without adding the correct code in your Application class.
Create a class, have it inherit from Application, then add this override:
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
In your AndroidManifest, add a name attribute to your application tag:
<application name=".MyApplication"

Decompiled method of Xamarin.iOS application is empty

I tryed to decompile iOS application developed by Xamarin.iOS(Xamarin.Forms), But ILSpy and NET Reflector couldn't decompile all methods correctly. Decompiled method body is prefectly empty.
What can i do for this problem?
The only thing you will find in a Xamarin Dll inside the app bundle is some metadata required by the runtime. All methods logic won't be there because it has been AOT'ed and now the logic lives inside the native binary itself. This is mainly because iOS does not allow dynamic code generation.
You can read more info about how Xamarin works here
Hope this helps.

Is there a way i could call a gradle task from within the java program

I want the android app that is being tested to be uninstalled everytime a new test method in the class runs. I know that gradle uninstallAll task does this. But i would like to call this task from the setup method of the testcase class.

Creating console MonoMac application

I need to create a console MonoMac application.
Open Xamarin Studio and create C# console application project (not MonoMac specific).
Add reference to MonoMac assembly.
Edit Main method in Program.cs:
using System;
using MonoMac.Foundation;
namespace ConsoleTest
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine(new NSString("Hello World!"));
}
}
}
The project builds ok. But when I run it the console opens with error:
Missing method .ctor in assembly /.../ConsoleTest.exe, type MonoMac.Foundation.NSString
So the console project runs on Mac, but MonoMac assembly cannot be used. How to fix it?
Solved.
MonoMac should be compiled from sources:
Clone https://github.com/mono/monomac (including submodules).
Open terminal and run "make" in the root folder.
Find MonoMac.dll in src folder and copy it to your project directory.
Reference it directly (don't use the version bundled with Xamarin Studio).
One thing I also tried is to run NSApplication.Init() when starting the app. It seems a working solution too.

worklight adapters and Groovy

Has anyone had success implementing IBM Worklight 5.0.6 Adapters using the Groovy language? Ie. Instead of calling a Java class from the JS adapter call a Groovy class. We have tried this and it seems to work most of the time but randomly we will get strange errors when invoking an adapter procedure. Ie.
Failed to create DGM method proxy : java.lang.NoSuchMethodException: org.codehaus.groovy.runtime.dgm$24.<init>(java.lang.String, org.codehaus.groovy.reflection.CachedClass, java.lang.Class, [Ljava.lang.Class;)
FWLSE0101E: Caused by: java.lang.NoSuchMethodException: org.codehaus.groovy.runtime.dgm$24.<init>(java.lang.String, org.codehaus.groovy.reflection.CachedClass, java.lang.Class, [Ljava.lang.Class;)
Unit tests executing the Groovy code run fine within Eclipse and the Groovy code seems to be compiling fine down to .class files and included in the adapter package. We're wondering if this is an issue with Groovy itself or invoking Groovy within the Worklight server container. I believe Worklight is using Rhino behind the scenes which may also be a culprit?
We are using Groovy 2.1.5 and the Eclipse plugin 2.8
did you open the .war and check if all compiled classes and libraries are actually in there?
We had the case quite often that the WL Eclipse Plugin/Build did not compile and package our Java Classes for the Adapter in the "server" folder ... they were missing in the .war file that we deployed and we got all sorts of Rhino, ClassNotFound etc. errors.
In addition to previous answer. You can always force a rebuild by selecting the project in the Enterprise Explorer or Navigator views, then select menu Project -> Clean -> Clean Projects Selected Below (the only choice should be your project).
This will clean the binaries, then rebuild your entire project.

Resources