Android Studio 3.1.1新版本 修改 compileSdkVersion sdk版本的各種錯誤
阿新 • • 發佈:2018-11-10
在新版本3.0以上的Android Studio裡面,有了很多的改動,大家都知道新建立一個專案,compileSdkVersion是最新版本的sdk
我的是Android Studio 3.1.1,最新的是complieSdkVesion 27
新建專案app/build.gradle
apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.test.destiny.myapplication" minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
一般我們都不會用那麼高版本的sdk,不然會有各種的相容問題。那麼我們肯定會想到修改complieSdkVersion版本,我這裡修改為22的:
會發現有一大堆的問題:
首先將build.gradle改正確:注意紅色框
然後根據提示來到Manifest.xml:去掉紅色框框的內容
同樣紅色框的也刪掉:
最後執行就不會有錯了
但是你會發現MainActivity繼承的是AppComPatActivity,如果修改為Activity 的話 AppThem也要改一下
改為:
改為什麼樣式就要看需求了 這裡只是做一個演示
最後 這樣做我總覺得有錯,如果有錯的話 歡迎留言(⊙,,⊙)(⊙,,⊙)(⊙,,⊙)(⊙,,⊙)