Start a new topic

android.view.InflateException: Binary XML file line #6: Error inflating cla

android.view.InflateException: Binary XML file line #6: Error inflating cla


Hello! 

 

I am having a difficult time to get camera view to work with Navigation Drawer pattern. I load wikitude world in a separate fragment. NavigationDrawer works perfect. I load different layouts with my fragment successfully. As soon as I try loading wikitude Camera View application crash. I have downloaded a new SDK just today so I believe I am up to date. 

 

Please advise me. I am getting this error message: 

 


android.view.InflateException: Binary XML file line #6: Error inflating class com.wikitude.architect.ArchitectView

            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)


 

 

I created a separate Fragment for Wikitude World:

 

"public class MyCameraViewFragment extends Fragment "

 


 

I tried using FrameLayout as well as LinearLayout

 


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="horizontal">

    <com.wikitude.architect.ArchitectView android:id="@+id/architectView" android:layout_width="fill_parent" android:layout_height="fill_parent"/>

</LinearLayout>


 

 

 

I think I inflate correctly: 

 

 

    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,

                             Bundle savedInstanceState) {

        // Inflate the layout for this fragment

        return inflater.inflate(R.layout.fragment_my_camera_view, container, false);

    }


 

 

Here is how I instantiate Fragment from my main activity:

 


        FragmentManager fragmentManager = getSupportFragmentManager();

 

            MyCameraViewFragment myCameraViewFragment = MyCameraViewFragment.newInstance();

            fragmentManager.beginTransaction()

                    .replace(R.id.container,myCameraViewFragment)

                    .commit();


 

 

I do call all lifecycle methods but I think the code does not reach here: 

 


 

    @Override

    public void onAttach(Activity activity) {

        super.onAttach(activity);

 

    }

 

    @Override

    public void onDetach() {

        super.onDetach();

 

    }

 

 

 

 

 

 

    @Override

    public void onResume() {

        super.onResume();

        if ( this.architectView != null ) {

 

            // call mandatory live-cycle method of architectView

            this.architectView.onResume();

 

        }

 

    }

 

    @Override

    public void onPause() {

        super.onPause();

 

        // call mandatory live-cycle method of architectView

        if ( this.architectView != null ) {

            this.architectView.onPause();

 

        }

 

 

    }

 

    @Override

    public void onStop() {

        super.onStop();

    }

 

    @Override

    public void onDestroy() {

        super.onDestroy();

        if ( this.architectView != null ) {

            this.architectView.onDestroy();

        }

    }

 

 

    @Override

    public void onLowMemory() {

        super.onLowMemory();

        if ( this.architectView != null ) {

            this.architectView.onLowMemory();

        }

    }

 


 

 

 

Hi, please check that the activity in your application is declared as "extends FragmentActivity" instead of "extends Activity", this could be a part of the problem if your application uses fragments.

Gabriele, thank you very much for your response! 

Yes. The main activity that creates fragments extends FragmentActivity

public class MainActivity extends FragmentActivity

        implements NavigationDrawerFragment.NavigationDrawerCallbacks

{

 ...

}

 

When navigation item on the left is tapped I create new fragment and replace existing one: 

 


 @Override

    public void onNavigationDrawerItemSelected(int position) {

        // update the main content by replacing fragments

        FragmentManager fragmentManager = getSupportFragmentManager();

 

        if(position==0)

       {

          fragmentManager.beginTransaction()

                    .replace(R.id.container,MyCameraViewFragment.newInstance()) // Wikitude Architect 

                    .commit();

 

        } else {

        fragmentManager.beginTransaction()

                .replace(R.id.container, PlaceholderFragment.newInstance(position + 1))

                .commit();

        }

 

    }

 

 

If I load different layout.xml in MyCameraViewFragment. Then there is no exception and can switch between pages and load different layouts. As soon as I load xml file that holds ArchitectView, I start getting exception and application crashes. 

 


<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="horizontal">

    <com.wikitude.architect.ArchitectView android:id="@+id/architectView" android:layout_width="fill_parent" android:layout_height="fill_parent"/>

</FrameLayout>

 

 

Do you see what else can trigger the exception message mentioned above? 


 

Gabriele, I think I was able to reproduce the problem...

 

I have noticed another error message in log file. Please see below:  

 

myapplication4.app D/ArchitectView? Exception while getting Camera Parameters

    java.lang.RuntimeException: Fail to get camera info

            at android.hardware.Camera._getCameraInfo(Native Method)

 

