Android Studio 2.0 to Android Studio 3.0

出处:http://blog.csdn.net/aifanjian/article/details/73509555

最近使用Android Studio 3.0 canary 3 时新建项目遇到标题所示错误,后网上找到解决办法。记录如下: 
在项目的build.gradle文件中添加如下内容即可解决。

repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

原文章链接

https://stackoverflow.com/questions/44071080/could-not-find-com-android-tools-buildgradle3-0-0-alpha1-in-circle-ci

后面studio 升级canary 4后,新建项目时,项目的build.gradle文件已经变成下面这样了,也不会再发生上述问题了。

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha4'     

        // 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
}
出处: http://blog.csdn.net/hjjxuqinjun/article/details/78901880

本文转自 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'
<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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值