我正在编写一个Android API 10级应用程序,用于捕获视频,然后将其上传到我们的Kaltura网站。它应该是直截了当的,因为Kaltura提供了一个Java客户端库(here),并且他们说在他们的文档中使用Java客户端库,标题为“Kaltura Android SDK参考应用程序实现指南”。 (here)
好吧,在编写了与Java客户端库示例相同的初步Kaltura上传类之后,Kaltura显示(在第一个链接上),包括Java客户端库“libs”文件夹中包含的所有构建引用到我的项目,除了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客户端源时,我的构建路径中缺少一些类。我注意到的第一个是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
感谢阅读。
答案 0 :(得分:0)
客户端确实是自动生成的,因为Kaltura的API得到更新,服务器会在每次更新时生成新客户端,以提供客户端中的最新功能。 您可以在此处阅读有关Kaltura的Client Libs生成器的更多信息: http://knowledge.kaltura.com/adding-new-kaltura-api-client-library-generator
欢迎您认为可以改进客户端库的任何补丁或修改,可以随时将其附加到Kaltura.org上的问题主题中。
当前的Java客户端还不具备Android友好性,它适合纯Java使用。 有适应和创建Android特定版本的工作,非常感谢任何改进的建议或补丁。