在Android Studio项目上添加Maven依赖项(XML)

时间:2015-08-04 14:57:37

标签: maven android-studio gradle

我正在尝试在我的Android应用中使用this Java库。从文档中,我必须在我的build.grade依赖项中编译“json-to-pdf:json-to-pdf:0.7.5”。当我尝试同步项目时,出现错误:

  

错误:(39,13)无法解决:json-to-pdf:json-to-pdf:0.7.5

asked the owner,但他不知道如何修复它。我想我必须在build.grade中添加以下Maven依赖项:

<repositories>
  <repository>
    <id>clojars.org</id>
    <url>http://clojars.org/repo</url>
  </repository>
</repositories>

但我不知道该怎么做。

到目前为止,这是我的设置:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    compileOptions.encoding = 'ISO-8859-1'

    defaultConfig {
        applicationId "br.com.app"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    jcenter()
    //mavenCentral() I tried that but doesn't work
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    ...
    compile 'json-to-pdf:json-to-pdf:0.7.5' // Doesn't work
}

1 个答案:

答案 0 :(得分:0)

您必须在build.gradle中定义clojars Maven存储库。

WITH Note_Max AS
(
    SELECT  ID, SubjectID, Stat, 
            MAX([Note Strength Value]) AS [Note Strength Value]
     FROM   dbo.Note
     WHERE  SeasonContext = 2015 AND 
            Days in (99999, 7, 14, 30, 60, 90, 77777, 88888)
     GROUP BY SubjectID,Stat
)

SELECT  n.ID
        ,n.SubjectID
        ,dbo.udf_StripHTML(ISNULL(n.Note,'')) AS [Note]
        ,n.[Note Strength Value]
FROM    Note n 
INNER JOIN
        n.ID = Note_Max.ID
WHERE   n.SubjectID = 14463
ORDER BY n.[Note Strength Value] DESC

这个库的作者可能应该将它添加到GitHub自述文件中。

更新:我使用应添加到文档中的相应Gradle代码段回应了GitHub问题。