以前我使用 File > New > New Module > Import .JAR/.AAR Package
但是从新模块向导中导入 .JAR/.AAR 包的选项已在 Android Studio 4.2 上删除,并遵循建议使用项目结构对话框的文档显示 导入 .AAR 模块没有明确的答案,似乎已经过时
我尝试将模块添加为项目结构中的依赖项,但没有用
我将库发布到内部Sonatype Nexus存储库.
Android Studio具有一项功能,可以自动查找通过gradle引用的库的正确来源.我将aar的来源作为一个单独的jar发布给nexus.但是Android Studio并没有把它们搞砸.
如何发布源代码以使其在Android Studio中可用?
类似问题中的所有答案都谈论了manderally编辑gradle文件.但我已经使用Android Studio导入AAR文件并检查了build.gradle文件,它们看起来都是正确的.
我的问题是:

我已经导入了ShowCaseView v5.0.0 AAR但是当我尝试在Tutorial.java文件中导入类时(你可以看到红色),Android Studio无法识别这些类.Android Studio识别的唯一导入是com.github.amlcurran.showcaseview.R.
我还试图清理和重建项目,关闭并重新打开Android Studio,但它没有帮助.
PS请忽略丢失的XML文件,就像我将它们复制到项目之前一样.
ShowCaseView-5.0.0> build.gradle:
configurations.create("default")
artifacts.add("default", file('ShowCaseView-5.0.0.aar'))
Run Code Online (Sandbox Code Playgroud)
我的应用程序的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.giraffeweather"
minSdkVersion 19
targetSdkVersion 21
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 'com.android.support:appcompat-v7:21.0.3'
compile project(':ShowCaseView-5.0.0')
}
Run Code Online (Sandbox Code Playgroud)
Android Studio项目的build.gradle:
// Top-level build file where you can add configuration options common to …Run Code Online (Sandbox Code Playgroud) 我想知道是否可以将我的原生.so文件打包到我的.aar文件中?如果是这样,.so文件将去哪里,是否有任何我可以阅读的参考文件?
我的项目包括一些图书馆项目.库正在使用一些aar文件,其dependecny已在模块:gradle文件中定义.我在项目中包含这个库时遇到了问题.
如果我在app-> lib中保留重复的aar文件并在app-> gradle文件中定义它们的依赖关系,那么就没有问题.但它不应该是正确的方法.
请在下面找到错误:
配置项目':app'时出现问题.
Could not resolve all dependencies for configuration ':app:_qaDebugCompile'. Could not find :api-release:. Searched in the following locations:
https://jcenter.bintray.com//api-release//api-release-.pom
https://jcenter.bintray.com//api-release//api-release-.aar
file:/D:/sample/sample-android-app/app/libs/api-release-.aar
file:/D:/sample/sample-android-app/app/libs/api-release.aar
Required by:
sample-android-app:app:unspecified > sample-android-app:misnapworkflow:unspecified
Run Code Online (Sandbox Code Playgroud)
请在下面找到项目结构:
sample
|-- app
|-- misnapworkflow
|
|-- lib
|-- api-release.aar
Run Code Online (Sandbox Code Playgroud)
在app gradle文件中,已经提到过包含该项目的文件
依赖项{compile project(':misnapworkflow')}
请在下面找到misnapworkflow gradle文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
consumerProguardFiles 'proguard-rules.pro'
}
lintOptions {
abortOnError false
}
// Publish both debug and release libraries
publishNonDefault …Run Code Online (Sandbox Code Playgroud) 从这个参考:
https://github.com/codepath/android_guides/wiki/Building-your-own-Android-library
我有以下gradle文件:
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
buildTypes {
release {
minifyEnabled true
consumerProguardFiles 'consumer-proguard-rules.pro'
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下proguard文件:
-dontobfuscate
-optimizations !code/allocation/variable
-keep public class * {
public protected *;
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行'assembleRelease'任务来构建我的发布aar文件时,aar中的所有类都丢失了.
有任何想法吗?
有没有人找到一种在Unity3D中使用Android .aar库的好方法,而不是解压缩它们?
Unity 4.2发行说明中的代码段:
该统一的文件澄清
预编译意味着所有.java文件必须已编译到位于项目的bin /或libs /文件夹中的jar文件中.
我熟悉使用jar + res/solution; 但我特意试图找出合并预编译aar的最佳方法.有什么东西比解压缩更好吗?
我有几个项目,我建立了一个.aar.然后我将这个.aar导入到/ libs下的Android Studio中.此依赖项的build.gradle文件如下所示:
repositories{
flatDir{
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.android.support:multidex:+'
compile(name: 'customApi-debug', ext:'aar')
}
Run Code Online (Sandbox Code Playgroud)
由于库非常大,我设置了multiDexEnabled = true.Android Studio查找库和自动填充功能.构建工作正常,但运行应用程序会出现以下错误:
java.lang.NoClassDefFoundError: com.companyx.android.api.ui.vision.metaio.MetaIoView
at com.companyx.android.api.ui.vision.metaio.MetaIoView$$InjectAdapter.<init>(MetaIoView$$InjectAdapter.java:29)
Run Code Online (Sandbox Code Playgroud)
我分别对.aar和dex文件进行了解压缩和反汇编,并验证了它所抱怨的类实际存在.我已经尝试过处理这个问题的现有方法,但没有一个能够工作.
有人经历过这个吗?提前致谢.
我写了一个cameraBarcodeScanner内置在aar文件中的库项目.此库在其build.gradle中定义了以下依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.zxing:core:3.2.1'
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
}
Run Code Online (Sandbox Code Playgroud)
我在测试应用程序中使用该库,如下所示:
dependencies {
compile(name: 'cameraBarcodeScanner-release', ext: 'aar')
}
Run Code Online (Sandbox Code Playgroud)
Gradle找到应用程序并能够构建它.但是,在运行时,android无法找到位于其中的类zxing-android-embedded.在我看来,gradle没有下载库项目的依赖项.我也尝试过:
dependencies {
compile(name: 'cameraBarcodeScanner-release', ext: 'aar'){
transitive = true
}
Run Code Online (Sandbox Code Playgroud)
但这也没有帮助.我是否必须以某种方式公开库的依赖项?您将如何使用库并使gradle下载其依赖项?
提前致谢!
android gradle android-gradle-plugin aar gradle-dependencies
我有一个包含library.so和其他一些资源和 java 文件的android_library.aar文件。
我将android_library.aar导入到我的项目中。我的项目使用带有 NDK 的 C++ 代码。我的问题是我无法使用 CMake编译依赖于library.so 的C++ 代码。如何在 CMake 编译之前从aar 中提取library.so?我想在没有 java 的情况下直接将library.so包含到我的 C++ 代码中。我知道如何将.so包含在项目中,但我不知道如何从 aar 内部进行。