android 应用程序在jitsi meet sdk启动时崩溃,无法检测到问题

hwamh0ep  于 2023-04-18  发布在  Android
关注(0)|答案(1)|浏览(282)

当jitsi meet sdk启动时,应用程序崩溃。我正在使用jitsi sdk准备会议应用程序。每当我点击开始meetign按钮时,应用程序崩溃。我在下面附上视频和代码。video here

package com.appsbypss.psmeet2023;

import static android.content.ContentValues.TAG;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.widget.Toast;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.LoadAdError;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;

import org.jitsi.meet.sdk.BroadcastEvent;
import org.jitsi.meet.sdk.BroadcastIntentHelper;
import android.content.BroadcastReceiver;
import org.jitsi.meet.sdk.JitsiMeet;
import org.jitsi.meet.sdk.JitsiMeetActivity;
import org.jitsi.meet.sdk.JitsiMeetActivityDelegate;
import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
import org.jitsi.meet.sdk.JitsiMeetView;

import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import java.net.MalformedURLException;
import java.net.URL;

import timber.log.Timber;

public class MeetingRooms extends AppCompatActivity {

    private InterstitialAd mInterstitialAd;

    public final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            onBroadcastReceived(intent);
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_meeting_rooms);
//        broadcastReceiver = new BroadcastReceiver() {
//            @Override
//            public void onReceive(Context context, Intent intent) {
//                // As new restrictions including server URL are received,
//                // conference should be restarted with new configuration.
//            onBroadcastReceived(intent);
//            }
//        };



        Intent intent = getIntent();
        String meeting_id = intent.getStringExtra("meeting_id");

        Toast.makeText(this, meeting_id, Toast.LENGTH_SHORT).show();

        URL serverURL;
        try {
            // When using JaaS, replace "https://meet.jit.si" with the proper serverURL
            serverURL = new URL("https://meet.jit.si");
        } catch (MalformedURLException e) {
            e.printStackTrace();
            throw new RuntimeException("Invalid server URL!");
        }
        JitsiMeetConferenceOptions defaultOptions
                = new JitsiMeetConferenceOptions.Builder()
                .setServerURL(serverURL)
                // When using JaaS, set the obtained JWT here
                //.setToken("MyJWT")
                // Different features flags can be set
                // .setFeatureFlag("toolbox.enabled", false)
                // .setFeatureFlag("filmstrip.enabled", false)
                .setFeatureFlag("welcomepage.enabled", false)
                .build();
        JitsiMeet.setDefaultConferenceOptions(defaultOptions);

        registerForBroadcastMessages();

        if (meeting_id != null || meeting_id != "") {
            // Build options object for joining the conference. The SDK will merge the default
            // one we set earlier and this one when joining.
            JitsiMeetConferenceOptions options
                    = new JitsiMeetConferenceOptions.Builder()
                    .setRoom(meeting_id)
                    .setFeatureFlag("welcomepage.enabled", false)

//                 Settings for audio and video
                    .setAudioMuted(true)
                    .setVideoMuted(true)
                    .build();
            // Launch the new activity with the given options. The launch() method takes care
            // of creating the required Intent and passing the options.
            JitsiMeetActivity.launch(this, options);

        }

        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {}
        });
        AdRequest adRequest = new AdRequest.Builder().build();

        InterstitialAd.load(this,"ca-app-pub-1433551814483417/5546969054", adRequest,
                new InterstitialAdLoadCallback() {
                    @Override
                    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
                        // The mInterstitialAd reference will be null until
                        // an ad is loaded.
                        mInterstitialAd = interstitialAd;
                        Log.i(TAG, "onAdLoaded");
                    }
                    @Override
                    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                        // Handle the error
                        Log.i(TAG, loadAdError.getMessage());
                        mInterstitialAd = null;
                    }

                });

    }

    private void registerForBroadcastMessages() {
        IntentFilter intentFilter = new IntentFilter();

        /* This registers for every possible event sent from JitsiMeetSDK
           If only some of the events are needed, the for loop can be replaced
           with individual statements:
           ex:  intentFilter.addAction(BroadcastEvent.Type.AUDIO_MUTED_CHANGED.getAction());
                intentFilter.addAction(BroadcastEvent.Type.CONFERENCE_TERMINATED.getAction());
                ... other events
         */
        for (BroadcastEvent.Type type : BroadcastEvent.Type.values()) {
            intentFilter.addAction(type.getAction());
        }

        LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter);
    }
    private void gotoHome() {
        startActivity(new Intent(this, Home.class));
        finish();
        if (mInterstitialAd != null) {
            mInterstitialAd.show(this);

        } else {
            Log.d("TAG", "The interstitial ad wasn't ready yet.");
        }

    }

    @Override
    protected void onDestroy() {
        LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver);

        super.onDestroy();
        hangUp();
    }





    // Example for handling different JitsiMeetSDK events
    private void onBroadcastReceived(Intent intent) {
        if (intent != null) {
            BroadcastEvent event = new BroadcastEvent(intent);

            switch (event.getType()) {
                case CONFERENCE_TERMINATED:

                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            gotoHome();
                        }
                    }, 3000);

                    break;
                case CONFERENCE_JOINED:
                    Timber.i("Conference Joined with url%s", event.getData().get("url"));
                    break;
                case PARTICIPANT_JOINED:
                    Timber.i("Participant joined%s", event.getData().get("name"));
                    break;
            }
        }
    }

    // Example for sending actions to JitsiMeetSDK
    private void hangUp() {
        Intent hangupBroadcastIntent = BroadcastIntentHelper.buildHangUpIntent();
        LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(hangupBroadcastIntent);
    }
}

