1.每当我在我的应用中刷下一张图片时,应用崩溃了,我不知道出了什么问题
noSuchMethodError:类landroid/util/sparsearray中没有包含(I)Z的虚拟方法;或其超类(“android.util.sparsearray”的声明出现在/system/framework/framework.jar!classes2.dex中)
class PostViewFragment : DialogFragment() {
private var player: SimpleExoPlayer? = null
private lateinit var mediaDataSourceFactory: DataSource.Factory
//var post: FeedNodeModel? = null
private val STORAGE_PERMISSION_CODE = 100
private var post: FeedNodeModel? = null
var currentPos = 0
var registeredFragments = SparseArray<SidecarPagerFragment>()
var isFirstLoad = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.FullScreenDialogStyle)
isCancelable = true
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
/*if (createdView != null) {
return createdView
}*/
val view = inflater.inflate(R.layout.fragment_post_view, container, false)
//post = arguments?.getSerializable("post") as FeedNodeModel?
when (post?.__typename) {
"GraphImage",
"GraphStoryImage" -> {
Picasso.get()
.load(post?.sourceUrl)
.into(view.img_post)
view.img_post.visibility = View.VISIBLE
view.playerView.visibility = View.GONE
view.viewpager.visibility = View.GONE
}
"GraphVideo",
"GraphStoryVideo" -> {
Glide.with(requireContext())
.load(post?.thumbnailUrl)
.into(object : CustomTarget<Drawable>() {
override fun onLoadCleared(p0: Drawable?) {
}
override fun onResourceReady(p0: Drawable, p1: Transition<in Drawable>?) {
initializePlayer(view.playerView,
post?.sourceUrl)
}
})
view.img_post.visibility = View.GONE
view.playerView.visibility = View.VISIBLE
view.viewpager.visibility = View.GONE
}
"GraphSidecar" -> {
val calHeight =
(resources.displayMetrics.widthPixels *
(post?.feedNodeModel?.get(0)?.dimenHeight!!)) /
post?.feedNodeModel?.get(0)?.dimenWidth!!
view.txt_pager_count.text = "1/${post?.feedNodeModel?.size}"
view.viewpager.layoutParams.height = calHeight
view.viewpager.adapter = object : FragmentPagerAdapter(childFragmentManager,
FragmentStatePagerAdapter.POSITION_NONE) {
override fun getItem(p0: Int): Fragment {
val fragment = SidecarPagerFragment.create(post?.feedNodeModel?.get(p0))
registeredFragments.put(p0, fragment)
if (isFirstLoad) {
fragment.isFirstLoad = true
isFirstLoad = false
}
return fragment
}
override fun getCount(): Int = post?.feedNodeModel?.size!!
}
view.viewpager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
@RequiresApi(Build.VERSION_CODES.R)
override fun onPageSelected(position: Int) {
if (post?.feedNodeModel?.get(currentPos)?.__typename == "GraphVideo") {
registeredFragments[currentPos]?.onPause()
}
currentPos = position
view.txt_pager_count.text = "${currentPos+1}/${post?.feedNodeModel?.size}"
if (registeredFragments.contains(position)) {
registeredFragments[position]?.loadVideo()
}
}
})
view.viewpager.visibility = View.VISIBLE
view.img_post.visibility = View.GONE
view.playerView.visibility = View.GONE
}
}
此行应用程序崩溃
if (registeredFragments.contains(position)) {
registeredFragments[position]?.loadVideo()
}
使用containskey
/** Returns true if the collection contains [key]. */
inline fun <T> SparseArray<T>.containsKey(key: Int) = indexOfKey(key) >= 0
我的领队迈克的见解
我在一个Android项目中使用了reverfit(2.7.2)和OkHttp版本(4.4.0),但我遇到了一个请求崩溃。 依赖项: 崩溃: noSuchMethodError:没有虚拟方法toString(Z)lJava/lang/String;在类LOKHTTP3/Cookie中;或其超级类(“OKHTTP3.cookie”的声明出现在/data/app/com.package-1/base.
在google play上出现此错误 defaultConfig{
我正在从检索小区信息数据() 对于每个小区信息对象,我通过以下途径查询mcc(移动国家代码)和mnc(移动网络代码) 其中eachCellInfo是CellInfo的对象 根据文档,不推荐使用该函数: 但是,当我使用建议的方法通过 方法说明: 其他信息:
JAVAlang.NoSuchMethodError:Lcom/google/firebase/FirebaseApp类中没有虚拟方法zzbqo()Z;或者它的超类(声明'com.google.firebase.FirebaseApp'出现在/data/app/woolamania.in.woolamania-2/base.apk)在com上。谷歌。火基。数据库FirebaseDatabase。c
我更新了Android Studio到2.2和我的项目将不再构建。我的活动super.on创建(SavedInstanceState)给我一个错误: 我做了一个全新的活动,看看是不是我的代码导致了这个问题,但没有帮助。活动内容如下: 这是我的身材。格雷德尔(应用程序) 在此错误之前,我得到了这个:java.lang.NoSuchMultiodError:没有静态方法setOnApplyWindow