Android Studio库项目错误 [英] Android Studio Library project error

查看:284
本文介绍了Android Studio库项目错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将模块导入到我的项目中。当我重建项目时,AS给了我一个错误,告诉我:项目应用程序中的Dependency Lib:未指定解析为不支持作为编译依赖项的APK归档文件。 我搜索并更改了应用插件'com.android.application' apply plugin:'com.android.library ',并从defaultConfig中删除了ApplicationId。然而,我得到了同样的错误警告:依赖项库:未指定在项目应用程序解析为一个APK档案,不支持作为编译依赖项。任何人都可以帮助我



以下是我的gradle代码:

  apply plugin:' com.android.library'

android {
compileSdkVersion 23
buildToolsVersion23.0.1

defaultConfig {
minSdkVersion 12
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'



$ b依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
testCompile'junit:junit:4.12'
compile'c​​om.android.support:appcompat-v7:23.1.0'
compile'c​​om.android.support:design:23.1.0'
compile project(':DimenLib')
}


解决方案

< blockquote>

警告:Dependency Lib:未指定在项目应用程序上解析为不支持作为编译依赖项的APK归档文件。


当您尝试添加一个APK相关时,就会发生这种情况。 使用:

  apply plugin:'com.android.application'

告诉Gradle将其构建为应用程序,生成APK

使用:

  apply plugin:'com.android.library'

它将构建为一个库,生成一个AAR



就你而言,看起来你正在改变插件在错误的地方。

它似乎是您的主要模块

  apply plugin:'com.android.librar (':DimenLib')
}



DimenLib 中移动 apply插件:'com.android.library'

I have imported a module into my project. When i rebuilt the project , AS gave me an error saying Warning:Dependency Lib:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency. I searched and changed apply plugin: 'com.android.application' to apply plugin: 'com.android.library' and also removed ApplicationId from defaultConfig. Yet i am getting this same error "Warning:Dependency Lib:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency." Can any one help me?

Here is my gradle code:

apply plugin: 'com.android.library'

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 12
        targetSdkVersion 23
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile project(':DimenLib')
    }

解决方案

"Warning:Dependency Lib:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency."

It happens when you are trying to add a dependency which is an APK.

Using:

apply plugin: 'com.android.application'

tells Gradle to build it as an application, generating an APK.

Using:

apply plugin: 'com.android.library'

it will build as a library, generating an AAR.

In your case, it seems that you are changing the plugin in the wrong place.
It seems to be your main module.

apply plugin: 'com.android.library'

dependencies {
    compile project(':DimenLib')
}

Move the apply plugin: 'com.android.library' in your DimenLib.

这篇关于Android Studio库项目错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