I was getting this error message even with proper permissions in AndroidManifest file... I restarted the device and it started working properly. The good news is that there is no problem with Fragments or Navigation Drawer now. It works stable until I turn off device screen with Camera View on. When I turn the screen back on my application crashes. And this happens consistently on Samsung Galazy Nexus Android 4.2.1 API 17 device... After it crashes a few times like this, then I need to restart device again because I start getting error message -  "Exception while getting Camera Parameters" and of course application crashes with the same error message I created this Post with. It cannot inflate the architect world view.... 

 

I tried another device - HTC EVE 3D Android 4.0.3 API 15. My application behaves differently on this device. It never crashes when I turn off  the device screen while the Camera View with Architect world is on. I tried many times turning off and on and it never crashes. This is a very good news. Navigation Drawer and fragements also work properly. The device is older, API is older but application works much stable. 

 

Target images get recognized and image drawables(overlays) display well on either device.

 

However with the new Wikitude SDK for Android  Video Drawable on ether device fail to play even if I use Wikitude App downloaded from Android play store. I have created architect world and loaded it on my server. Then I load it using the this.architectView.load("<URL TO AR WORLD ON MY SERVER>"); The same URL consistently works and all video drawables play well on iOS. But on Android video drawables fail to play in my app or in Wikitude App itself. I tried restarting My App, Wikitude App and restarting devices, I managed to play it only once on HTC EVE 3D device but after I restarted the App again I could not play it again. Please note, the same url to Architect world works consistently well and all video drawables play on iOS. I have also updated the iOS Wikidute SDK to a newer version today.  

 

Please advise me how to fix these issues. 

 

Below are the error messages that I get on either device when Architect World is loaded. 

 

 

E/MediaPlayer? Error (1,-2147483648)

E/MediaPlayer? error (1, -2147483648)

W/System.err? java.lang.NullPointerException

 W/System.err? at com.wikitude.architect.VideoManager.a(Unknown Source)

W/System.err? at com.wikitude.architect.ArchitectWebView.playVideoCallback(Unknown Source)

W/System.err? at com.wikitude.architect.PlatformBridge.callAsyncImpl(Native Method)

 at com.wikitude.architect.PlatformBridge.callAsyncImpl(Unknown Source)

 

 

 E/VideoManager? Exception when playing video null

 

 

Thank you very much and I hope for your support. 

 

Hi, Sergey.

If you have problem when turning off and on the screen, then you should check that your Fragment also forwards the "onPause()"/"onResume()" events to the underlying ArchitectView. If the ArchitectView isn't paused when the application stops, this could cause the crash you are experiencing when resuming.

 

About the VideoDrawable, could it just be a video format compatibility issue? Did it also fail with the previous SDK release? Have you tried with another video? Could you please send the complete log of this error? It's very strange that you get a null pointer exception, are you sure that the video is loaded correctly? Maybe there is some problem loading the video, and the error is only a consequence of that?

Gabriele, thank you for your reply. Yes, lifecycle methods get called. I double checked. When I turn off device screen it calles onPause(), when I turn it back on it calles onResume() and crashes then calles onPause() then calles onDestroy(). 

I am attaching here with this post a few files. 

1. Log file taken from HTC EVO device Android 4.0.3 API 15. Application does not crash on this device but video drawables do not alway play. To get video drawables play I need to restart application a couple of times. Image drawables always work well. 

2. Log file from Samsung Galaxy Nexus Android 4.2.1 API 17. Application crashes when creen goes off and then back on. The same story with video drawables. Image drawables always work well. 

3. I am also attaching a MainActivity with two fragments declared in a single file. 

4. A sample Navigation Drawer project with one MainActivity created in Android Studio. 

Do you see where the problem is?

 

Hi Gabriele! 

Just wanted to learn if information I have attached in my post is sufficient and can help you to advise me on why video drawables most of the time fail to play on Android and why application crashes in Nexus Galaxy when screen is turned off and then back on? 

Thank you Gabriele! 

 

 

Hi.

Yes, Thank you for the information, I'm working on this issue.

Hi, I have found something about the VideoDrawable.

I see that you have disabled the 'onLoaded' trigger on all your videos. This means that a video can start playing before it's fully loaded. This could be an explanation for the issue you are experiencing.

Please enable the trigger (only play videos after you get the "onLoaded" event), and check again.

