代码:
package com.example.shengwang;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.view.SurfaceView;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.ui.action.BasicComponentData;
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.ui.component.basic.WXBasicComponent;
import io.agora.rtc.IRtcEngineEventHandler;
import io.agora.rtc.RtcEngine;
public class PlayVid extends WXComponent<FrameLayout> {
public PlayVid(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData) {
super(instance, parent, basicComponentData);
init();
}
public void init(){
System.out.println("执行");
try{
RtcEngine mRtcEngine =RtcEngine.create(getContext(), "123", new IRtcEngineEventHandler() {
@Override
public void onJoinChannelSuccess(String s, int i, int i1) {
// super.onJoinChannelSuccess(s, i, i1);
System.out.println("Rtc:"+i);
}
});
}catch(Exception e){
System.out.println("123");
}
}
@Override
protected FrameLayout initComponentHostView(@NonNull Context context) {
// return super.initComponentHostView(context);
FrameLayout frameLayout = new FrameLayout(context);
SurfaceView SurfaceView=new SurfaceView(context);
TextView text = new TextView(context);
text.setText("TextView");
frameLayout.addView(text);
return frameLayout;
}
//注释掉此行代码 就不报错了
public IRtcEngineEventHandler mRtcEngineEventHandler = new IRtcEngineEventHandler() {
@Override
public void onJoinChannelSuccess(String s, int i, int i1) {
// super.onJoinChannelSuccess(s, i, i1);
// System.out.println("onJoinChannelSuccess:"+s);
}
};
}
报错内容
E/weex: WXComponentFactory Exception type:[PlayVido] java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.taobao.weex.ui.SimpleComponentHolder$ClazzComponentCreator.createInstance(SimpleComponentHolder.java:98)
at com.taobao.weex.ui.SimpleComponentHolder.createInstance(SimpleComponentHolder.java:189)
at com.taobao.weex.ui.component.WXComponentFactory.newInstance(WXComponentFactory.java:66)
at com.taobao.weex.ui.action.GraphicActionAbstractAddElement.createComponent(GraphicActionAbstractAddElement.java:61)
at com.taobao.weex.ui.action.GraphicActionAddElement.<init>(GraphicActionAddElement.java:86)
at com.taobao.weex.bridge.WXBridgeManager.callAddElement(WXBridgeManager.java:2799)
at com.taobao.weex.bridge.WXBridge.callAddElement(WXBridge.java:535)
at com.taobao.weex.base.SystemMessageHandler.nativeRunWork(Native Method)
at com.taobao.weex.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:104)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.NoClassDefFoundError: com.example.shengwang.PlayVid$1
at com.example.shengwang.PlayVid.init(PlayVid.java:47)
at com.example.shengwang.PlayVid.<init>(PlayVid.java:24)
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.taobao.weex.ui.SimpleComponentHolder$ClazzComponentCreator.createInstance(SimpleComponentHolder.java:98)
at com.taobao.weex.ui.SimpleComponentHolder.createInstance(SimpleComponentHolder.java:189)
at com.taobao.weex.ui.component.WXComponentFactory.newInstance(WXComponentFactory.java:66)
at com.taobao.weex.ui.action.GraphicActionAbstractAddElement.createComponent(GraphicActionAbstractAddElement.java:61)
at com.taobao.weex.ui.action.GraphicActionAddElement.<init>(GraphicActionAddElement.java:86)
at com.taobao.weex.bridge.WXBridgeManager.callAddElement(WXBridgeManager.java:2799)
at com.taobao.weex.bridge.WXBridge.callAddElement(WXBridge.java:535)
at com.taobao.weex.base.SystemMessageHandler.nativeRunWork(Native Method)
at com.taobao.weex.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:104)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
E/weex: [WXBridgeManager] callAddElement exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.taobao.weex.dom.WXAttr com.taobao.weex.ui.component.WXComponent.getAttrs()' on a null object reference
at com.taobao.weex.ui.RenderContextImpl.registerComponent(RenderContextImpl.java:86)
at com.taobao.weex.ui.WXRenderManager.registerComponent(WXRenderManager.java:306)
at com.taobao.weex.ui.action.GraphicActionAbstractAddElement.createComponent(GraphicActionAbstractAddElement.java:62)
at com.taobao.weex.ui.action.GraphicActionAddElement.<init>(GraphicActionAddElement.java:86)
at com.taobao.weex.bridge.WXBridgeManager.callAddElement(WXBridgeManager.java:2799)
at com.taobao.weex.bridge.WXBridge.callAddElement(WXBridge.java:535)
at com.taobao.weex.base.SystemMessageHandler.nativeRunWork(Native Method)
at com.taobao.weex.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:104)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
E/weex: commitCriticalExceptionRT :WX_KEY_EXCEPTION_INVOKE_BRIDGEexceptionjava.lang.NullPointerException: Attempt to invoke virtual method 'com.taobao.weex.dom.WXAttr com.taobao.weex.ui.component.WXComponent.getAttrs()' on a null object reference
at com.taobao.weex.ui.RenderContextImpl.registerComponent(RenderContextImpl.java:86)
at com.taobao.weex.ui.WXRenderManager.registerComponent(WXRenderManager.java:306)
at com.taobao.weex.ui.action.GraphicActionAbstractAddElement.createComponent(GraphicActionAbstractAddElement.java:62)
at com.taobao.weex.ui.action.GraphicActionAddElement.<init>(GraphicActionAddElement.java:86)
at com.taobao.weex.bridge.WXBridgeManager.callAddElement(WXBridgeManager.java:2799)
at com.taobao.weex.bridge.WXBridge.callAddElement(WXBridge.java:535)
at com.taobao.weex.base.SystemMessageHandler.nativeRunWork(Native Method)
at com.taobao.weex.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:104)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
4 个回复
2***@qq.com (作者)
有人能解答吗
2***@qq.com (作者)
???????????
2***@qq.com (作者)
???????????????????
1***@163.com - 拉直索尔
解决了吗