java - 如何将 jar 文件(maven)导入 Android Studio?

标签 java android eclipse maven android-studio

我想将一个 jar 文件导入到我的 Android 项目中。( here is the jar file )
这是我的步骤:

  1. 在 MANIFEST.MF 文件中添加两行(Class-Path 和 Main-Class)
    类路径:libs/nineoldandroids-2.4.0.jar
    主类:com.demos.tencent_qq_ui.Aty.MainActivity

  2. 将jar文件拖到libs目录下

  3. 右键单击“添加为库”

  4. 编辑我的build.gradle文件
    依赖项{
    编译 fileTree(dir: 'libs', include: ['*.jar'])
    编译 'com.android.support:appcompat-v7:22.2.0'
    编译文件('libs/nineoldandroids-2.4.0.jar')

重建项目 --> 运行

但出现错误:Couldn't find or load Main Class com.demos.tencent_qq_ui.Aty.MainActivity

我谷歌了很长时间,但没有得到太多有用的信息......

如果能帮助我发现错误,我们将不胜感激。谢谢!
操作系统:ubuntu 15.04
IDE:Android Studio 1.2

最佳答案

<dependency>
  <groupId>com.nineoldandroids</groupId>
  <artifactId>library</artifactId>
  <version>2.4.0</version>
</dependency>

我想这可以像这样转换为 gradle 依赖:

dependencies {
  compile 'com.nineoldandroids:library:2.4.0'
}

因为图书馆在maven central这应该工作。 我认为您不需要向 MANIFEST.MF 添加任何内容

确保你的 build.gradle 中有 mavenCentral,如下所示:

buildscript {
    repositories {
        mavenCentral()
    }
}

关于java - 如何将 jar 文件(maven)导入 Android Studio?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31970368/

相关文章:

java - 抽屉导航后退按钮到主要 fragment

android - DatagramSocket.bind();套接字异常 : cannot assign requested address. Android 模拟器

android - [android]如何保持与数据库的连接?

eclipse - 在 Eclipse 3.5 中安装普通插件 jar

android - 新 Android 项目中缺少 main.xml - Eclipse OS X

java - 检查 ace 是否存在以及点数是否 >21

java - 如何使用eclipse编写并执行PIG Latin

java - 我有一个旧版本的jar,现在我想使用jlink生成一个更小的jre,该怎么做?

java - 如何确定属于空间中两条不相交线之间距离的点

java.io.FileNotFoundException : Could not open ServletContext resource [/WEB-INF/final-servlet. xml]