热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何使用AndroidStudio从Maven获取旧库-HowtogetanolderlibraryfromMavenusingAndroidStudio

IneedtohaveanolderMavenlibraryofeclipselinkusingAndroidStudio1.2.我需要使用AndroidStudio1

I need to have an older Maven library of eclipselink using Android Studio 1.2.

我需要使用Android Studio 1.2拥有一个旧版的eclipselink Maven库。

When I use the Library Dependency to search for eclipselink, I get the following results:

当我使用Library Dependency搜索eclipselink时,我得到以下结果:

enter image description here

However, this library was compiled using Java 8, so it is not suitable for me.

但是,这个库是使用Java 8编译的,所以它不适合我。

This is my gradle.build file:

这是我的gradle.build文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 10
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'org.odata4j:odata4j-dist:0.7.0'
    provided 'org.eclipse.persistence:eclipselink:2.6.0'
    compile 'com.android.support:appcompat-v7:22.1.1'
}

If I change the org.eclipse.persistence:eclipselink:2.6.0 to org.eclipse.persistence:eclipselink:2.1.2, I get this error:

如果我将org.eclipse.persistence:eclipselink:2.6.0更改为org.eclipse.persistence:eclipselink:2.1.2,我收到此错误:

Failed to resolve: org.eclipse.persistence:eclipselink:2.1.2

无法解决:org.eclipse.persistence:eclipselink:2.1.2

How could I use an older version of this library?

我怎么能使用这个库的旧版本?

UPDATE:

I've tried to use v2.4.2 but it couldn't compile, so I downloaded a 2.1.2 jar and added as a file dependency. Now it can't find it, and searches in the SDK library. This Maven/Gradle thing is very, very far from NuGet...

我试过使用v2.4.2但它无法编译,所以我下载了一个2.1.2 jar并添加为文件依赖项。现在它找不到它,并在SDK库中搜索。这个Maven / Gradle的东西离NuGet非常非常远......

This is the gradle file:

这是gradle文件:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/eclipselink-2.1.2.jar')
    compile 'org.odata4j:odata4j-dist:0.7.0'
    compile 'com.android.support:appcompat-v7:22.1.1'

}

And the message:

并且消息:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find org.eclipse.persistence:eclipselink:2.1.2.
     Searched in the following locations:
         https://jcenter.bintray.com/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.pom
         https://jcenter.bintray.com/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.jar
         file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/android/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.pom
         file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/android/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.jar
         file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/google/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.pom
         file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/google/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.jar
     Required by:
         MyApp:app:unspecified > org.odata4j:odata4j-dist:0.7.0 > org.odata4j:odata4j-core:0.7.0

It just simply ignores the gradle file.

它只是忽略了gradle文件。

UPDATE #2:

I copied the jar to the SDK library. When I build now, I get this error:

我将jar复制到SDK库。当我现在构建时,我收到此错误:

:app:preDexDebug
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.joda.time.DateTimeZone$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.
trouble processing "javax/xml/stream/EventFilter.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
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. 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.
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. 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. 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.
1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED

What should I do?

我该怎么办?

3 个解决方案

#1


Search dependencies on bintray, e.g. this is what I get when searching for 'eclipselink'. Indeed, there's no 2.1.2 version, so you'll have to pick one from the list.

在bintray上搜索依赖关系,例如这是我在搜索'eclipselink'时得到的。实际上,没有2.1.2版本,所以你必须从列表中选择一个。

#2


The earliest version of org.eclipse.persistence:eclipselink is 2.4.2 http://mvnrepository.com/artifact/org.eclipse.persistence/eclipselink

最早版本的org.eclipse.persistence:eclipselink是2.4.2 http://mvnrepository.com/artifact/org.eclipse.persistence/eclipselink

Or you could try to download an older .jar manually somehow

或者您可以尝试以某种方式手动下载较旧的.jar

#3


Unfortunately the solution is not to use Gradle in the project and use the old fashioned (and working) way: add the jars manually. This is the reliable way.

