我试图在我的Android Studio项目中集成Vitamio
Bundle,但这里没有工作是我的步骤
然后我收到了这个错误
我发现如果我从导入的库中删除AndroidManifest.xml中的android:label="@string/vitamio_name"
,错误就会消失
我按照这里的指示Vitamio Bundle
活动
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
public class MyActivity extends Activity {
VideoView videoView;
private void test_2(){
String httpLiveUrl = "http://-------------.mp4";
videoView = (VideoView) findViewById(R.id.VideoView);
videoView.setVideoURI(Uri.parse(httpLiveUrl));
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.start();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
test_2();
}
}
布局
<io.vov.vitamio.widget.VideoView
android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/VideoView">
</io.vov.vitamio.widget.VideoView>
清单
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="io.vov.vitamio.activity.InitActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
android:launchMode="singleTop"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="stateAlwaysHidden" />
</application>
错误
09-12 13:48:27.020 1786-1786/com.stream.myapplication E/AndroidRuntime﹕ FATAL
EXCEPTION: main
Process: com.stream.myapplication, PID: 1786
java.lang.ExceptionInInitializerError
at io.vov.vitamio.MediaPlayer.<init>(MediaPlayer.java:96)
at io.vov.vitamio.MediaPlayer.<init>(MediaPlayer.java:78)
at io.vov.vitamio.widget.VideoView.openVideo(VideoView.java:221)
at io.vov.vitamio.widget.VideoView.access$2200(VideoView.java:62)
at io.vov.vitamio.widget.VideoView$9.surfaceCreated(VideoView.java:461)
at android.view.SurfaceView.updateWindow(SurfaceView.java:572)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1871)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at io.vov.utils.CPU.getFeature(CPU.java:101)
at io.vov.vitamio.Vitamio.<clinit>(Vitamio.java:129) ......
我不确定该错误意味着什么......这是在Android Studio中安装Vitamio
的正确方法吗?
答案 0 :(得分:3)
您是否已将此添加到代码中?
public void onCreate(Bundle b) {
super.onCreate(b);
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;
// your code
}
我也在使用vitamio库,我注意到你代码的唯一区别就是这个。我还从vitamio的AndroidManifest.xml中删除了标签,对我来说效果很好。
祝你好运!答案 1 :(得分:0)
在添加Vitamio作为模块后,不要忘记在Vitamio build.gradle中添加这些行
jniLibs.srcDirs = ['libs']
其他副应用程序无效。