import FragmentActivity from "androidx.fragment.app.FragmentActivity"
import FragmentManager from "androidx.fragment.app.FragmentManager"
export class NativePlayer {
$element : UniNativeViewElement;
constructor(element : UniNativeViewElement) {
this.$element = element;
this.bindView();
}
frameLayout : FrameLayout | null = null;
bindView() {
this.frameLayout = new FrameLayout(this.$element.getAndroidActivity()!);
const activity = UTSAndroid.getUniActivity()!
if (activity instanceof FragmentActivity) {
const fragmentActivity = activity as FragmentActivity
const fm : FragmentManager = fragmentActivity.getSupportFragmentManager()
console.log("Got supportFragmentManager:", fm)
}
this.$element.bindAndroidView(this.frameLayout!);
}
}
使用UTSAndroid.getUniActivity()!去拿到 supportFragmentManager 是对的吗,调试报错 —>
error: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: class androidx.activity.ComponentActivity, unresolved supertypes: androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.lifecycle.HasDefaultViewModelProviderFactory, androidx.savedstate.SavedStateRegistryOwner class androidx.core.app.ComponentActivity, unresolved supertypes: androidx.lifecycle.LifecycleOwner class androidx.activity.OnBackPressedDispatcherOwner, unresolved supertypes: androidx.lifecycle.LifecycleOwner Adding -Xextended-compiler-checks argument might provide additional information.
显示没有这几个库,还是有其他方式可以将Fragment添加进去
Gongjinwei (作者)
config.json中已经加入了对应版本的依赖 打了本地基座 图片我放在下边的编辑回复了 启动还是报这个错误还是找不到
2025-08-22 11:27
DCloud_Android_THB
回复 Gongjinwei: 如果自定义基座能成功,就说明依赖都是正确的
2025-08-22 17:19