Android studio编程时出现的错误:unspecified on project app resolves to an APK archive which is not supported

用Android Studio中导入第三方库工程的时候出现的问题:

Error:Dependency MyApplication.libraries:MaterialDesign:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. File: D:\ADTBundle\StudioWorkspace\MyApplication\libraries\MaterialDesign\build\outputs\apk\MaterialDesign-release-unsigned.apk


出现该问题unspecified on project app resolves to an APK archive which is not supported as a compilation dependency的问题可能是:创建了两个Module,其中一个Module依赖另一个Module而导致了出现该问题;

在导入的那个第三方库的build.gradle,里面可以看到:

apply plugin: 'com.android.application'  
这句话是Gradle将导入的第三方库编译称为application,也就是apk,这就是问题的所在;

解决方法:将上面该句改为:

apply plugin: 'com.android.library' 

此时,Gradle将编译称为一个Library,也就是库

运行之后,如果出现这个问题:

Error:Library projects cannot set applicationId. applicationId is set to 'package_name' in default config.

那是因为这个库不允许设置applicationId

将第三方库的build.gradle: android — defaultConfig 中的 applicationId 删除 即可


然后问题即可解决~


你可能感兴趣的:(Android studio编程时出现的错误:unspecified on project app resolves to an APK archive which is not supported)