简体   繁体   English

无法在Android项目构建路径中包含jndi.jar文件

[英]Not able to include jndi.jar file in android project build path

I need to do LDAP authentication of my users in Android application , for the same I am using JNDI lookup method and need to include JNDI.jar in my build path , but android is not letting me do so and throwing the following error 我需要在Android应用程序中对用户进行LDAP身份验证,同样,我正在使用JNDI查找方法,并且需要在构建路径中包含JNDI.jar,但是android不允许我这样做并抛出以下错误

[2011-02-17 15:08:33 - DHCAndroid]: Dx trouble processing "javax/naming/AuthenticationException.class": [2011-02-17 15:08:33-DHCAndroid]:Dx处理“ javax / naming / AuthenticationException.class”时遇到麻烦:

Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. 不构建核心库时对核心类(java。*或javax。*)的不良使用或错误使用。

This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). 这通常是由于在使用IDE(例如Eclipse)时在应用程序项目中无意中包含了一个核心库文件。 If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on. 如果您确定没有刻意定义核心类,那么这是最可能的解释。

However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example, from a non-Android virtual machine project. 但是,您实际上可能正在尝试在核心名称空间中定义一个类,例如,您可能从非Android虚拟机项目中获取了该类的源。 This will most assuredly not work. 这肯定是行不通的。 At a minimum, it jeopardizes the compatibility of your app with future versions of the platform. 至少,这会损害您的应用程序与平台未来版本的兼容性。 It is also often of questionable legality. 它的合法性也常常令人怀疑。

If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the "--core-library" option to suppress this error message. 如果您确实打算构建一个核心库(仅适合于创建完整的虚拟机发行版而不是编译应用程序),请使用“ --core-library”选项来禁止显示此错误消息。

If you go ahead and use "--core-library" but are in fact building an application, then be forewarned that your application will still fail to build or run, at some point. 如果您继续使用“ --core-library”,但实际上是在构建应用程序,那么请注意,在某些时候您的应用程序仍将无法构建或运行。 Please be prepared for angry customers who find, for example, that your application ceases to function once they upgrade their operating system. 请为生气的客户做好准备,这些客户发现例如,他们的操作系统升级后,您的应用程序将停止运行。 You will be to blame for this problem. 您将为此问题负责。

If you are legitimately using some code that happens to be in a core package, then the easiest safe alternative you have is to repackage that code. 如果您合法使用的代码恰好位于核心程序包中,那么最简单的安全选择就是重新打包该代码。 That is, move the classes in question into your own package namespace. 也就是说,将相关的类移到您自己的包名称空间中。 This means that they will never be in conflict with core system classes. 这意味着它们永远不会与核心系统类冲突。 JarJar is a tool that may help you in this endeavor. JarJar是一种可以帮助您实现这一目标的工具。 If you find that you cannot do this, then that is an indication that the path you are on will ultimately lead to pain, suffering, grief, and lamentation. 如果您发现自己无法做到这一点,则表明您所走的道路最终将导致痛苦,痛苦,悲伤和悲哀。

[2011-02-17 15:08:33 - DHCAndroid]: Dx1 error; [2011-02-17 15:08:33-DHCAndroid]:Dx1错误; aborting [2011-02-17 15:08:33 - DHCAndroid] Conversion to Dalvik format failed with error 1 正在中止[2011-02-17 15:08:33-DHCAndroid]转换为Dalvik格式失败,错误1

As soon as i remove the jar the error disappears, removing the jar is not an option , please help with the way to do it 一旦我取出罐子,错误就会消失,取出罐子不是一种选择,请提供帮助的方式

Regards, Smriti Garg 问候,Smriti Garg

Like the error message says: 像错误消息说:

move the classes in question into your own package namespace. 将相关的类移到您自己的包名称空间中。 [...] JarJar is a tool that may help you in this endeavor. [...] JarJar是一种可以帮助您实现这一目标的工具。

Repackage the JNDI code into your own namespace, by using JarJar. 使用JarJar将JNDI代码重新打包到您自己的名称空间中。 Then rely on your new jar instead. 然后依靠您的新罐子。

Find another LDAP library, then, one that is not in the javax namespace. 然后,找到另一个LDAP库,该库不在javax名称空间中。 What you want to do with this JAR is not possible. 您无法与此JAR一起做什么。

Add the dex parameter --core-library to the [ANDROID_SDK]\\platform-tools\\dx.bat. 将dex参数--core-library添加到[ANDROID_SDK] \\ platform-tools \\ dx.bat。

Change line ~59 of dx.bat: 'set params=' to 'set params=--core-library' 将dx.bat的〜59行更改为:'set params ='到'set params=--core-library' -core 'set params=--core-library'

This enables the Android build process to allow including javax pacakges. 这使Android构建过程可以包含javax pacakges。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在适用于Android项目的Ant build.xml中包含.jar文件 - how to include a .jar file with Ant build.xml for Android project Android:将项目添加为库,在构建路径>库>库项目中获取(丢失).jar文件 - Android: Added project as library, getting (missing) .jar file in Build Path>Libraries>Library Projects Android,如何在不是JAR文件的项目中包含特定库? - Android, How to include specific library in project that is not a JAR file? 将android库项目转换为带有资源的jar文件(libs和build文件夹) - Convert android library project to jar file with resources (libs and build folder) 如何为Android项目构建JAR - How to build a JAR for an android project 将Java项目包含到android build中 - Include java project into android build 如何在android库项目中包含jar文件 - How to include jar files in android library project Gradle:如何在Android版本中包含来自依赖java项目的本地jar? - Gradle: how do I include a local jar from a dependent java project in an Android build? 在android项目中编辑build.xml以包含facebook sdk.jar - Edit build.xml in android project to include facebook sdk.jar Android:在Build中包含外部Jar(没有Eclipse) - Android: Include External Jar in Build (Without Eclipse)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM