Android的工作室库"错误:包不存在" [英] Android Studio library "error: package does not exist"

查看:264
本文介绍了Android的工作室库"错误:包不存在"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的Andr​​oid库作为Android的工作室模块。新增的依赖,以我的根模块。虽然编码,我可以从库包导入任何类,但同时我想运行我收到错误的应用程序包some.mylibrary.project不存在

I have created Android library as Android Studio module. Added as dependency to my root module. While coding I can import any class from library package but while I'm trying run the application I'm getting an error package some.mylibrary.project does not exist.

build.gradle 根模块

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}
apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.android.gms:play-services:5.+'
    compile project(':libraries:mylibrary')
}

android {
    compileSdkVersion 17
    buildToolsVersion "20.0.0"

    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
        abortOnError false
    }

    ***
}

build.gradle 库模块

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'idea'

android {
    compileSdkVersion 17
    buildToolsVersion "20.0.0"

     *****    
}

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

settings.gradle

include ':libraries:mylibrary'

P.S。我不得不提的是,项目从Eclipse IDE中导出这样的项目结构是默认的不同。

P.S. I have to mention that the project was exported from Eclipse IDE so the project structure is different from default one.

推荐答案

如果你有一个库模块,则不能使用应用插件:com.android.application在模块定义语句,或构建为你看到的将静默失败。使用应用插件:com.android.library而不是

If you have a library module, it can't use the apply plugin: 'com.android.application' statement in the module definition, or the build will silently fail as you're seeing. use apply plugin: 'com.android.library' instead.

一个错误已被提出来请求构建系统失败了一声,而不是默默地当发生这种情况:<一href="https://$c$c.google.com/p/android/issues/detail?id=76725">https://$c$c.google.com/p/android/issues/detail?id=76725

A bug has been filed to request that the build system fail loudly instead of silently when this happens: https://code.google.com/p/android/issues/detail?id=76725

这篇关于Android的工作室库&QUOT;错误:包不存在&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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