不幸的是,解决方案不是在项目中使用Gradle并使用旧式(和工作)方式:手动添加jar。这是可靠的方式。


推荐阅读
  • 获取年月日,之前的日期不能选择日历cCalendar.getInstance();获取系统的工具类【可以获取时间】DatePickerDialogdate ... [详细]
  • 本文介绍如何使用Java实现AC自动机(Aho-Corasick算法),以实现高效的多模式字符串匹配。文章涵盖了Trie树和KMP算法的基础知识,并提供了一个详细的代码示例,包括构建Trie树、设置失败指针以及执行搜索的过程。 ... [详细]
  • mybatis相关面试题 ... [详细]
  • 本文详细探讨了在Python开发中遇到的ImportError: 无法找到名为Crypto.Cipher的模块的问题,并提供了多种解决方案,包括环境配置、库安装和代码调整等方法。 ... [详细]
  • 本文旨在探讨Linux系统中两种重要的进程间通信(IPC)机制——System V和POSIX的标准及其特性,为开发者提供深入的理解。 ... [详细]
  • Android 5 及以上版本中使用存储访问框架(SAF)实现 SD 卡写入权限的方法
    本文探讨了在 Android 5 及更高版本中通过存储访问框架(Storage Access Framework, SAF)实现对 SD 卡文件的写入与重命名操作。文章分析了 SAF 的工作原理,并提供了一个示例应用的代码实现,展示了如何正确获取并使用用户授予的写入权限。 ... [详细]
  • 本文探讨了在 JavaFX 应用程序中使用 TableView 组件时遇到的滚动条问题,特别是当表格数据变化时,水平滚动条无法自动复位至初始位置的情况。 ... [详细]
  • 深入解析 Android 中的 ActivityGroup 实现
    本文详细探讨了如何在 Android 应用中使用 ActivityGroup 来实现类似微博客户端主界面的效果,并分析了 TabActivity 的局限性,推荐使用更为灵活的 ActivityGroup 方案。 ... [详细]
  • 本文探讨了在JavaScript中如何有效地从服务器控件DropDownList中获取绑定的ID值,而非仅仅是显示的文本值。这对于需要根据用户选择动态处理数据的应用场景非常有用。 ... [详细]
  • Docker环境下Redis的安装与配置
    本文详细介绍了如何在Docker环境中安装和配置Redis,包括镜像下载、容器启动、连接测试以及持久化设置等步骤。同时,还提供了使用Redis可视化管理工具的方法,帮助用户更好地管理和监控Redis实例。 ... [详细]
  • 初学者必备:iBATIS入门指南与常见问题解决
    本文旨在为iBATIS初学者提供一份详细的入门指南,并针对官方文档中示例不足的问题提出解决方案。适合零基础学习者。 ... [详细]
  • HTML5 拖拽功能实现
    本文通过一个简单的示例,展示了如何利用 HTML5 的拖放 API 实现元素之间的拖拽功能。示例包括 HTML 结构、CSS 样式以及 JavaScript 逻辑,旨在帮助开发者快速理解和应用拖拽技术。 ... [详细]
  • 搜索引擎架构设计
    本文详细介绍了搜索引擎的主要组成部分,包括爬虫模块、索引模块和搜索模块。其中,索引模块采用了高效的二元分词技术进行数据存储,而搜索模块则基于ASP.NET框架实现了一个用户友好的界面和高效的搜索算法。 ... [详细]
  • 本文将指导你如何通过自定义配置,使 Windows Terminal 中的 PowerShell 7 更加高效且美观。我们将移除默认的广告和提示符,设置快捷键,并添加实用的别名和功能。 ... [详细]
  • 帝国cms各数据表有什么用
    CMS教程|帝国CMS帝国cmsCMS教程-帝国CMS精易编程助手源码,ubuntu桥接设置,500错误是tomcat吗,爬虫c原理,php会话包括什么,营销seo关键词优化一般多 ... [详细]
author-avatar
jkjkjd_105
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有