當我想構建時,Eco Jitsi 插件會產生問題。它向我展示了這種型別的錯誤
///
///
Note: Recompile with -Xlint:unchecked for details.
e: /usr/local/Caskroom/flutter/3.3.4/flutter/.pub-cache/hosted/pub.dartlang.org/eko_jitsi-1.3.4/android/src/main/kotlin/com/ekodemy/eko_jitsi/EkoJitsiPluginActivity.kt: (224, 28): Type mismatch: inferred type is String? but String was expected
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':eko_jitsi:compileReleaseKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 22s
Running Gradle task 'assembleRelease'... 83.1s
Gradle task assembleRelease failed with exit code 1
ABIR BuddyBee %
這是 EkoJitsiPluginActivity.kt:
package com.ekodemy.eko_jitsi
import android.app.AlertDialog
import android.app.KeyguardManager
import android.content.*
import android.content.BroadcastReceiver
import android.content.res.Configuration
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.*
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.*
import com.ekodemy.eko_jitsi.EkoJitsiPlugin.Companion.EKO_JITSI_CLOSE
import com.ekodemy.eko_jitsi.EkoJitsiPlugin.Companion.EKO_JITSI_TAG
import com.facebook.react.ReactRootView
import com.facebook.react.views.text.ReactTextView
import com.facebook.react.views.view.ReactViewGroup
import org.jitsi.meet.sdk.*
import java.util.*
/**
* Activity extending JitsiMeetActivity in order to override the conference events
*/
class EkoJitsiPluginActivity : JitsiMeetActivity() {
companion object {
var classroomLogo: String? = null;
var whiteboardUrl: String? = null;
var classroomLogoId: Int? = null;
var context: Context? = null;
@JvmStatic
fun launchActivity(
context: Context?,
options: JitsiMeetConferenceOptions
) {
var intent = Intent(context, EkoJitsiPluginActivity::class.java).apply {
action = "org.jitsi.meet.CONFERENCE"
putExtra("JitsiMeetConferenceOptions", options)
}
context?.startActivity(intent)
this.context = context;
}
@JvmStatic
fun setData(classroomLogo: String?, whiteboardUrl: String?): Unit {
this.classroomLogo = classroomLogo;
this.whiteboardUrl = whiteboardUrl;
if (this.classroomLogo != null) {
this.classroomLogoId = this.context!!.resources.getIdentifier(
this.classroomLogo,
"drawable",
context!!.packageName
);
}
Log.i(
EKO_JITSI_TAG,
"classroomLogo [" classroomLogo "] whiteboardUrl [" whiteboardUrl "]"
);
}
}
var onStopCalled: Boolean = false;
var ekoLayout: LinearLayout? = null;
override fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean,
newConfig: Configuration?
) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
if (isInPictureInPictureMode) {
EkoJitsiEventStreamHandler.instance.onPictureInPictureWillEnter()
this.ekoLayout!!.setVisibility(LinearLayout.GONE);
} else {
EkoJitsiEventStreamHandler.instance.onPictureInPictureTerminated()
this.ekoLayout!!.setVisibility(LinearLayout.VISIBLE);
}
if (isInPictureInPictureMode == false && onStopCalled) {
// Picture-in-Picture mode has been closed, we can (should !) end the call
getJitsiView().leave()
}
}
private val myReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent?.action) {
EKO_JITSI_CLOSE -> finish()
}
}
}
override fun onStop() {
super.onStop()
onStopCalled = true;
unregisterReceiver(myReceiver)
}
override fun onResume() {
super.onResume()
onStopCalled = false
registerReceiver(myReceiver, IntentFilter(EKO_JITSI_CLOSE))
}
override fun onConferenceWillJoin(data: HashMap<String, Any>?) {
Log.d(EKO_JITSI_TAG, String.format("EkoJitsiPluginActivity.onConferenceWillJoin: %s", data))
EkoJitsiEventStreamHandler.instance.onConferenceWillJoin(data)
super.onConferenceWillJoin(data)
}
override fun onConferenceJoined(data: HashMap<String, Any>?) {
Log.d(EKO_JITSI_TAG, String.format("EkoJitsiPluginActivity.onConferenceJoined: %s", data))
EkoJitsiEventStreamHandler.instance.onConferenceJoined(data)
super.onConferenceJoined(data)
this.test();
}
override fun onConferenceTerminated(data: HashMap<String, Any>?) {
Log.d(
EKO_JITSI_TAG,
String.format("EkoJitsiPluginActivity.onConferenceTerminated: %s", data)
)
EkoJitsiEventStreamHandler.instance.onConferenceTerminated(data)
super.onConferenceTerminated(data)
}
override fun onParticipantLeft(data: HashMap<String, Any>?) {
Log.d(EKO_JITSI_TAG, String.format("EkoJitsiPluginActivity.onParticipantLeft: %s", data))
EkoJitsiEventStreamHandler.instance.onParticipantLeft(data)
super.onConferenceTerminated(data)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
turnScreenOnAndKeyguardOff();
}
override fun onPostCreate(savedInstanceState: Bundle?) {
Log.i(EKO_JITSI_TAG, "ABC Post Create");
super.onPostCreate(savedInstanceState);
// logContentView(getWindow().getDecorView(), "");
val view = window.decorView as ViewGroup;
Log.d(EKO_JITSI_TAG, "ABC " view.javaClass.canonicalName);
val layout: LinearLayout = view.getChildAt(0) as LinearLayout;
prepareWhiteboardLayout(layout);
}
fun test() {
if(true){
return;
}
try {
var jitsiView: JitsiMeetView = jitsiView;
Log.d(EKO_JITSI_TAG, "ABC " jitsiView.javaClass.canonicalName);
var ab = jitsiView.getRootReactView(jitsiView);
Log.d(EKO_JITSI_TAG, "ABC " ab.javaClass.canonicalName);
var rootReactView: ReactRootView = ab as ReactRootView;
Log.d(EKO_JITSI_TAG, "ABC " rootReactView.javaClass.canonicalName);
logContentView(rootReactView.rootViewGroup, "");
} catch (ex: Exception) {
Log.e(EKO_JITSI_TAG, "ABC Error", ex);
}
// var jitsiFragment: Fragment? = getSupportFragmentManager().findFragmentById(R.id.jitsiFragment);
}
fun prepareWhiteboardLayout(layout: LinearLayout) {
this.ekoLayout = LinearLayout(this);
this.ekoLayout!!.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
this.ekoLayout!!.setPadding(25, 25, 25, 25)
this.ekoLayout!!.gravity = Gravity.LEFT;
var logoParentlayout: LinearLayout = LinearLayout(this);
logoParentlayout.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
logoParentlayout.gravity = Gravity.LEFT;
val logoImage = ImageView(this);
//logoImage.setImageURI(Uri.parse("https://www.ekodemy.in/wp-content/uploads/2021/02/vidyartham@2x_1.png"));
if (EkoJitsiPluginActivity.classroomLogoId != null) {
logoImage.setImageResource(EkoJitsiPluginActivity.classroomLogoId!!);
}
logoImage.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
100
);
logoImage.id = View.generateViewId();
logoImage.scaleType = ImageView.ScaleType.FIT_START;
logoImage.adjustViewBounds = true;
var btnParentlayout: LinearLayout = LinearLayout(this);
btnParentlayout.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
btnParentlayout.gravity = Gravity.RIGHT;
val btnTag = Button(this)
btnTag.layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
100
);
btnTag.text = "Whiteboard";
btnTag.id = View.generateViewId();
btnTag.setBackgroundColor(Color.BLACK);
if (EkoJitsiPluginActivity.whiteboardUrl != null) {
btnTag.setTextColor(Color.WHITE);
btnTag.setOnClickListener {
EkoJitsiEventStreamHandler.instance.onWhiteboardClicked();
// Toast.makeText(this, "Whiteboard", Toast.LENGTH_SHORT).show()
val alert: AlertDialog.Builder = AlertDialog.Builder(this)
alert.setTitle("Whiteboard")
val wv = WebView(this)
wv.loadUrl(whiteboardUrl)
wv.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
view.loadUrl(url)
return true
}
}
wv.settings.javaScriptEnabled = true;
wv.settings.javaScriptCanOpenWindowsAutomatically = true;
wv.settings.domStorageEnabled = true;
alert.setView(wv)
alert.setNegativeButton("Close",
DialogInterface.OnClickListener { dialog, id -> dialog.dismiss() });
alert.show()
}
} else {
btnTag.setTextColor(Color.BLACK);
}
layout.setBackgroundColor(Color.BLACK);
logoParentlayout.addView(logoImage);
btnParentlayout.addView(btnTag);
this.ekoLayout!!.addView(logoParentlayout);
this.ekoLayout!!.addView(btnParentlayout);
layout.addView(ekoLayout, 0);
}
fun logContentView(parent: View, indent: String) {
if (parent is ReactViewGroup) {
var abc = parent as ReactViewGroup;
Log.i("ABC test", indent parent.javaClass.name " - Tag " abc.tag)
} else if (parent is ReactTextView) {
var abc = parent as ReactTextView;
Log.i("ABC test", indent parent.javaClass.name " - Text " abc.text)
} else {
Log.i("ABC test", indent parent.javaClass.name)
}
if (parent is ViewGroup) {
val group = parent
for (i in 0 until group.childCount) logContentView(group.getChildAt(i), "$indent ")
}
}
override fun onDestroy() {
super.onDestroy()
turnScreenOffAndKeyguardOn();
}
private fun turnScreenOnAndKeyguardOff() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
// For newer than Android Oreo: call setShowWhenLocked, setTurnScreenOn
setShowWhenLocked(true)
setTurnScreenOn(true)
// If you want to display the keyguard to prompt the user to unlock the phone:
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
keyguardManager?.requestDismissKeyguard(this, null)
} else {
// For older versions, do it as you did before.
window.addFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
or WindowManager.LayoutParams.FLAG_FULLSCREEN
or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
)
}
}
private fun turnScreenOffAndKeyguardOn() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(false)
setTurnScreenOn(false)
} else {
window.clearFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
or WindowManager.LayoutParams.FLAG_FULLSCREEN
or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
)
}
}
}
fun BaseReactView<JitsiMeetViewListener>.getRootReactView(view: JitsiMeetView): Any {
return BaseReactView::class.java.getDeclaredField("reactRootView").let {
it.isAccessible = true;
val value = it.get(view);
//todo
return@let value;
}
// return this.reactRootView;
}
想要構建時會產生問題,但是當使用顫振運行時就可以了。我怎么解決這個問題 ?
uj5u.com熱心網友回復:
在您的錯誤訊息EkoJitsiPluginActivity.kt (224, 28)中, 224 是指行號。這樣你就可以找出錯誤在哪里。如果我沒記錯的話,那應該在上面寫著
wv.loadUrl(whiteboardUrl)
loadUrl需要一個String但是whiteboardUrl是一個String?。要將其推廣為String您可以撰寫的
wv.loadUrl(whiteboardUrl!!)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/520246.html
標籤:细绳扑科特林无效的吉齐
