5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Android Studioの移行2.3.3 → 3.1.4

Posted at

はじめに

久しぶりにAndroid Studioを起動したらバージョンが上がってたので、移行。
あとついでに日本語化も。
環境:macOS Sierra (10.12.6)

Android Studioのアップデート

AndroidStudio > Check for Update > Update and Restart
ASVUP_01.png

Complete InstallationではImport Studio setting from: Previous versionを選択して、設定情報を引き継ぎ。
ASVUP_02.png

無事アップデート完了。
ASVUP_03.png

日本語化

Pleiadesを使う。Eclipseだけかと思ったけど、Jetbrains製IDEならなんでもいけるみたい。以下サイトを参考にしました。
Android Studio3.1を日本語化する
「ファイルの階層移動」は不要でした。macだから?
ASVUP_04.png

 Gradleラッパーの設定

ローカルのGradleを使う設定から、Gradleラッパーを使うように設定変更。
ASVUP_05.png

Gradleラッパーのアップデート

ここを見ると、最新版は4.10みたいなので、gradle-wrapper.propertiesを修正。

gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

プロジェクトの同期を実行すると、自動的にGradleのダウンロードが始まる。
完了後、バージョン確認。

% ./gradlew --version                                             (git)-[master]

Welcome to Gradle 4.10!

Here are the highlights of this release:
 - Incremental Java compilation by default
 - Periodic Gradle caches cleanup
 - Gradle Kotlin DSL 1.0-RC3
 - Nested included builds
 - SNAPSHOT plugin versions in the `plugins {}` block

For more details see https://docs.gradle.org/4.10/release-notes.html


------------------------------------------------------------
Gradle 4.10
------------------------------------------------------------

Build time:   2018-08-27 18:35:06 UTC
Revision:     ee3751ed9f2034effc1f0072c2b2ee74b5dce67d

Kotlin DSL:   1.0-rc-3
Kotlin:       1.2.60
Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_131 (Oracle Corporation 25.131-b11)
OS:           Mac OS X 10.12.6 x86_64

Android Gradle Pluginのアップデート

build.gradleを修正する。
jcenterだと取得できないプラグインがあるみたいなので、googleリポジトリの追加もやる。
3.0.0-alpha以降のAndroidプラグインはGoogleのmavenリポジトリで取得する必要がある

build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google() // 追加
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4' // 3.1.4に変更

        // 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
}

SDKツールのアップデート

ツール > SDKマネージャー > 外観 & 振る舞い > システム設定 > Android SDK > SDKツールタブで以下を選択してアップデート。

  • Android SDK Build-Tools
  • Android SDK Platform-Tools
  • Android SDK Tools
  • Intel x86 EmulatorAccelerator (任意)
  • Android Support Repository
  • Google Repository
ASVUP_06.png

自分で日本語化しておいてあれだけど、「外観 & 振る舞い」ってダサいな・・・

エラー対応

オンデマンド設定をオフに

Gradle4.6以降はオンデマンド設定に対応していない。

Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.

検索したらstackoverflowに解決策があった。
Configuration on demand is not supported by the current version of the Android Gradle plugin
Android Studio > 環境設定 > ビルド、実行、デプロイ > コンパイラーから「オンデマンドで設定」のチェックを外す。
ASVUP_07.png

Dependencyの設定

Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation' and 'androidTestApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

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

Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

言われるがままに、build.gradleを修正

build.gradle
// before
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
}
build.gradle
// after
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:25.1.0'
    testImplementation 'junit:junit:4.12'
}

参考

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?