下载了完整的Android项目(URL:http://www.cniao5.com/course/10043),考虑到项目的原作者也是用Android Studio构建的;
1.直接打开项目
1.1按照正常的思路,尝试直接打开项目:
1.2打开的项目缺失res文件,然后各种报错,并且尝试各种修复都失败
2、通过Gradle构建项目
2.1 选择import project ,一直下一步。。
2.2 软件自动调用了Gradle作为项目的构建工具,res出现了
不过,Gradle上报出以下错误:
Error:(2) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat'.
Error:(8, 29) No resource found that matches the given name: attr 'actionBarStyle'.
Error:(10, 29) No resource found that matches the given name: attr 'actionBarTabTextStyle'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name '@style/Widget.AppCompat.ActionBar'.
Error:(41, 29) No resource found that matches the given name: attr 'background'.
Error:(42, 29) No resource found that matches the given name: attr 'backgroundStacked'.
Error:(44, 29) No resource found that matches the given name: attr 'titleTextStyle'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name '@style/Widget.AppCompat.ActionBar.TabView'.
Error:(41, 29) No resource found that matches the given name: attr 'background'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name '@style/Widget.AppCompat.ActionBar.TabText'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name '@style/TextAppearance.AppCompat.Widget.ActionBar.Title'.
2.3解决方法:
2.3.1问题:找不到引用:
@style/Theme.AppCompat
(引用来源为com.android.support:appcompat-v7:22.2.1)
①打开 File---Project Structure---app---Dependencies
②+ 第一项 找到com.android.support:appcompat-v7:22.2.1,OK!
2.3.2 问题:SDK版本问题
解决方法:①在build.gradle(module:app)中修改一下选项
defaultConfig {
applicationId
"com.cniao5.jizha"
minSdkVersion
10
targetSdkVersion
10
}
修改为:
defaultConfig {
applicationId
"com.cniao5.jizha"
minSdkVersion
14
targetSdkVersion
18
}
②点击同步,问题解决