0

这是我的application代码

public class StreamingApplication extends Application {

@Override
public void onCreate() {
    super.onCreate();
    StreamingEnv.init(this);
}

}

这是报错信息

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myqiniu/com.example.myqiniu.StreamingByCameraActivity}: java.lang.IllegalStateException: You must initialize StreamingEnv by StreamingEnv#init first!

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3364)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3548)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155)
    at android.os.Handler.dispatchMessage(Handler.java:109)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:7539)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
 Caused by: java.lang.IllegalStateException: You must initialize StreamingEnv by StreamingEnv#init first!
    at com.qiniu.pili.droid.streaming.StreamingEnv.a(StreamingEnv.java:86)
    at com.qiniu.pili.droid.streaming.MediaStreamingManager.a(MediaStreamingManager.java:1293)
    at com.qiniu.pili.droid.streaming.MediaStreamingManager.<init>(MediaStreamingManager.java:369)
    at com.qiniu.pili.droid.streaming.MediaStreamingManager.<init>(MediaStreamingManager.java:339)
    at com.example.myqiniu.StreamingByCameraActivity.init(StreamingByCameraActivity.java:56)
    at com.example.myqiniu.StreamingByCameraActivity.onCreate(StreamingByCameraActivity.java:34)
    at android.app.Activity.performCreate(Activity.java:7441)
    at android.app.Activity.performCreate(Activity.java:7431)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3343)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3548) 
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86) 
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155) 
    at android.os.Handler.dispatchMessage(Handler.java:109) 
    at android.os.Looper.loop(Looper.java:207) 
    at android.app.ActivityThread.main(ActivityThread.java:7539) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) ### 问题描述

问题出现的环境背景及自己尝试过哪些方法

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

你期待的结果是什么?实际看到的错误信息又是什么?

10月22日提问
1 个回答
0

init 放在 Application 中;开始推流需要在执行mMediaStreamingManager.resume();后的 state#ready状态后。

public class StreamingApplication extends Application {

@Override
public void onCreate() {
    super.onCreate();
    StreamingEnv.init(getApplicationContext());
}

}

撰写答案

推广链接