我正在一个项目中,其中一个外部aar文件与我的应用程序集成在一起。当我集成此aar文件时,如果没有导航,它的工作效果很好,但是当我通过导航添加文件时,它给了我以下错误
我还清理了项目,使缓存重新启动无效,但是它不起作用,出了什么问题
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\layout\activity_abdashborad.xml:10: AAPT: error: attribute defaultNavHost (aka com.mag:defaultNavHost) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\layout\activity_abdashborad.xml:10: AAPT: error: attribute navGraph (aka com.mag:navGraph) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\layout\activity_ablogin.xml:9: AAPT: error: attribute defaultNavHost (aka com.mag:defaultNavHost) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\layout\activity_ablogin.xml:9: AAPT: error: attribute navGraph (aka com.mag:navGraph) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\abdashboard_navigation.xml:2: AAPT: error: attribute startDestination (aka com.mag:startDestination) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\abdashboard_navigation.xml:8: AAPT: error: attribute destination (aka com.mag:destination) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\abdashboard_navigation.xml:12: AAPT: error: attribute destination (aka com.mag:destination) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\ablogin_navigation.xml:2: AAPT: error: attribute startDestination (aka com.mag:startDestination) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\ablogin_navigation.xml:8: AAPT: error: attribute destination (aka com.mag:destination) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\ablogin_navigation.xml:14: AAPT: error: attribute destination (aka com.mag:destination) not found.
C:\Users\ip500\.gradle\caches\transforms-1\files-1.1\abd-release.aar\2dc4e4c1d8eaf250fd060d9c37fbba72\res\navigation\ablogin_navigation.xml:15: AAPT: error: attribute destination (aka com.mag:destination) not found.
答案 0 :(得分:2)
AAR本身不会不嵌入或以其他方式编码有关传递依赖项的任何内容(例如您的AAR对导航的依赖项),因此,如果您只是将AAR用作local binary dependency,您需要重新声明所有传递依赖。
根据Gradle Declaring Dependencies documentation,适当的依赖关系以Maven存储库的形式存在(本地或远程)。 Maven存储库除了托管AAR本身之外,还包括一个POM file,用于声明您的库所依赖的传递依赖项。这样可以确保您的构建中包含的每个库只有一个版本(因为它可以对多个库中的传递依赖项进行重复数据删除)。