[英]newInstance failed: no <init>
I cannot instantiate a sub activity. 我无法实例化子活动。 In the logcat I see this line: 在logcat中我看到这一行:
01-22 15:14:38.906: DEBUG/dalvikvm(411): newInstance failed: no <init>()
This is the line in dalvik that generates that logcat. 这是dalvik中生成该logcat的行。
/*
* public T newInstance() throws InstantiationException, IllegalAccessException
*
* Create a new instance of this class.
*/
static void Dalvik_java_lang_Class_newInstance(const u4* args, JValue* pResult)
...
/* find the "nullary" constructor */
init = dvmFindDirectMethodByDescriptor(clazz, "<init>", "()V");
if (init == NULL) {
/* common cause: secret "this" arg on non-static inner class ctor */
LOGD("newInstance failed: no <init>()\n");
dvmThrowExceptionWithClassMessage("Ljava/lang/InstantiationException;",
clazz->descriptor);
RETURN_VOID();
}
Here is the action I take to activate the activity in a timer handler. 以下是我在计时器处理程序中激活活动的操作。
// move on to Activation
// ePNSplash is this activity a splash screen
Intent i = new Intent (ePNSplash.this, Activation.class);
startActivity (i);
The activity that I am trying to start is 2 extensions above Activity 我尝试启动的活动是活动上方的2个扩展
Here is the first extension 这是第一个扩展
public abstract class AndroidScreen extends Activity {
....
public AndroidScreen (String title, AndroidScreen parent, AndroidScreen main)
{
super ();
myGlobals = Globals.getGlobals ();
myGlobals.myLogger.logString("AndroidScreen: 001");
myParent = parent;
myMainScreen = main;
myTitle = title;
}
This is only the constructor, which seems to be the part that has the problem. 这只是构造函数,它似乎是有问题的部分。 Here is the 2nd extension and the class i am trying to instantiate. 这是第二个扩展和我试图实例化的类。
public class Activation extends AndroidScreen {
public Activation (String title, AndroidScreen parent, AndroidScreen main)
{
super (title, parent, main);
}
I am absolutely confused, I have a constructor, I make sure I call my super constructors, what could possibly be wrong? 我绝对困惑,我有一个构造函数,我确保我调用我的超级构造函数,可能是什么错误?
Thank you 谢谢
Julian 朱利安
dalvikvm's looking for a zero-argument constructor (that's what they mean by "nullary", as in "binary" for 2 arguments, "unary" for 1 argument, it's "nullary" for 0 arguments). dalvikvm正在寻找一个零参数构造函数(这就是“nullary”的含义,如2个参数的“binary”,1个参数的“unary”,0个参数的“nullary”)。
in the snippet you've shown, you only have a three-argument constructor. 在您展示的代码段中,您只有一个三参数构造函数。 that's no good: you'll be instantiated with no arguments, so you need a zero-argument constructor. 这不好:你将被实例化而没有参数,所以你需要一个零参数构造函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.