Android Studio 升级到3.1.2问题小结

Android studio冲2.1版本升到3.1.2遇到好多问题,在这里做一下简单的总结,希望同道中人有则改之、无则加勉:

首先:

     在安装完成后,需要对Gradle进行对应的升级,在升级过程中会遇到“Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.3-all.zip'.”这样的错误,重试了很多次都不行,后来重启电脑,这个问题就解决了,不得不感叹,还是重启大法好啊

其次:

     在Android studio 3.0中build gradle的时候遇到“Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html”这样的错误提示,如图:

这里出现错误的原因是Android studio 3.0以后build.gradle中的关键词compile、testCompile、androidTestApi 将被implementation、testImplementation、androidTestImplementation等关键词替代,这里只需要将build.gradle中对应的关键词修改掉,重新编译即可。

然后:

      在编译完成后,将app运行到模拟器上时,会遇到如下错误:

主要是因为我在工程里的module依赖了butterknife的jar包,而jar里面又用到了注解。在新的gradle版本里,需要写新的groovy代码来对每个引用注解的地方单独配置。而在以往的版本中,gradle会默认给每个module都依赖一个annotationProcess,导致很多多余的对annotationProcess的依赖。对应的解决方法如下:

在相应的module的gradle文件中,使用javaCompileOptions:

defaultConfig {
        applicationId "com.breakloop.httpurlconnectiondemo"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        //添加了javaCompileOptions 
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath = true
            }
        }
    }
然后重新编译运行到模拟器上即可

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,你遇到的问题是在将Spring Boot版本升级3.1.2后,出现了报错信息"Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required"。这个错误通常是由于MyBatis Plus的配置问题引起的。解决这个问题的方法如下: 1. 确保你的项目中已经正确配置了MyBatis Plus的相关依赖。在你的pom.xml文件中,检查是否添加了正确的依赖项,例如`mybatis-plus-boot-starter`。 2. 检查你的配置文件,确保已经正确配置了MyBatis Plus的相关属性。在Spring Boot的配置文件(例如application.properties或application.yml)中,检查是否包含了以下属性的配置: ```yaml mybatis-plus.mapper-locations=classpath*:mapper/**/*.xml mybatis-plus.type-aliases-package=com.example.entity ``` 这些属性用于指定MyBatis Plus的mapper文件的位置和实体类的包路径。 3. 确保你的MyBatis Plus的配置类正确配置了`SqlSessionFactory`或`SqlSessionTemplate`。在你的配置类中,检查是否包含了以下代码: ```java @Configuration @MapperScan("com.example.mapper") public class MyBatisPlusConfig { @Autowired private DataSource dataSource; @Bean public SqlSessionFactory sqlSessionFactory() throws Exception { SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); // 其他配置... return sessionFactory.getObject(); } // 或者使用SqlSessionTemplate @Bean public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { return new SqlSessionTemplate(sqlSessionFactory); } } ``` 这些代码用于配置MyBatis Plus的`SqlSessionFactory`或`SqlSessionTemplate`。 如果你按照上述步骤检查并配置了你的项目,仍然出现报错信息"Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required",那么可能是其他原因引起的。你可以尝试查看详细的错误日志或搜索相关的解决方案来解决这个问题

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值