顯示廣告
隱藏 ✕
看板 KnucklesNote
作者 Knuckles (站長 那克斯)
標題 [AndroidStudio] 更新IDE後遇到的問題
時間 2016-07-26 Tue. 12:40:15


好久沒動 Android 程式,Android Studio 2 已經變正式版了
記錄一下升級後程式要改動的地方

從1.5更新為2.1版

‧模擬器 AVD 要全部刪掉重新新增

‧修改 build.gradle (Module: app)
apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.disp_tech.dispbbs"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 6
        versionName "0.5"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "3g"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.facebook.fresco:fresco:0.8.1'
    compile 'com.google.android.gms:play-services-analytics:9.2.1'
    compile 'com.google.android.gms:play-services-appindexing:9.2.1'
}

apply plugin: 'com.google.gms.google-services'

compileSdkVersion 從23改為24
buildToolsVersion 從23.0.1改為23.0.2
targetSdkVersion  從23改為24

加上
    dexOptions {
        javaMaxHeapSize "3g"
    }

appcompat版本改為 v7:24.1.1


‧修改 gradle.properties

在Gradle Console會有提示要在這加上
org.gradle.jvmargs=-Xmx3072M
可提升gradle build的速度



更新到 Android Studio 2.3.3 後

在 build.gradle (app) 的這行會被畫紅線:
    compile 'com.android.support:appcompat-v7:25.3.1'
[圖]

提示訊息為「All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 23.1.1. Examples include com.android.support:animated-vector-drawable:25.3.1 and com.android.support:recyclerview-v7:23.1.1」

代表其他的函式庫有用到 'com.android.support:recyclerview-v7:23.1.1'
可能會和 25.3.1 起衝突

解決方法參考 StackOverflow 加上這行:
    compile 'com.android.support:recyclerview-v7:25.3.1'
將提示訊息裡提到的舊版函式庫加上新版就可以了



--
※ 作者: Knuckles 時間: 2016-07-26 12:40:15
※ 編輯: Knuckles 時間: 2017-06-29 03:10:34
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 393 
分享網址: 複製 已複製
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