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
原文章連結
後面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.
相關文章
- Android Studio 3.0 Canary 釋出Android
- Android Studio 2.0 功能介紹Android
- 當 jenkins遇上Android Studio 3.0JenkinsAndroid
- Android Studio 3.0新功能介紹Android
- Android Studio 3.0 上 Gradle 改動AndroidGradle
- Android Studio 3.0更新:Kotlin正式可用AndroidKotlin
- Android Studio 3.0 svg圖片問題AndroidSVG
- Android Studio 3.0 利用 Android Profiler 測量應用效能Android
- Android Studio 2.0 正式版釋出Android
- Android Studio3.0 NDK配置與開發Android
- android studio 3.0 gradle 打包指令碼配置AndroidGradle指令碼
- Android Studio 3.0 的一些小變化Android
- Android Studio 3.0 Android 分析器 | 中文教學視訊Android
- (Android Studio 3.0)Android Profiler記憶體洩漏檢查Android記憶體
- Android StudioAndroid
- Android Studio教程從入門到精通2.0Android
- android studio安裝教程|android studio漢化包Android
- 官方詳細介紹Android Studio 3.0 Canary 1Android
- Android studio更新到3.0後問題解決Android
- Android Studio3.0更新之路(遇坑必入)Android
- Android Studio工具Android
- Android Studio 初探Android
- Android studio jniAndroid
- Android Studio配置Android
- Android Studio 升級到3.0 提示 java.lang.NoClassDefFoundErrorAndroidJavaError
- Android Studio 2.0:速度提升,極大提高開發效率Android
- Android studio3.0 的幾種依賴方式筆記Android筆記
- 安裝android studioAndroid
- Android Studio使用ProtocolBuffersAndroidProtocol
- android studio 快捷鍵Android
- Android Studio外掛Android
- Android Studio - 基本配置Android
- android studio 外掛Android
- Android Studio復位Android
- Android Studio最全解析Android
- Android Studio安裝Android
- 【Android Studio】Android Studio 搭建開發環境(Linux Ubuntu篇)Android開發環境LinuxUbuntu
- Android Studio 3.0 新功能解析和舊專案適配Android