本人遇到升级android studio 升级3.1.1的问题

1.
 
AndroidStudio3.1对应的gradle版本为4.4
使用compile依赖包都要替换为api或implementation,否则会一直gradle失败

compileSdkVersion 27
buildToolsVersion '27.0.3'

api 'com.android.support:appcompat-v7:26.1.0'
api 'com.android.support:recyclerview-v7:26.1.0'
api 'com.android.support:design:26.1.0'

2.

 
升上3.1之后,gradle build总是出现“The option 'android.enableAapt2' is deprecated and should not be used anymore. Use 'android.enableAapt2=true' to remove this warning.
打开gradle.properties添加下面代码即可解决:
android.enableAapt2=false

3.

 
The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
旧版本 - > 新版本

instrumentTestCompile - > androidTestCompile

instrumentTest  - > androidTest

4.

Cannot resolve symbol KeyEventCompat(android.support.v4.view.KeyEventCompat找不到)
解决方案
KeyEventCompat类(我项目中用它的hasNoModifiers方法)最后查看源码 才知道这个hasNoModifiers方法已经被KeyEvent实现了。 贴出源码:
//报错地方
                    // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
                    // before Android 3.0. Ignore the tab key on those devices.
//                  if (KeyEventCompat.hasNoModifiers(event)) {
//                      handled = arrowScroll(FOCUS_FORWARD);
//                  } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
//                      handled = arrowScroll(FOCUS_BACKWARD);
//                  }


//                  http://blog.csdn.net/lrpshuai/article/details/78392872

//正确代码
                    if (event.hasNoModifiers()) {
                        handled = arrowScroll(FOCUS_FORWARD);
                    } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                        handled = arrowScroll(FOCUS_BACKWARD);
                    }

5.

创建项目后报错
com.android.ide.common.process.ProcessException:Failed to execute aapt

原因:在build.gradle文件中,
compileSdkVersion 和buildToolsVersion 不匹配, 改成1中的 27和 27.0.3

最后,项目只能buildapk 不能发布到手机,然后将回3.0了,死到了gradle升级3.0以后的问题

error: style attribute '@android:attr/attr/windowBackground' not found.

网上搜的 都不行,appt false之后又给我报了一个

java.util.NoSuchElementException

定位不到错误位置,so放弃了


评论中大佬回复解决,请看评论

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值