我试图将Vitamio Bundle集成到我的Android Studio项目中,但这不适用于我的步骤
>我创建了一个新的Android项目“空白活动”
>我选择文件>新模块>导入现有项目Image
>我得到了导入摘要Image的这个列表
>现在我去了档案>项目结构> app>依赖项并添加了库
然后我得到了这个错误
我发现如果我从导入的库中删除AndroidManifest.xml中的android:label =“@ string / vitamio_name”,错误就会消失
活动
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();
}
}
布局
android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/VideoView">
表现
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name=".MyActivity"
android:label="@string/app_name" >
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" />
错误
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.(MediaPlayer.java:96)
at io.vov.vitamio.MediaPlayer.(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.(Vitamio.java:129) ......
我不确定这个错误是什么意思……这是在Android Studio中安装Vitamio的正确方法吗?
解决方法:
你有没有把它添加到你的代码中?
public void onCreate(Bundle b) {
super.onCreate(b);
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;
// your code
}
我也使用vitamio库,我注意到你的代码的唯一区别是这个.我也从vitamio的AndroidManifest.xml中删除了标签,对我来说效果很好.
祝好运!
标签:android,android-studio,vitamio
来源: https://codeday.me/bug/20190628/1320344.html