Android Studio 2.0 to Android Studio 3.0

来源:互联网 发布:培育发展新动力 优化 编辑:程序博客网 时间:2024/06/05 06:44

本文转自 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 toimplementation, replace testCompile with testImplementation, replaceandroidTestCompile 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'<pre>with<pre>implementation "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.

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 窗口期什么意思 冻结窗口怎么设置 关闭窗口快捷键 窗口切换快捷键 关闭窗口的快捷键 电脑命令窗口怎么打开 窗口动画缩放 油价调整窗口 小窗口模式在哪里设置 电脑怎么切换窗口 国际贸易单一窗口 电脑快速切换窗口 暴走大侠兑换码领取窗口在哪 中国国际贸易单一窗口 手机上怎么调出wifi认证窗口 窗台 人造石窗台 窗台板图片 窗台高度 窗台拼音 窗台图片 窗台石图片 窗台飘窗 窗台石价格 窗台上的花 窗台晾衣架 窗台垫 窗台花架 什么的窗台 窗台是什么 窗台的英文 大窗台装修 窗台装修 客厅窗台 高窗台装修 窗台布置 窗台防护网 石材窗台 别墅窗台 窗台英语 装饰窗台