尝试使用CamcorderProfile.hasProfile(xyz)时出现运行时NoSuchMethodError。
在我的应用清单中,指定了正确的API

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />


这是我想使用的块

CamcorderProfile cf = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_480P)) {
   cf = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
} else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_CIF)) {
    cf = CamcorderProfile.get(CamcorderProfile.QUALITY_CIF);
} else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_QVGA)) {
   cf = CamcorderProfile.get(CamcorderProfile.QUALITY_QVGA);
}


编写/构建时,我在Eclipse中没有任何错误,即使代码完成也可以正常工作。
现在,我在一些设备(Galaxy,Incredible和Desire)上运行代码。

stacktrace错误是

E/AndroidRuntime(12499): FATAL EXCEPTION: main
E/AndroidRuntime(12499): java.lang.NoSuchMethodError: Android.media.CamcorderProfile.hasProfile


任何提示为什么会这样吗?谢谢。

最佳答案

我认为Bruno是对的,似乎这是API级别的问题。

关于android - android CamcorderProfile.hasProfile NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11139013/

10-09 00:08