热门标签 | 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。这是可靠的方式。


推荐阅读
  • Android中将独立SO库封装进JAR包并实现SO库的加载与调用
    在Android开发中,将独立的SO库封装进JAR包并实现其加载与调用是一个常见的需求。本文详细介绍了如何将SO库嵌入到JAR包中,并确保在外部应用调用该JAR包时能够正确加载和使用这些SO库。通过这种方式,开发者可以更方便地管理和分发包含原生代码的库文件,提高开发效率和代码复用性。文章还探讨了常见的问题及其解决方案,帮助开发者避免在实际应用中遇到的坑。 ... [详细]
  • 解决Only fullscreen opaque activities can request orientation错误的方法
    本文介绍了在使用PictureSelectorLight第三方框架时遇到的Only fullscreen opaque activities can request orientation错误,并提供了一种有效的解决方案。 ... [详细]
  • Android 构建基础流程详解
    Android 构建基础流程详解 ... [详细]
  • 基于Net Core 3.0与Web API的前后端分离开发:Vue.js在前端的应用
    本文介绍了如何使用Net Core 3.0和Web API进行前后端分离开发,并重点探讨了Vue.js在前端的应用。后端采用MySQL数据库和EF Core框架进行数据操作,开发环境为Windows 10和Visual Studio 2019,MySQL服务器版本为8.0.16。文章详细描述了API项目的创建过程、启动步骤以及必要的插件安装,为开发者提供了一套完整的开发指南。 ... [详细]
  • 我有一个从C项目编译的.o文件,该文件引用了名为init_static_pool ... [详细]
  • Hadoop的文件操作位于包org.apache.hadoop.fs里面,能够进行新建、删除、修改等操作。比较重要的几个类:(1)Configurati ... [详细]
  • 通过将常用的外部命令集成到VSCode中,可以提高开发效率。本文介绍如何在VSCode中配置和使用自定义的外部命令,从而简化命令执行过程。 ... [详细]
  • 在 CentOS 6.4 上安装 QT5 并启动 Qt Creator 时,可能会遇到缺少 GLIBCXX_3.4.15 的问题。这是由于系统中的 libstdc++.so.6 版本过低。本文将详细介绍如何通过更新 GCC 版本来解决这一问题。 ... [详细]
  • Spring – Bean Life Cycle
    Spring – Bean Life Cycle ... [详细]
  • 在分析Android的Audio系统时,我们对mpAudioPolicy->get_input进行了详细探讨,发现其背后涉及的机制相当复杂。本文将详细介绍这一过程及其背后的实现细节。 ... [详细]
  • 实验九:使用SharedPreferences存储简单数据
    本实验旨在帮助学生理解和掌握使用SharedPreferences存储和读取简单数据的方法,包括程序参数和用户选项。 ... [详细]
  • 在探讨如何在Android的TextView中实现多彩文字与多样化字体效果时,本文提供了一种不依赖HTML技术的解决方案。通过使用SpannableString和相关的Span类,开发者可以轻松地为文本添加丰富的样式和颜色,从而提升用户体验。文章详细介绍了实现过程中的关键步骤和技术细节,帮助开发者快速掌握这一技巧。 ... [详细]
  • Unity3D 中 AsyncOperation 实现异步场景加载及进度显示优化技巧
    在Unity3D中,通过使用`AsyncOperation`可以实现高效的异步场景加载,并结合进度条显示来提升用户体验。本文详细介绍了如何利用`AsyncOperation`进行异步加载,并提供了优化技巧,包括进度条的动态更新和加载过程中的性能优化方法。此外,还探讨了如何处理加载过程中可能出现的异常情况,确保加载过程的稳定性和可靠性。 ... [详细]
  • 本指南介绍了如何在ASP.NET Web应用程序中利用C#和JavaScript实现基于指纹识别的登录系统。通过集成指纹识别技术,用户无需输入传统的登录ID即可完成身份验证,从而提升用户体验和安全性。我们将详细探讨如何配置和部署这一功能,确保系统的稳定性和可靠性。 ... [详细]
  • Vuforia 开发指南:第二章 环境配置与搭建
    本章节详细介绍了如何在Vuforia官网上完成账号注册及环境配置。首先,访问Vuforia官方网站并点击“Register”按钮,按照提示填写必要的个人信息。提交表单后,系统将验证信息并创建账户。接下来,用户需要下载并安装Vuforia开发工具,确保开发环境的顺利搭建。此外,还提供了详细的配置步骤和常见问题的解决方案,帮助开发者快速上手。 ... [详细]
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社区 版权所有