4

I was trying to integrate Vitamio Bundle in my Android Studio project, and it didn't work here is my steps

  1. I created a new Android Project "Blank Activity"
  2. The i select File > New Module > import Existing Project Image
  3. I got this list of import Summary Image
  4. Now i went to file > Project Structure > app > dependencies and Added the Library

enter image description here


Then i got this error

enter image description here

i found out that if i remove the android:label="@string/vitamio_name" in the AndroidManifest.xml from the imported library the error will go away


i followed the instruction from here Vitamio Bundle

Activity

   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();
}
}

Layout

 <io.vov.vitamio.widget.VideoView
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" android:id="@+id/VideoView">
  </io.vov.vitamio.widget.VideoView>

Manifest

<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>

Error

         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) ...... 

I'm not sure what does that error means... and is this is the right way for installing Vitamio in Android Studio?

Community
  • 1
  • 1
Mina Gabriel
  • 17,138
  • 23
  • 89
  • 118

2 Answers2

3

Have you added this to your code?

    public void onCreate(Bundle b) {
        super.onCreate(b);
        if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
        return;
        // your code
   }

I am using vitamio library as well and the only difference I notice with your code is this. I have also removed the label from vitamio's AndroidManifest.xml and works fine for me.

Good luck!

user4467097
  • 103
  • 1
  • 10
0

After added Vitamio as module, Do not forget to add these lines in Vitamio build.gradle

 jniLibs.srcDirs = ['libs']

Other vice app will not work.