2012-06-21 88 views
1

嘗試使用CamcorderProfile.hasProfile(xyz)時出現運行時NoSuchMethodError。 在我的應用程序的清單正確的API指定android CamcorderProfile.hasProfile NoSuchMethodError

<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中的任何錯誤書寫時/建築,甚至代碼完成工作正常。 編輯在這一點上我運行在一些設備上的代碼(銀河,令人難以置信和慾望)。

堆棧跟蹤誤差

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

任何暗示爲什麼出現這種情況?謝謝。

回答

1

我認爲布魯諾是對的,它似乎是一個API級別的問題。

0

您使用的是AVD嗎?您將媒體和相機所需的支持放在AVD中?

嘗試在真實設備中測試您的應用程序。

+0

嘿布魯諾,感謝您的回覆,並抱歉不提及它的問題。我正在幾款手機上測試它(三星Galaxy,HTC Desire和Incredible)。 – ticofab

+0

QUALITY_QVGA來自API級別15,也許這是問題:http://developer.android.com/reference/android/media/CamcorderProfile.html#QUALITY_QVGA –

相關問題