您好我有一个机器人库项目产生的AAR。
所有这些都是好的,但是当我使用AAR在另一个项目中,我得到这个错误:
java.lang.NoClassDefFoundError的:com.squareup.picasso.Picasso
在AAR利用毕加索,是有可能产生一个在导出AAR的相关性呢?
解决方案一个人怎么可以去建立一个本地Maven回购。
警告:下面的食谱工作,但可能无法使用改进的,因为我的据的从Maven的专家。我敲定了这个方法,去年为使用我CWAC库。
步骤#1:添加类路径com.github.dcendents:Android的行家 - 插件:1.0
您 buildscript
依赖
块库中的项目的 build.gradle
文件。另外补充版本
和组
报表提供有关您AAR的信息。
步骤#2:使用 摇篮安装
编译AAR和默认的本地仓库安装
第三步:一般情况下,你会增加您的应用程序项目的 mavenLocal()
到依赖
块通过其工件ID拿起AAR。这可能会再次合作,虽然它是一个有点破。相反,使用行家{URL$ {System.env.HOME} /。平方米/库}
作为一个短期的解决办法。
因此,举例来说,你的库项目 build.gradle
文件可能包含以下内容:
buildscript {
库{
mavenCentral()
}
依赖{
类路径com.android.tools.build:gradle:0.9.+
类路径com.github.dcendents:Android的行家 - 插件:1.0
}
}
应用插件:机器人库
应用插件:Android的行家
版本0.4.0
集团some.likely.group.name.goes.here
库{
mavenCentral()
}
依赖{
编译com.squareup.picasso:毕加索:2.2.0
编译文件树(导演:库,包括:的* .jar)
}
安卓{
//为正常
}
您会使用 摇篮安装
发布的JAR到你的本地Maven回购。您的应用程序的项目将不得不在下面的东西,它 build.gradle
:
buildscript {
库{
mavenCentral()
}
依赖{
类路径com.android.tools.build:gradle:0.9.+
}
}
应用插件:'机器人'
库{
mavenCentral()
行家{URL$ {System.env.HOME} /。平方米/库} // mavenLocal()
}
依赖{
编译some.likely.group.name.goes.here:name-of-library:0.4.0
}
安卓{
//为正常
}
在这里你替换:
some.likely.group.name.goes.here
的东西
0.4.0
在XYZ格式的版本号
名称库 -
将是包含了Android库项目(目录名,例如, presentation
或富
)
Hi I have a Android Library Project which produces an AAR.
All is good but when I use the AAR in another project I get this error:
java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso
The AAR makes use of picasso, is it possible to export the dependencies of the AAR as well when generating one?
解决方案How can one go about setting up a local maven repo.
WARNING: the following recipe works, but probably could use improvement, as I am far from a Maven expert. I hammered out this approach last year for use with my CWAC libraries.
Step #1: Add classpath 'com.github.dcendents:android-maven-plugin:1.0'
to your buildscript
dependencies
block in your library project's build.gradle
file. Also add version
and group
statements to provide that information about your AAR.
Step #2: Use gradle install
to compile the AAR and install it in the default local Maven repository.
Step #3: Ordinarily, you would add mavenLocal()
to the dependencies
block of your application project to pick up the AAR via its artifact ID. That may be working again, though it was broken for a bit. Instead, use maven { url "${System.env.HOME}/.m2/repository" }
as a short-term workaround.
So, for example, your library project build.gradle
file might contain:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.github.dcendents:android-maven-plugin:1.0'
}
}
apply plugin: 'android-library'
apply plugin: 'android-maven'
version '0.4.0'
group 'some.likely.group.name.goes.here'
repositories {
mavenCentral()
}
dependencies {
compile 'com.squareup.picasso:picasso:2.2.0'
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
// as normal
}
You would use gradle install
to publish the JAR to your local Maven repo. Your application project would then have the following stuff in its build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
maven { url "${System.env.HOME}/.m2/repository" } // mavenLocal()
}
dependencies {
compile 'some.likely.group.name.goes.here:name-of-library:0.4.0'
}
android {
// as normal
}
where you replace:
some.likely.group.name.goes.here
with something
0.4.0
with a version number in X.Y.Z format
name-of-library
will be the directory name that contains the Android library project (e.g., presentation
or foo
)
上一篇:如何自定义CirclePageIndicator?自定义、CirclePageIndicator
下一篇:从邮递员执行列表 REST API 时出现错误 415 Unsupported Media Type邮递员、出现错误、列表、REST