【发布时间】:2019-12-16 12:01:50
【问题描述】:
我创建了一个 android 应用程序并希望将其作为模块添加到其他应用程序。我尝试使用以下方法导入应用程序:文件->新建->导入模块->(浏览要导入的应用程序)->(更改模块名称)->完成
导入应用程序后发生以下变化:
setting.gradle
import ':app'
import ':ocr'
build.gradle(Module:app)
implementation project(path: ':ocr')
模块被添加到项目中。
但是当我尝试 sync 项目时,它显示以下错误:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :ocr.
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :ocr.
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :ocr.
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project :ocr.
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve project :ocr.
我试图四处寻找问题,但无法解决。谁能告诉问题出在哪里或如何解决?
【问题讨论】:
-
确保 ocr 模块中的 build.gradle 有“apply plugin: 'com.android.library'”而不是“apply plugin: 'com.android.application'”
-
是的,我更改了“应用插件:'com.android.library'”而不是“应用插件:'com.android.application'”,但它引发另一个错误为错误:原因:java。 lang.NullPointerException。因为我使用的是firebase ocr,所以我需要在设置中添加“应用插件:'com.google.gms.google-services'”和“类路径'com.google.gms:google-services:4.2.0'”,gradle
标签: android android-gradle-plugin build.gradle android-module