簡體   English   中英

Android上的Kaltura Java客戶端庫

[英]Kaltura Java Client Library on Android

我正在編寫一個Android API 10級應用程序,該應用程序會捕獲視頻,然后將其上傳到我們的Kaltura網站。 這應該很簡單,因為Kaltura提供了一個Java客戶端庫( 在此處 ),並且他們說在其名為“ Kaltura Android SDK參考應用程序實施指南”的文檔中使用Java客戶端庫。 這里

好吧,在編寫完一個與Java客戶端庫示例相同的Kaltura上載類之后,Kaltura在第一個鏈接上顯示了該示例,該示例包括Java客戶端庫“ libs”文件夾中包含的所有構建引用到我的項目(EXCEPT for JUnit)由於Android已經擁有自己的JUnit(包括其JUnit會導致構建失敗),因此該應用在構建新的KalturaClient對象期間會拋出java.lang.VerifyError:

W/dalvikvm(8232): VFY: array-length on non-array
W/dalvikvm(8232): VFY:  rejecting opcode 0x21 at 0x000a
W/dalvikvm(8232): VFY:  rejected Lorg/apache/log4j/config/PropertySetter;.getPropertyDescriptor (Ljava/lang/String;)Ljava/beans/PropertyDescriptor;
W/dalvikvm(8232): Verifier rejected class Lorg/apache/log4j/config/PropertySetter;
W/dalvikvm(8232): Exception Ljava/lang/VerifyError; thrown while initializing Lorg/apache/log4j/LogManager;
W/dalvikvm(8232): Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lcom/kaltura/client/KalturaClientBase;
D/AndroidRuntime(8232): Shutting down VM
W/dalvikvm(8232): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(8232): FATAL EXCEPTION: main
E/AndroidRuntime(8232): java.lang.ExceptionInInitializerError
E/AndroidRuntime(8232):     at com.mysite.myapp.kaltura.KalturaUploader.<init>(KalturaUploader.java:32)
E/AndroidRuntime(8232):     at com.mysite.myapp.storage.LoginActivity.invokeKaltura(LoginActivity.java:105)
E/AndroidRuntime(8232):     at com.mysite.myapp.storage.LoginActivity.access$2(LoginActivity.java:102)
E/AndroidRuntime(8232):     at com.mysite.myapp.storage.LoginActivity$3.onClick(LoginActivity.java:81)
E/AndroidRuntime(8232):     at android.view.View.performClick(View.java:2506)
E/AndroidRuntime(8232):     at android.view.View$PerformClick.run(View.java:9112)
E/AndroidRuntime(8232):     at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(8232):     at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(8232):     at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(8232):     at android.app.ActivityThread.main(ActivityThread.java:3835)
E/AndroidRuntime(8232):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(8232):     at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(8232):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
E/AndroidRuntime(8232):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
E/AndroidRuntime(8232):     at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(8232): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime(8232):     at org.apache.log4j.Logger.getLogger(Logger.java:118)
E/AndroidRuntime(8232):     at com.kaltura.client.KalturaClientBase.<clinit>(KalturaClientBase.java:45)
E/AndroidRuntime(8232):     ... 15 more
E/AndroidRuntime(8232): Caused by: java.lang.VerifyError: org.apache.log4j.config.PropertySetter
E/AndroidRuntime(8232):     at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:684)
E/AndroidRuntime(8232):     at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)
E/AndroidRuntime(8232):     at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544)
E/AndroidRuntime(8232):     at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440)
E/AndroidRuntime(8232):     at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476)
E/AndroidRuntime(8232):     at     org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
E/AndroidRuntime(8232):     at org.apache.log4j.LogManager.<clinit>(LogManager.java:125)
E/AndroidRuntime(8232):     ... 17 more
I/Process(8232): Sending signal. PID: 8232 SIG: 9

所以我猜想發生了上述情況,因為沒有其他包裝類(code.google.com/p/android-logging-log4j),Log4J不能在Android上完全正常工作,那么為什么不修改Kaltura以使用Android的日志記錄功能呢?

因為我已經讀過(在Kaltura的文檔中)Java客戶端不是編寫而是生成的,所以我覺得手動編輯代碼以支持android-logging-log4j會很幼稚。 此外,當我在Eclipse中打開Kaltura Java Client源代碼時,構建路徑中缺少一些類。 我注意到的第一個是sun.misc.BASE64Encoder ... Android確實有它自己的Base64Encoder,它兼容嗎?

沒有任何人有任何建議,我應該怎么辦呢? 有人得到了在Android上運行的Kaltura Java客戶端庫嗎? 第二個鏈接中描述的示例應用程序在哪里?

另外,在構建項目時,我還會在Eclipse控制台中看到許多這些消息,包括構建路徑中提供的JAR:

[2012-07-18 22:44:37 - MyApp] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

先謝謝您的幫助!


編輯:瀏覽Kaltura代碼,我發現了一些可怕的東西,這些東西一定是此生成的庫的結果...

 // =================================================================================================== // _ __ _ _ // | |/ /__ _| | |_ _ _ _ _ __ _ // | ' </ _` | | _| || | '_/ _` | // |_|\\_\\__,_|_|\\__|\\_,_|_| \\__,_| // // This file is part of the Kaltura Collaborative Media Suite which allows users // to do with audio, video, and animation what Wiki platfroms allow them to do with // text. // // Copyright (C) 2006-2011 Kaltura Inc. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // // @ignore // =================================================================================================== package com.kaltura.client.enums; /** * This class was generated using generate.php * against an XML schema provided by Kaltura. * @date Wed, 18 Jul 12 07:10:33 -0400 * * MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN. */ public enum KalturaFlavorReadyBehaviorType implements KalturaEnumAsInt { NO_IMPACT (0), REQUIRED (1), OPTIONAL (2), INHERIT_FLAVOR_PARAMS (0); public int hashCode; KalturaFlavorReadyBehaviorType(int hashCode) { this.hashCode = hashCode; } public int getHashCode() { return this.hashCode; } public static KalturaFlavorReadyBehaviorType get(int hashCode) { switch(hashCode) { case 0: return NO_IMPACT; case 1: return REQUIRED; case 2: return OPTIONAL; case 0: return INHERIT_FLAVOR_PARAMS; default: return NO_IMPACT; } } } 

他們如何編譯此代碼? 它甚至不是合法的Java。 可能有一百個類,其中大多數類的頂部都有“這是自動生成的”通知。 其他類也有類似的愚蠢問題(KalturaNullableBoolean)。

現在,我要假裝Java客戶端庫不存在。 存在一個Ruby客戶端庫,過去我在Android上使用JRuby取得了很大的成功,而且我們的應用程序僅上傳需要花費很長時間的大文件,因此開銷的增加應該不會非常明顯。作品。 多虧了附帶的JRuby JAR,我們只需要接受.APK巨大的代碼...

更不用說他們將所有內容都塞進了2個Ruby腳本中,而不是將數百個Java類塞入了所有……所有這些都更容易剔除不兼容的功能(如果有的話),至少我的Eclipse項目不會是Kaltura Java源文件的叢林不再。 :D

謝謝閱讀。

客戶端的確是自動生成的,因為Kaltura的API已更新,服務器每次更新都會生成新的客戶端,以提供客戶端中的最新功能。 您可以在此處閱讀有關Kaltura的客戶端庫生成器的更多信息: http : //knowledge.kaltura.com/adding-new-kaltura-api-client-library-generator

歡迎您認為可以改善客戶端庫的任何補丁或修改,請隨時將其附加在此處或附加到Kaltura.org上的發行線程上。

當前的Java客戶端尚不支持Android,僅適用於純Java。 目前有工作來適應和創建Android特定版本,對於任何改進的建議或補丁,我們將不勝感激。

暫無
暫無

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

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