简体   繁体   English

无法找到具有 Gradle 路径的模块。 链接到库 - 未指定

[英]Unable to find module with Gradle path. Linking to library -unspecified instead

Update 2 This has been fixed in Android Studio 1.2 Beta 3更新 2这已在 Android Studio 1.2 Beta 3 中得到修复

Update: This has reportedly been fixed in an upcoming release of Android Studio.更新:据报道,这已在即将发布的 Android Studio 版本中修复。

In Android Studio 1.2 Beta 2 I started getting the following warnings when syncing Gradle.在 Android Studio 1.2 Beta 2 中,我在同步 Gradle 时开始收到以下警告。

Failed to set up dependencies
Warning:Unable to find module with Gradle path ':Library1'. Linking to library 'Library1-unspecified' instead.
Warning:Unable to find module with Gradle path ':Library2'. Linking to library 'Library2-unspecified' instead.

I've noticed that jumping to a declaration declared in one of the library modules pulls up the Decompiler instead of just going to the actual source in the library module.我注意到跳转到库模块之一中声明的声明会拉出反编译器,而不是仅仅转到库模块中的实际源代码。

In my Android Studio Project I have the following modules:在我的 Android Studio 项目中,我有以下模块:

- App
- Library1
- Library2

Module: App build.gradle snippet:模块:App build.gradle片段:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':Library1')
    compile project(':Library2')
}

settings.gradle file: settings.gradle文件:

include ':App'
include ':Library1'
include ':Library2'
project(':Library1').projectDir = new File(settingsDir, '../library1/lib')
project(':Library2').projectDir = new File(settingsDir, '../Library2/lib')

I faced this with Android Studio 2.2.3.我在 Android Studio 2.2.3 中遇到了这个问题。 The problem was with the .iml file that was causing the problem.问题出在导致问题的.iml文件上。

After importing the module folder into the project directory and adding the changes to include module in settings.gradle , delete the .iml file from the module folder and do a Gradle Sync.将模块文件夹导入项目目录并添加更改以在settings.gradle包含模块后,从模块文件夹中删除.iml文件并执行 Gradle 同步。 Then right click on any module in the Project Window and click on "Configure Project Subset...", if the imported module is not checked, check it and Android Studio should do a Gradle Sync.然后右键单击项目窗口中的任何模块,然后单击“配置项目子集...”,如果未选中导入的模块,请选中它,Android Studio 应该执行 Gradle 同步。 By then the imported module will appear in the Project Window and will have a .iml file regenerated that is does not cause any issues.届时,导入的模块将出现在项目窗口中,并将重新生成一个不会导致任何问题的.iml文件。

  1. delete the .iml file under the error module.删除error模块下的.iml文件。
  2. restart Android studio重启安卓工作室

右键单击项目,选择“配置项目子集...”并选择您的模块,重建您的项目。

I met the same problem on AS 2.0 preview, and I fixed it by following steps:我在 AS 2.0 preview 上遇到了同样的问题,我按照以下步骤修复了它:

1.Rename the module. 1.重命名模块。 2.Change the names in app/build.gradle and setting.gradle. 2.更改 app/build.gradle 和 setting.gradle 中的名称。 3.Start gradle sync. 3.启动gradle同步。

I don't know why but it works on my issue.我不知道为什么,但它适用于我的问题。

Check in settings.检查设置。 of your app.你的应用程序。 Down there is the field "Load/Unload Modules"下面是“加载/卸载模块”字段

Your module might be unloaded, that's why Android Studio ignores it even if you specify it in Gradle.您的模块可能已卸载,这就是即使您在 Gradle 中指定它,Android Studio 也会忽略它的原因。

At least that was the problem for me.至少这对我来说是个问题。

在此处输入图片说明

如果您使用的是React-native>60 ,那么您应该在进行 Gradle 同步之前在项目的根目录上运行npx jetify

For me the following worked in Android Studio 3.5.3对我来说,以下在 Android Studio 3.5.3 中有效

First of all, check if the path is correct in your Gradle settings.首先,检查您的 Gradle 设置中的路径是否正确

If the path is correct then invalidate caches & restart by navigating to the top 'File' menu如果路径正确,则通过导航到顶部的“文件”菜单使缓存无效并重新启动

It is a known bug introduced in 1.2 Beta 2.这是 1.2 Beta 2 中引入的已知错误。

See This issue on the Android issue tracker.请参阅 Android 问题跟踪器上的此问题 Fix should be out within hours.修复应该在几个小时内完成。

I had this problem and solved it by clicking on我遇到了这个问题并通过单击解决了它

File> Ivalidate cache / Restart...文件> Ivalidate缓存/重新启动...

as shown below:如下所示:

打印安卓工作室

Problem:问题:

This problem can also occur when you change the path to the module.当您更改模块的路径时,也会出现此问题。

settings.gradle设置.gradle

include ':app', ':filechooserlibrary'
project(':filechooserlibrary').projectDir = new File('../../repos-github/file-chooser/file-chooser-library/filechooserlibrary')

I changed the path to '../../github/file-chooser/file-chooser-library/filechooserlibrary'我将路径更改为'../../github/file-chooser/file-chooser-library/filechooserlibrary'

The old path did not exist any more.旧路已不复存在。 But then, instead of accepting the new path, Android Studio recreated the old path structure thus referring to an empty directory.但是,Android Studio 并没有接受新路径,而是重新创建了旧路径结构,从而引用了一个空目录。

Solution: So, I deleted this obsolete path structure and restarted Android Studio, after deleting the .iml file (I don't know if this is necessary, but it cannot do harm).解决方案:所以,我删除了这个过时的路径结构并在删除了 .iml 文件后重新启动了 Android Studio(我不知道这是否有必要,但它不会造成伤害)。 Then I reimported the Gradle project and it worked.然后我重新导入了 Gradle 项目并且它起作用了。

Try using an updated version of NDK .尝试使用NDK的更新版本。

I faced the same issue.我遇到了同样的问题。 I was using NDK version r17c .我使用的是NDK版本r17c Issue solve after using r21e .使用r21e后问题解决。

  • Android Studio Version: 4.1.3安卓工作室版本: 4.1.3
  • OS: Ubuntu 18.04.5操作系统:Ubuntu 18.04.5

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

相关问题 无法找到具有Gradle路径':volley'的模块。链接到库'volley-unspecified'而不是 - Unable to find module with Gradle path ':volley'. Linking to library 'volley-unspecified' instead android gradle错误:无法找到具有Gradle路径':libs'的模块(模块'app'需要。) - android gradle error:Unable to find module with Gradle path ':libs' (needed by module 'app'.) 在自定义Java库模块中编译android模块时,Gradle警告“未指定取决于库但是是jar” - Gradle Warning “unspecified depends on libraries but is a jar ” while compiling an android module within a custom java library module 错误:无法找到带有 Gradle 路径“:capacitor-cordova-android-plugins”的模块 - ERROR: Unable to find module with Gradle path ':capacitor-cordova-android-plugins' Android Gradle无法找到Apache库 - Android Gradle Unable to Find Apache Library Gradle无法与“无法找到可选库”同步 - Gradle failed to sync with 'unable to find optional library' IntelliJ 和 Android Gradle 依赖项 - 找不到模块 - IntelliJ and Android Gradle dependencies - unable to find module Gradle flatDir模块路径 - Gradle flatDir path to module Gradle 同步失败:无法找到请求目标的有效证书路径 - Gradle sync failed: unable to find valid certification path to requested target Android:Gradle-模块依赖性问题-无法找到符号 - Android: Gradle - Module Dependency Issue - Unable to find symbol
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM