求助:怎样才能在python中用jpype调用android project的class
I can run a class of Java project with Jpype well.我可以成功用jpype调用标准Java工程的Class,但是我尝试调用android project的class时失败了。
Android Project代码如下,很简单的一个工程,只是打印出hello world字符串:
package real.android.test.hello;
import android.app.Activity;
import android.os.Bundle;
public class hello extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Python Jpype代码:
# -*- coding: UTF8 -*-
import jpype
jvmPath = jpype.getDefaultJVMPath()
classpath = r"E:\workspace\Hello\bin\real\android\test\hello"#hello.class 所在文件夹路径
jvmArg = "-Djava.class.path=" + classpath
jpype.startJVM(jvmPath, jvmArg)
javaClass = jpype.JClass("real.android.test.hello.hello")
执行python脚本错误Infomation:
Traceback (most recent call last):
File "testJpype.py", line 7, in ?
javaClass = jpype.JClass("real.android.test.hello")
File "E:\Python24\Lib\site-packages\jpype\_jclass.py", line 54, in JClass
raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.java.lang.ExceptionPyRaisable: java.lang.Exception: Class real
.android.test.hello not found.
请大家帮忙,多谢! --------------------编程问答-------------------- setContentView(R.layout.main);
在代码里面自定义布局,看看行不?
--------------------编程问答-------------------- 待解,求解
补充:移动开发 , Android