下面是我的logcat

Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
E/gralloc4: Empty SMPTE 2094-40 data
D/InsetsController: show(ime(), fromIme=true)
D/DecorView[]: onWindowFocusChanged hasWindowFocus false
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
    java.lang.RuntimeException: Unable to start service org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService@cbde6f8 with Intent { cmp=com.appsbypss.psmeet2023/org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService (has extras) }: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=JitsiOngoingConferenceChannel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0xa color=0x00000000 category=call actions=2 vis=PUBLIC)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4844)
        at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2275)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:210)
        at android.os.Looper.loop(Looper.java:299)
        at android.app.ActivityThread.main(ActivityThread.java:8136)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028)
     Caused by: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=JitsiOngoingConferenceChannel shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0xa color=0x00000000 category=call actions=2 vis=PUBLIC)
        at android.app.NotificationManager.fixNotification(NotificationManager.java:700)
        at android.app.NotificationManager.notifyAsUser(NotificationManager.java:679)
        at android.app.NotificationManager.notify(NotificationManager.java:628)
        at android.app.NotificationManager.notify(NotificationManager.java:604)
        at org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService.onStartCommand(JitsiMeetOngoingConferenceService.java:135)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4826)
        at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2275) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loopOnce(Looper.java:210) 
        at android.os.Looper.loop(Looper.java:299) 
        at android.app.ActivityThread.main(ActivityThread.java:8136) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028) 
I/JitsiMeetSDK: JitsiConnectionService onAbort F44D7602-71D0-4B03-9503-CC4CA9682113
D/JitsiMeetSDK: JitsiConnectionService onStateChanged: DISCONNECTED F44D7602-71D0-4B03-9503-CC4CA9682113
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
E/gralloc4: Empty SMPTE 2094-40 data
I/Process: Process is going to kill itself!
    java.lang.Exception
        at android.os.Process.killProcess(Process.java:1330)
        at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:202)
        at org.jitsi.meet.sdk.JitsiMeetUncaughtExceptionHandler.uncaughtException(JitsiMeetUncaughtExceptionHandler.java:48)
        at org.chromium.base.JavaExceptionReporter.uncaughtException(chromium-TrichromeWebViewGoogle6432.aab-stable-556311634:17)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
        at java.lang.Thread.dispatchUncaughtException(Thread.java:2306)
I/Process: Sending signal. PID: 957 SIG: 9

我知道这是由于无效的通知图像,所以我试图使其有效.我干净的项目建成.但没有改变.所以请尽快给予我解决这个问题.谢谢.

blmhpbnm

blmhpbnm1#

jitis-meet-sdk的最新版本需要通知图标,因为sdk使用通知。
因此,只需将其添加到res/drawable目录(名称:ic_notification):

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="26.086956"
    android:viewportHeight="26.086956"
    android:tint="#FFFFFF">
    <group android:translateX="1.0434783"
        android:translateY="1.0434783">
        <path
            android:fillColor="#FF000000"
            android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83
            0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83
            0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45
            1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83
            0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8
            3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5
            1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,
            1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71
            -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1
            12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2
            -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51
            0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75
            -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
    </group>
</vector>

这应该能解决你的问题。
编辑:我忘了,有一个更快的方法为图标:
1.右键点击res文件夹,在android项目中选择image asset from new section。
1.使用以下配置名称创建图标:ic_notification图标类型:通知图标
来源:https://github.com/jitsi/jitsi-meet/issues/11847
Jitsi Android SDK crashes (version 6.1.0) after joining call

相关问题