簡體   English   中英

Android ClassCastException:

[英]Android ClassCastException:

我正在嘗試將Google Sample App集成到我自己的App中。 示例應用程序說明了Camera2 API的用法。 示例應用程序可以編譯並正常運行。

如前所述,我想在我的App中使用CameraActivity.javaCamera2BasicFragment.javaAutoFitTextureView.java 但是,當我運行我的應用程序時,出現此錯誤:

java.lang.ClassCastException:android.view.TextureView無法轉換為openbook.pub.sypa.view.AutoFitTextureView

此行引發異常(在Camera2BasicFragment.onViewCreated ):

mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture);

AutoFitTextureView在示例應用程序中保持不變,並從TextureView擴展:

public class AutoFitTextureView extends android.view.TextureView {

我什至build.gradle文件從示例應用程序復制到我自己的應用程序中,以確保它依賴於相同的庫。 我還清理了項目。

為什么會出現此錯誤? 為什么在Google的示例應用程序中可以正常使用?

為什么會出現此錯誤?

據推測, TextureViewview的布局具有TextureView ,而不是AutoFitTextureView

為什么在Google的示例應用程序中可以正常使用?

因為Google的示例應用程序的布局具有AutoFitTextureView

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM