Android Studio 2.0 to Android Studio 3.0
本文转自 https://www.codexpedia.com/android/android-studio-2-0-to-android-studio-3-0/
When importing Android project that was using gradle 2+ and Android Studio 2+ into Android Studio 3.0, Android Studio 3.0 might run into this error.
Error:Could not initialize class org.jetbrains.kotlin.kapt.idea.KaptModelBuilderService
Replace following project gradle file which uses gradle 2.2.2
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
with this project gradle file to use grade 3.0.0 to work with Android Studio 3.0+
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { google() jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
In the app gradle file, replace these plugins with
apply plugin: 'com.android.application'apply plugin: 'io.fabric'apply plugin: 'com.neenbedankt.android-apt'
these plugins.
apply plugin: 'com.android.application'apply plugin: 'kotlin-android'apply plugin: 'kotlin-android-extensions'apply plugin: 'kotlin-kapt'apply plugin: 'io.fabric'
In the dependencies tag in the app gradle file, replace compile
to implementation
, replace testCompile
with testImplementation
, replace androidTestCompile
with androidTestImplementation
For projects using dagger 2. replace
compile 'com.google.dagger:dagger:2.7'apt 'com.google.dagger:dagger-compiler:2.7'provided 'javax.annotation:jsr250-api:1.0'withimplementation "com.google.dagger:dagger:2.11"implementation "com.google.dagger:dagger-android:2.11"kapt "com.google.dagger:dagger-compiler:2.11"
Now you will probably get this error if you haven’t upgraded the gradle library in the gradle-wrapper.properties file.
Could not find method google() for arguments [] on repository container.
So, let’s replace this line in the gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
with this line
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Then do a clean and rebuild, everything should work now.
更多相关文章
- Android-TextView多行本文滚动轻松实现
- 解析PHP的基本文本输出
- php 读取文本文件
- 从文本文件中读取,然后决定是否要在php中禁用或启用按钮
- python 读写文本文件
- Python -在文本文件中添加日期戳
- 文本文件到字符串数组?
- 50分求关于执行SQL脚本文件的问题,在线等 解决了马上结贴。
- 请问用Java如何逐行的读取一个文本文件呀?我现在只能完整读取.