我在android上的ti.paint模块有错误。 每当我尝试设置图像时,我的应用程序崩溃(在iOS上运行正常) 我尝试了几个代码:
var paintView = Paint.createPaintView({
top:0, right:0, bottom:80, left:0,
image : "images/doge.png",
eraseMode : true,
strokeWidth : 70
});
和
image : "/images/doge.png"
也
image = "http://dogr.io/doge.png"
最后
var dogeFile = Titanium.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'images/doge.png');
var paintView = Paint.createPaintView({
top:0, right:0, bottom:80, left:0,
image : dogeFile.nativePath,
eraseMode : true,
strokeWidth : 70
});
但是应用程序每次都在Android上崩溃(在iOS上运行正常)。
我也尝试过使用jpeg图像,甚至是NULL值。
以下是我在控制台中收到的错误消息
[ERROR] TiApplication: (main) [0,205] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{wow.much.scratch/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException; Titanium 3.2.3,2014/04/22 10:17,b958a70
[ERROR] TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{wow.much.scratch/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException
[ERROR] TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
[ERROR] TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
[ERROR] TiApplication: at android.app.ActivityThread.access$600(ActivityThread.java:141)
[ERROR] TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
[ERROR] TiApplication: at android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] TiApplication: at android.os.Looper.loop(Looper.java:137)
[ERROR] TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5103)
[ERROR] TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] TiApplication: at java.lang.reflect.Method.invoke(Method.java:525)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[ERROR] TiApplication: at dalvik.system.NativeStart.main(Native Method)
[ERROR] TiApplication: Caused by: java.lang.NullPointerException
[ERROR] TiApplication: at ti.modules.titanium.paint.UIPaintView$PaintView.setImage(UIPaintView.java:224)
[ERROR] TiApplication: at ti.modules.titanium.paint.UIPaintView.<init>(UIPaintView.java:42)
[ERROR] TiApplication: at ti.modules.titanium.paint.PaintViewProxy.createView(PaintViewProxy.java:30)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:463)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:566)
[ERROR] TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:544)
[ERROR] TiApplication: at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:303)
[ERROR] TiApplication: at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32)
[ERROR] TiApplication: at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:452)
[ERROR] TiApplication: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:528)
[ERROR] TiApplication: at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR] TiApplication: at android.app.Activity.performCreate(Activity.java:5133)
[ERROR] TiApplication: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[ERROR] TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
[ERROR] TiApplication: ... 11 more
我正在运行Titanium SDK 3.2.3.GA。
任何帮助都将不胜感激。
答案 0 :(得分:0)
我目前正在使用ti.paint,我遇到了与Android相同的问题。 Android的管理视图与Titanium的管理视图不同,这就产生了问题...... 想法是使用主线程。
这里是PaintViewProxy.java模块的变化:
@Kroll.setProperty
@Kroll.method
public void setImage(String imagePath) {
final String imgPath = imagePath;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
paintView.setImage(imgPath);
}
});
}
重新编译它应该有效,它对我有用。 我希望你有帮助...