Gabriele, thank you for your reply. I am not sure if I understood you right. Do you suggest that I should call play() inside of onLoaded()? 

The goal is to play video as soon as target image is recognized. And here is how I do it. It works on iOS by the way. 

  var my_video = new AR.VideoDrawable(?<URL TO VIDEO FILE ON REMOTE SERVER>", 0.9, {

                                            offsetX: 0,

                                            offsetY: 0,

                                            onLoaded: function videoLoaded() {

                                             },

                                            onPlaybackStarted: function videoPlaying () {

                                               my_video.enabled = true;

                                            },

                                            onFinishedPlaying: function videoFinished () {

                                            my_video.playing = false;

                                            my_video.enabled = false;

                                            },

                                            onClick: function videoClicked () {

                                            if (my_video.playing) {

                                            my_video.pause();

                                            my_video.playing = false;

                                             } else {

                                            my_video.resume();

                                            my_video.playing = true;

                                             }

                                            }

                                            });

 

 var my_video_obj = new AR.Trackable2DObject(this.tracker, ?target_image_name", {

                                          drawables: {

                                          cam:

                                          },

                                          onEnterFieldOfVision: function onEnterFieldOfViewFn () {

                                         

                                                   my_video.play(1);

                                                   my_video.playing = true;

                                             

                                          },

                                          onExitFieldOfVision: function onExitFieldOfView() {

                                         if (my_video.playing) {

                                             my_video.stop();

                                             my_video.playing = false;

                                               

                                           }

                                          }

 

                                          });

 

 

I have tried playing video only after the onLoaded is called. It did not help.Ex. 

 

var can_video_play = false;

... onLoaded: function videoLoaded() {

  can_video_play = true;                                            

}

?

 

onEnterFieldOfVision: function onEnterFieldOfViewFn () {

 if(can_video_play)

{

       my_video.play(1);

      my_video.playing = true;

}                                             

 },

 

 

 

