I want to use a fragment in appcelerator using hyperloop

147 Views Asked by At

I want to add a fragment using xml in titanium appcelerator but i am getting error saying .

Error: Binary XML file line #6: Binary XML file line #6: Error inflating class fragment

I have created a xml file inside platform/android/res/layout as given in hyperloop guide

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/linear">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/frame">
        <fragment
            android:id="@+id/player_fragment"
            android:name="com.aol.mobile.sdk.player.view.PlayerFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</LinearLayout>

Error

Error - [ERROR] :  TiExceptionHandler: (main) [117,396] /hyperloop/android.view.LayoutInflater.js:390
[ERROR] :  TiExceptionHandler:  var result = this.$native.callNativeFunction({
[ERROR] :  TiExceptionHandler:                            ^
[ERROR] :  TiExceptionHandler: Error: Binary XML file line #6: Binary XML file line #6: Error inflating class fragment
[ERROR] :  TiExceptionHandler:     at LayoutInflater.inflate (/hyperloop/android.view.LayoutInflater.js:390:28)
[ERROR] :  TiExceptionHandler:     at new Controller (/alloy/controllers/index.js:44:15)
[ERROR] :  TiExceptionHandler:     at Object.exports.createController (/alloy.js:339:9)
[ERROR] :  TiExceptionHandler:     at /app.js:59:7
[ERROR] :  TiExceptionHandler:     at Module._runScript (ti:/module.js:613:9)
[ERROR] :  TiExceptionHandler:     at Module.load (ti:/module.js:105:7)
[ERROR] :  TiExceptionHandler:     at Module.loadJavascriptText (ti:/module.js:457:9)
[ERROR] :  TiExceptionHandler:     at Module.loadAsFile (ti:/module.js:512:15)
[ERROR] :  TiExceptionHandler:     at Module.loadAsFileOrDirectory (ti:/module.js:429:20)
[ERROR] :  TiExceptionHandler:     at Module.require (ti:/module.js:256:17)
[ERROR] :  TiExceptionHandler:
[ERROR] :  V8Exception: Exception occurred at /hyperloop/android.view.LayoutInflater.js:390: Uncaught Error: Binary XML file line #6: Binary XML file line #6: Error inflating class fragment

JS File

const Context = require('android.content.Context');
const Inflater = require('android.view.LayoutInflater');
const Activity = require('android.app.Activity');
const activity = new Activity(Ti.Android.currentActivity);
const inflater = Inflater.cast(activity.getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE));
const resID = activity.getResources().getIdentifier('floating', 'layout', activity.getPackageName());
const view = inflater.inflate(resID, null);
$.win.add(view);
$.win.open();

0

There are 0 best solutions below