简体   繁体   English

Android Studio-将aar项目导入为库-Apk编译,但包未解析

[英]Android Studio - Importing aar project as library - Apk compiles, but packages not resolved

I'm having problems importing my Android library (which builds to .aar) in my Android project (.apk). 我在Android项目(.apk)中导入我的Android库(构建为.aar)时遇到问题。 I've imported my library as was anwsered here . 我已经导入我的图书馆正如anwsered 这里

Inside the Android Studio editor, my imported library sources are not found - all my imports cannot be resolved. 在Android Studio编辑器中,找不到我导入的库源-无法解析所有导入。

Application actually builds successfully without any error messages as apk. 应用程序实际上构建成功,没有任何错误消息(apk)。

Project root build.gradle: 项目根目录build.gradle:

include ':app', ':Library'
project(':Library').projectDir = new File('libs/Library/app')

Project apk build.gradle dependencies: 项目apk build.gradle依赖项:

compile project(':Library')

The problem was in my Android Library folder structure. 问题出在我的Android库文件夹结构中。 Structure did not correspond to my actual package name. 结构与我的实际包裹名称不符。 IDE underlined package name as the following error, but it still compiled and built aar library archive: IDE在软件包名称下划线标记为以下错误,但它仍编译并构建了aar库归档文件:

package name 'somepackage' does not correspond to the file path 'com.whatever.somepackage.someclass'

Seems like this issue confused Android Studio and it didn't recognise the package, when using it in the android application. 似乎此问题使Android Studio感到困惑,并且在android应用程序中使用该包时无法识别该包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM