看板 AndroidDev 關於我們 聯絡資訊
※ 引述《david800427 (A_wei)》之銘言: : 請問有大大在ANDROID上實作過GOOGLE的YOUTUBE API嗎??? : 我已經可以在JAVA中裡用YOUTUBE的API上傳影片及撈出所有上傳過影片的資訊 : 但是當我要移植到ANDROID上時,卻一直沒有回應就關閉 : 問題出在這行 : : YouTubeService ytservice = new YouTubeService("AppName",Dev_Key); : LOG說 : java.lang.NoClassDefFoundError: com.google.gdata.client.youtube.YouTubeService : 該放進去的JAR檔我都有放呀!! : 不知道有沒有有經驗的大大知不知道錯誤在哪???? 借標題問一下 最近也碰到一樣的問題~"~ service = new YouTubeService("clientID","Developer Key"); try { service.setUserCredentials("gmail_address", "password"); } catch (AuthenticationException e) { e.printStackTrace(); } ---我把upload()寫在Button_Click事件裡,程式碼如下:--- VideoEntry newEntry = new VideoEntry(); YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup(); mg.setTitle(new MediaTitle()); mg.getTitle().setPlainTextContent("My Test Movie"); mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos")); mg.setKeywords(new MediaKeywords()); mg.getKeywords().addKeyword("cars"); mg.getKeywords().addKeyword("funny"); mg.setDescription(new MediaDescription()); mg.getDescription().setPlainTextContent("My description"); mg.setPrivate(false); mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag")); mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "anotherdevtag")); newEntry.setGeoCoordinates(new GeoRssWhere(37.0, -122.0)); MediaFileSource ms = new MediaFileSource(new File("video.mp4"), "video/quicktime"); newEntry.setMediaSource(ms); String uploadUrl = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"; try { VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } ------------ 專案裡丟了以下的jar檔: android-support-v4 com.google.gdata.client gdata-client-1.0 com.google.gdata gdata-media-1.0 gdata-youtube-2.0 gdata-media-1.0-sources gdata-youtube-meta-2.0 google-api-client-1.4.1-beta google-collections 但編譯後會出現錯誤 java.lang.NoClassDefFoundError: com.google.gdata.client.youtube.YouTubeService 還有 String uploadUrl = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"; 這個上傳網址是要再另外申請的嗎? 申請完再把default替換成自己的ID之類的? 我看了Interactive YouTube API Demo Beta的網頁 但還是不知該從何下手~"~ 懇請大大求解 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.11.129.171 ※ 編輯: jokie 來自: 27.105.27.110 (12/11 22:29)
ted66:java.lang.NoClassDefFoundError很像妳import的東西有問題 12/11 23:11
ted66:http://ppt.cc/Fp4M 可以考慮讓他自己下載LIB比較穩當 12/11 23:13
ted66:今天我有看到裡面有YOUTUBE的部分 12/11 23:13
jokie:謝謝你~~可是今天試過了好像沒差耶,還是會出現一樣的錯誤.. 12/13 00:50
ted66:不過你的錯誤指出的就是可能你IMPORT的東西沒有這個CLASS 12/13 09:27
ted66:我之前是有做日曆的部分,我也是跟你類似,搜尋一段時間 12/13 09:28
ted66:他說google沒有在維護了,所以就變成找不到也是正常 12/13 09:28
jokie:嗯...我去jar檔看裡面是有那個class的耶! 12/13 12:46
jokie:只是不知道為什麼抓不到 12/13 12:47
ted66:那有開放嗎? 還是他用別的接口接的 12/16 09:18
jokie:開放?我就只有把jar檔丟進去而已^^" 12/17 17:44
jokie:後來改用intent的方式就OK了~感謝~~ 12/17 17:45