[英]Add AAR file as dependency to Intellj project
I'm using Intellij IDEA 14.1.4 to make an Android project after moving from Android Studio a while back. 我正在使用Intellij IDEA 14.1.4在从Android Studio移动一段时间之后创建一个Android项目。 I made some libraries (through Android Studio) and would like to use them in Intellij.
我制作了一些库(通过Android Studio),并希望在Intellij中使用它们。
However, it seems that Intellij only accepts .jar
files through the libs
folder, and Android Studio only creates .aar
files. 但是,似乎Intellij只通过
libs
文件夹接受.jar
文件,Android Studio只创建.aar
文件。
In Android Studio, one has the option (when creating a new module) to import an existing .jar/.aar
package to be put into a new module. 在Android Studio中,可以选择(在创建新模块时)导入现有的
.jar/.aar
包以放入新模块。 This option doesn't seem to be in intellij. 此选项似乎不在intellij中。 This user seems to think that Intellij supports that, but those instructions allow me to create a brand new Gradle module.
这个用户似乎认为Intellij支持这一点,但这些说明允许我创建一个全新的 Gradle模块。 What I want to do is use an existing
.aar
file. 我想要做的是使用现有的
.aar
文件。
What should I go about doing? 我该怎么办? Should I move back to Studio for this project, or is there a way for me to use these
.aar
files? 我应该为这个项目移回Studio,还是有办法让我使用这些
.aar
文件?
PS Intellij can't process raw aar
s, period. PS的IntelliJ不能处理原始
aar
S,期。 I tried adding this to my gradle files, but got an error: 我尝试将其添加到我的gradle文件中,但出现错误:
compile fileTree(dir: 'libs', include: ['*.aar'])
Edit Here's my build.gradle
: 编辑这里是我的
build.gradle
:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
flatDir() {
dirs 'libs'
}
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ':mylib@aar'
compile 'com.android.support:appcompat-v7:22.2.0'
}
So I saw this option in Intellj called "Associate file..." and associated the aar with an archive. 所以我在Intellj中看到了这个名为“Associate file ...”的选项,并将aar与存档相关联。 Upon recompile I got this error
重新编译后,我收到了这个错误
Warning:Project app: Only Jar-type local dependencies are supported. Cannot handle: mylib.aar
I guess it's only jars for Intellij. 我猜这只是Intellij的罐子。 Back to Android Studio, I suppose :)
回到Android Studio,我想:)
Well first of all you can create .jar files with Android Studio as well, see this but .aars are awesome and enable you to do more then what you could with a jar 首先,您可以使用Android Studio创建.jar文件,看看这个但是.aars非常棒,让您可以用jar做更多的事情
I have not used Intellij IDEA but I assume you have a gradle.build file in your project? 我没有使用过Intellij IDEA,但我假设你的项目中有一个gradle.build文件? If the name of your aar file is
如果您的aar文件的名称是
my_lib_1.0.0.aar
my_lib_1.0.0.aar
and its under the libs directory then try the following in your gradle.build file: 并在libs目录下,然后在gradle.build文件中尝试以下操作:
compile(name:'my_lib_1.0.0', ext:'aar')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.