●方法一
跳出更新推薦的時候,點更新,會全部自動設定好
●方法二:如果沒有自動跳出更新,build的時候會出現很多錯誤訊息,照說明一個一個更改即可
1.build.gradle(project)=>tools.build 3.0.1改為3.4.0
2.gradle-wrapper.properties=>gradle-4.1-all.zip改為gradle-5.1.1-all.zip
3. 可能會出現警告訊息如下:
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018.
WARNING: Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'.
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018.
做法:build.gradle(app)=>compile 改為 implementation、testCompile改為testImplementation、androidTestCompile改為androidTestImplementation (Warning Only)
4. 可能會出現警告訊息如下:
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
做法:build.gradle(app)=>buidlToolsVersion 26.0.2改為28.0.3(android studio minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0. )
5.如果出現如下列訊息:
ERROR: Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
Required by:
project :
Add Google Maven repository and sync project
Open File
ERROR: Failed to resolve: com.android.support:appcompat-v7:26.+
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
ERROR: Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
Install artifact and sync project
Show in Project Structure dialog
Affected Modules: app
ERROR: Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Add Google Maven repository and sync project
Show in Project Structure dialog
Affected Modules: app
=>點"Add Google Maven repository and sync project",出現如下畫面,點擊"Do refactor"即可
*使用openCV遇到的錯誤訊息
ERROR: The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
WARNING: The targetSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
作法:在openCVLibrary343的AndroidManifest.xml,移除minSdk和targetSdk設定
另外:openCVLibrary343Library的build.gradle(app)的buidlToolsVersion也要改為28.0.3(改法同方法2)
*使用firebase Message 會crash
Default FirebaseApp is not initialized in this process com.maggie.faceaimessage. Make sure to call FirebaseApp.initializeApp(Context) first.
做法:build.gradle(project)將classpath改為 'com.google.gms:google-services:4.2.0'
Android Studio 各版本下載:https://developer.android.com/studio/archive