Android Studio不能打开外来的项目:使用Gradle重建项目

下载了完整的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
}


②点击同步,问题解决





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值