0

尝试按照 Meshenger 方法在我的应用程序中实现 WebRTC,它在那里运行良好,但由于某种原因,我收到了膨胀错误。

我使用的版本是:'org.webrtc:google-webrtc:1.0.28513'

这是错误:

2020-04-10 04:55:19.053 13015-13015/landforms.trumpeter.premium E/AndroidRuntime: FATAL EXCEPTION: main
    Process: landforms.trumpeter.premium, PID: 13015
    java.lang.RuntimeException: Unable to start activity ComponentInfo{landforms.trumpeter.premium/landforms.trumpeter.premium.ui.activities.CallActivity}: android.view.InflateException: Binary XML file line #12 in landforms.trumpeter.premium:layout/activity_call: Binary XML file line #12 in landforms.trumpeter.premium:layout/activity_call: Error inflating class org.webrtc.SurfaceViewRenderer
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: android.view.InflateException: Binary XML file line #12 in landforms.trumpeter.premium:layout/activity_call: Binary XML file line #12 in landforms.trumpeter.premium:layout/activity_call: Error inflating class org.webrtc.SurfaceViewRenderer
     Caused by: android.view.InflateException: Binary XML file line #12 in landforms.trumpeter.premium:layout/activity_call: Error inflating class org.webrtc.SurfaceViewRenderer

这是我的activity_call.xml

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="landforms.trumpeter.premium.ui.activities.CallActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <org.webrtc.SurfaceViewRenderer
            android:id="@+id/remoteRenderer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="?attr/backgroundCardColor" />

        <org.webrtc.SurfaceViewRenderer
            android:id="@+id/localRenderer"
            android:layout_width="150dp"
            android:layout_height="200dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:visibility="gone" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="40dp"
            android:gravity="center_horizontal"
            android:orientation="vertical">

            <TextView
                android:id="@+id/callName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="CallerName"
                android:textColor="?attr/primaryTextColor"
                android:textSize="30dp" />

            <TextView
                android:id="@+id/callStatus"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/call_connecting"
                android:textColor="?attr/secondaryTextColor"
                android:textSize="20dp" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/callOptions"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:paddingBottom="30dp">

            <ImageButton
                android:id="@+id/callAccept"
                android:layout_width="@dimen/call_button_size"
                android:layout_height="@dimen/call_button_size"
                android:layout_marginRight="80dp"
                android:background="@drawable/accept_button_round"
                android:padding="@dimen/call_button_image_padding"
                android:scaleType="fitXY"
                android:src="@drawable/baseline_phone_black_48"
                android:visibility="gone"/>

            <ImageButton
                android:id="@+id/callDecline"
                android:layout_width="@dimen/call_button_size"
                android:layout_height="@dimen/call_button_size"
                android:background="@drawable/accept_button_round"
                android:padding="@dimen/call_button_image_padding"
                android:scaleType="fitXY"
                android:src="@drawable/baseline_phone_missed_black_48" />

            <RelativeLayout
                android:layout_width="@dimen/call_button_size"
                android:layout_height="@dimen/call_button_size"
                android:layout_toRightOf="@id/callDecline"
                android:layout_marginLeft="40dp"
                android:id="@+id/videoStreamSwitchLayout"
                android:visibility="gone">

                <ImageButton
                    android:id="@+id/videoStreamSwitch"
                    android:layout_width="@dimen/call_button_size"
                    android:layout_height="@dimen/call_button_size"
                    android:background="@drawable/accept_button_round"
                    android:padding="@dimen/call_button_image_padding"
                    android:scaleType="fitXY"
                    android:src="@drawable/ic_attach_camera" />

            </RelativeLayout>


            <ImageButton
                android:id="@+id/frontFacingSwitch"
                android:layout_width="@dimen/call_button_size"
                android:layout_height="@dimen/call_button_size"
                android:layout_marginLeft="40dp"
                android:layout_toRightOf="@id/videoStreamSwitch"
                android:background="@drawable/accept_button_round"
                android:padding="@dimen/call_button_image_padding"
                android:scaleType="fitXY"
                android:src="@drawable/ic_attach_camera"
                android:visibility="gone" />


        </LinearLayout>

    </RelativeLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

问题可能是什么?先感谢您。

4

1 回答 1

0

对于任何有类似问题的人。问题是我的项目中使用但不存在的属性。例如android:background="?attr/backgroundCardColor". 删除或添加它们,它应该可以工作。

于 2020-04-10T04:41:22.963 回答