Re: [問題] 如和利用GOOGLE的YOUTUBE API上傳影片

看板AndroidDev作者 (啾~)時間12年前 (2013/12/11 19:58), 編輯推噓0(0012)
留言12則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《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)

12/11 23:11, , 1F
java.lang.NoClassDefFoundError很像妳import的東西有問題
12/11 23:11, 1F

12/11 23:13, , 2F
http://ppt.cc/Fp4M 可以考慮讓他自己下載LIB比較穩當
12/11 23:13, 2F

12/11 23:13, , 3F
今天我有看到裡面有YOUTUBE的部分
12/11 23:13, 3F

12/13 00:50, , 4F
謝謝你~~可是今天試過了好像沒差耶,還是會出現一樣的錯誤..
12/13 00:50, 4F

12/13 09:27, , 5F
不過你的錯誤指出的就是可能你IMPORT的東西沒有這個CLASS
12/13 09:27, 5F

12/13 09:28, , 6F
我之前是有做日曆的部分,我也是跟你類似,搜尋一段時間
12/13 09:28, 6F

12/13 09:28, , 7F
他說google沒有在維護了,所以就變成找不到也是正常
12/13 09:28, 7F

12/13 12:46, , 8F
嗯...我去jar檔看裡面是有那個class的耶!
12/13 12:46, 8F

12/13 12:47, , 9F
只是不知道為什麼抓不到
12/13 12:47, 9F

12/16 09:18, , 10F
那有開放嗎? 還是他用別的接口接的
12/16 09:18, 10F

12/17 17:44, , 11F
開放?我就只有把jar檔丟進去而已^^"
12/17 17:44, 11F

12/17 17:45, , 12F
後來改用intent的方式就OK了~感謝~~
12/17 17:45, 12F
文章代碼(AID): #1Ig5DYrD (AndroidDev)
文章代碼(AID): #1Ig5DYrD (AndroidDev)