Android Studio中没有检测到的编译支持库 [英] Android Studio not detecting support libraries on Compilation
问题描述
由于Android的工作室将是为Android开发IDE默认情况下,我决定把我现有的项目移植到Android的工作室。该项目stucture似乎有所不同和文件夹在我的项目层次结构如下:
完整的项目
- > .idea
- >建立
- > Facebook的SDK
- > MainProject
- > ......(其他库)
的build.gradle
local.properties
settings.gradle
...
外部库
- > Android的API 8平台
- > Android的API平台18
- > Android的API平台19
- > 1.7的Java
- >支持 - v4-19.1.0
我MainProject具有其中包含项目中使用不同的罐子一个libs文件夹。它令人惊讶的不包含Android的支持-V4罐子这是present在我的Eclipse项目。因此,它似乎是外部库在根文件夹必须照顾它。
但导入后,当我试图编译该项目开始呕吐符号找不到错误的所有与Android的支持库某些类。
有关如:Android Studio中的自动完成让我建议的NotificaitonCompat从android.support.v4.app.NotificationCompat,但是当我尝试编译我的项目模块它说:
错误:(17 30)错误:无法找到符号类NotificationCompat错误:执行失败的任务:应用程序:compileDebugJava'>编译失败;详情请参见编译器错误输出。
这发生在许多其他类也为相同的支持库。我试图插入一个罐子,并在的build.gradle为MainProject变化相同,但错误依然存在。
我甚至尝试重新启动,并再次生成项目,但没有改变。
编辑:
我附上的摇篮文件MainProject内
的build.gradle在MainProject模块
应用插件:'com.android.application安卓{
compileSdkVersion 19
buildToolsVersion21.1.2defaultConfig {
的applicationIDpackage.app
8的minSdkVersion
targetSdkVersion 19
}buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard的-rules.txt
}
}
}配置{
所有* .exclude组:com.android.support',模块:支持-V4
}依赖{
编制项目(':facebookSDK')
编制项目(':库)
编制项目(':凌空)
编译com.google.android.gms:播放服务:+'
编译com.actionbarsherlock:actionbarsherlock:4.4.0@aar
编译com.android.support:support-v4:19.1.0
编译文件(库/ FlurryAnalytics_3.3.3.jar')
编译文件(库/通用图像装载-1.8.4.jar')
....
}
您构建文件的此部分:
配置{
所有* .exclude组:com.android.support',模块:支持-V4
}
告诉构建系统忽略支持-V4,这就是为什么它没有编制。删除。
在构建文件,你有这样的,这是包括支持正确的方式:
编译com.android.support:support-v4:19.1.0
如果您在库您的任何模块的目录支持库jar文件,将其删除,并确保你提到的这种方式 - 如果包括图书馆作为一个罐子,你可能会碰到那里的罐子被包含多次,这将导致一个错误DEX的一个问题。
Since Android Studio is going to be default IDE for Android Development, I decided to migrate my existing project into Android-studio. The project stucture seems different and the hierarchy of folders in my Project is as follows:
Complete Project
->.idea
-> build
-> Facebook SDK
-> MainProject
-> ... (Other Libraries)
build.gradle
local.properties
settings.gradle
...
External Libraries
-> Android API 8 Platform
-> Android API 18 Platform
-> Android API 19 Platform
-> 1.7 Java
-> support-v4-19.1.0
My MainProject has a libs folder which contains different jars used within the project. It surprisingly does not contain the android-support-v4 jar which was present in my eclipse project. So, it seems that the external Libraries folder at the root must take care of it.
But after import, when I tried to compile the project started throwing "Symbol not found error" for Certain Classes all relating to android support library.
For Eg: The auto complete in Android Studio gives me suggestion for NotificaitonCompat from android.support.v4.app.NotificationCompat, but when I try to compile my Project Module it says
Error:(17, 30) error: cannot find symbol class NotificationCompat Error:Execution failed for task ':app:compileDebugJava'.> Compilation failed; see the compiler error output for details.
This happens in many other classes too for the same support library. I tried to insert a jar and changed the same in the build.gradle for the MainProject, but the error persists.
I even tried restarting and building the project again, but nothing changed.
EDIT: I am attaching the Gradle file inside the MainProject
build.gradle in MainProject Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "package.app"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
dependencies {
compile project(':facebookSDK')
compile project(':library')
compile project(':volley')
compile 'com.google.android.gms:play-services:+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:19.1.0'
compile files('libs/FlurryAnalytics_3.3.3.jar')
compile files('libs/universal-image-loader-1.8.4.jar')
....
}
This part of your build file:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
is telling the build system to ignore support-v4, which is why it isn't compiling. Remove that.
In your build file, you have this, which is the correct way to include support:
compile 'com.android.support:support-v4:19.1.0'
If you have the support library jar file in the libs directory of any of your modules, remove it and make sure you refer to it this way -- if you include the library as a jar, you're likely to run into a problem where the jar is included multiple times which will result in a dex error.
这篇关于Android Studio中没有检测到的编译支持库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!