It still looks to me that the problem is on device side :(? I am getting errors in log file that I think are the cause of why videos are not playing?. In my previous post I have attached a sample application. Do not know if you have time to run it. I wonder if it runs on your side. If does not may be you will see why? 

 

 

Why does it throw this message?: 

called unimplemented OpenGL ES API

 

 

Or this one?:

MediaPlayer? error 

 

 

 

04-08 18:02:54.086    3878-3878/com.my-company.myapplication4.app D/dalvikvm? Trying to load lib /data/data/com.my-company.myapplication4.app/libarchitect.so 0x41f95df8

04-08 18:02:54.118    3878-3878/com.my-company.myapplication4.app D/dalvikvm? Added shared lib /data/data/com.my-company.myapplication4.app/libarchitect.so 0x41f95df8

04-08 18:02:54.485    3878-3878/com.my-company.myapplication4.app W/CapsuleAPI? Method WebSettingsClassic::setMediaPlaybackRequiresUserGesture not found, return TRUE, please check the API level table.

04-08 18:02:54.485    3878-3878/com.my-company.myapplication4.app W/CapsuleAPI? could not invoke method setMediaPlaybackRequiresUserGesture of class android.webkit.WebSettingsClassic

 

 

04-08 18:02:54.633    3878-3878/com.my-company.myapplication4.app I/ArchitectWebView? ARchitect Build: b2af9d1

04-08 18:02:54.688    3878-3878/com.my-company.myapplication4.app I/Choreographer? Skipped 96 frames!  The application may be doing too much work on its main thread.

04-08 18:02:54.805    3878-3906/com.my-company.myapplication4.app E/libEGL? called unimplemented OpenGL ES API

04-08 18:02:54.805    3878-3906/com.my-company.myapplication4.app E/libEGL? called unimplemented OpenGL ES API

04-08 18:02:54.922    3878-3878/com.my-company.myapplication4.app D/dalvikvm? GC_FOR_ALLOC freed 247K, 3% free 10356K/10636K, paused 25ms, total 26ms

04-08 18:02:54.922    3878-3878/com.my-company.myapplication4.app I/dalvikvm-heap? Grow heap (frag case) to 10.577MB for 460816-byte allocation

04-08 18:02:54.938    3878-3906/com.my-company.myapplication4.app D/dalvikvm? GC_FOR_ALLOC freed <1K, 3% free 10806K/11088K, paused 15ms, total 15ms

04-08 18:02:54.961    3878-3881/com.my-company.myapplication4.app D/dalvikvm? GC_CONCURRENT freed 4K, 3% free 10841K/11088K, paused 2ms+2ms, total 21ms

04-08 18:02:54.961    3878-3878/com.my-company.myapplication4.app D/dalvikvm? WAIT_FOR_CONCURRENT_GC blocked 17ms

04-08 18:02:56.664    3878-3881/com.my-company.myapplication4.app D/dalvikvm? GC_CONCURRENT freed 133K, 3% free 11257K/11540K, paused 4ms+2ms, total 41ms

04-08 18:02:57.336    3878-3878/com.my-company.myapplication4.app D/TilesManager? Starting TG #0, 0x5d003f78

04-08 18:02:57.336    3878-3878/com.my-company.myapplication4.app D/TilesManager? new EGLContext from framework: 5d45c888

04-08 18:02:57.336    3878-3878/com.my-company.myapplication4.app D/GLWebViewState? Reinit shader

04-08 18:02:57.360    3878-3878/com.my-company.myapplication4.app D/GLWebViewState? Reinit transferQueue

04-08 18:02:58.383    3878-3940/com.my-company.myapplication4.app E/MediaPlayer? error (1, -2147483648)

04-08 18:02:58.407    3878-3878/com.my-company.myapplication4.app E/MediaPlayer? Error (1,-2147483648)

04-08 18:02:58.547    3878-3890/com.my-company.myapplication4.app E/MediaPlayer? error (1, -2147483648)

04-08 18:02:58.563    3878-3878/com.my-company.myapplication4.app E/MediaPlayer? Error (1,-2147483648)

04-08 18:02:58.907    3878-3940/com.my-company.myapplication4.app W/MediaPlayer? info/warning (3, 0)

The error you get is "E/VideoManager? Exception when playing video null"

This means that the media player cannot play the video, because there is no video. When you create a VideoDrawable, the video is not available until your application receives the "onLoaded()' event.

If you declare onLoaded as an empty function, your application doesn't know whether the video is loaded or not.

 

Gabriele, thank you for your response. 

I did try waiting until video is loaded but the issue is still there. Video does not appear and does not play... I have tried many times. It would work ones and then would never appear again... on iPhone though the video drawable appears right away and starts playing right away... As always I have tried on two different Android devices and the behaviour identical.  Here is javascript example: 

    

var is_video_loaded = false;

 

 var my_video = new AR.VideoDrawable(" URL TO mp4 file here ?, 0.9, {

                                            offsetX: 0,

                                            offsetY: 0,

                                            onLoaded: function videoLoaded() {

                                                 is_video_loaded = true;

                                            },

                                            onPlaybackStarted: function videoPlaying () {

                                               my_video.enabled = true;

                                            },

                                            onFinishedPlaying: function videoFinished () {

                                            my_video.playing = false;

                                            my_video.enabled = false;

                                            },

                                            onClick: function videoClicked () {

                                            if (my_video.playing) {

                                            my_video.pause();

                                            my_video.playing = false;

                                            

                                            } else {

                                            my_video.resume();

                                            my_video.playing = true;

                                            

                                            }

                                            }

                                            });

 

 var video_tracker = new AR.Trackable2DObject(this.tracker, ?target_image?, {

                                          drawables: {

                                          cam:

                                          },

                                          onEnterFieldOfVision: function onEnterFieldOfViewFn () {

                                           if(is_video_loaded)

                                               {

                                                   my_video.play(1);

                                                   my_video.playing = true;

                                               }

                                          },

                                          onExitFieldOfVision: function onExitFieldOfView() {

                                         if (my_video.playing) {

                                             my_video.stop();

                                             my_video.playing = false;

                                               

                                           }

                                          }

                                          });

 

 

Gabriele, is there a way for me to trigger video loading again? I am assuming that for some reason the video loading takes a very long time or for some reason it is not loaded when was first requested. Can I trigger the system to make it try to load video one more time?

 

 

 

I checked your project and done some other test.

If I start your AR world in our sample application, then both videos are showing most of the times, but I've managed to reproduce the issue (although the error message on my test device is different), and we are working on a possible solution.

We will keep you informed about the development.

Thank you very much Gabriele! Thank you for finding some time to check my sample project and the AR world. I am very happy you were able to reproduce the issue because now I know you will fix it. How long do you think we will need to wait for the fix?  Is it realistic to expect it next week?
Login or Signup to post a comment