AndroidStudio3.1.X中如何導(dǎo)入項(xiàng)目-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)Android Studio 3.1.X中如何導(dǎo)入項(xiàng)目的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

專注于為中小企業(yè)提供網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)建昌免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

修改app\build:gradle

修改compileSdkVersion和buildToolsVersion

修改前,

compileSdkVersion 23
buildToolsVersion '25.0.0'

修改后:

compileSdkVersion 27
buildToolsVersion '27.0.3'

其中buildToolsVersion 是在Android Studio 3.0之后取消了,你可以保留也可以注釋掉,在defaultConfig方法中將targetSdkVersion 為27并增加一下代碼。

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

修改依賴關(guān)鍵字 compile(implementation/api),provided(compileOnly),apk(runtimeOnly)

修改前:

dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
 compile name: 'SMSSDK-3.0.0', ext: 'aar'
 compile name: 'SMSSDKGUI-3.0.0', ext: 'aar'
 compile 'com.android.support:appcompat-v7:23.4.0'
 compile 'com.android.support:design:23.4.0'
 compile 'com.android.support:recyclerview-v7:23.4.0'
 compile 'de.hdodenhof:circleimageview:2.1.0'
 compile 'com.youth.banner:banner:1.4.9'
 compile 'com.facebook.fresco:fresco:0.13.0'
 compile 'com.squareup.okhttp3:okhttp:3.4.1'
 compile 'com.google.code.gson:gson:2.8.0'
 compile 'com.github.bumptech.glide:glide:3.7.0'
 compile 'com.android.support:support-v4:23.4.0'
 compile 'com.foamtrace:photopicker:1.0'
 compile 'com.github.chrisbanes.photoview:library:1.2.4'
 compile 'com.android.support.constraint:constraint-layout:1.0.2'
 testCompile 'junit:junit:4.12'
 compile project(':ZXingAndroid')
 compile 'com.google.zxing:core:3.3.1'
}

修改后:

dependencies {
 implementation fileTree(include: ['*.jar'], dir: 'libs')
 implementation 'com.android.support:appcompat-v7:27.1.1'
 implementation 'com.android.support.constraint:constraint-layout:1.1.1'
 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'
 implementation name: 'SMSSDK-3.0.0', ext: 'aar'
 implementation name: 'SMSSDKGUI-3.0.0', ext: 'aar'
 implementation 'com.android.support:appcompat-v7:27.1.1'
 implementation 'com.android.support:design:27.1.1'
 implementation 'com.android.support:recyclerview-v7:27.1.1'
 implementation 'de.hdodenhof:circleimageview:2.1.0'
 implementation 'com.youth.banner:banner:1.4.9'
 implementation 'com.facebook.fresco:fresco:0.13.0'
 implementation 'com.squareup.okhttp3:okhttp:3.4.1'
 implementation 'com.google.code.gson:gson:2.8.0'
 implementation 'com.github.bumptech.glide:glide:3.7.0'
 implementation 'com.android.support:support-v4:27.1.1'
 implementation 'com.foamtrace:photopicker:1.0'
 implementation 'com.github.chrisbanes.photoview:library:1.2.4'
 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
 implementation 'com.google.zxing:core:3.3.1'
}

修改項(xiàng)目下的XXX(項(xiàng)目名)\build:gradle

修改前:

<code class="language-html">// 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.3.3' 
 
 // NOTE: Do not place your application odependencies here; they belong 
 // in the individual module build.gradle files 
} 
} 
 
allprojects { 
repositories { 
 jcenter() 
 maven {url "https://jitpack.io" } 
} 
} 
 
task clean(type: Delete) { 
delete rootProject.buildDir 
}</code>

修改后:

// 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.buiwld:gradle:3.1.3'//與AS版本號(hào)保持一致
 
 // NOTE: Do not place your application dependencies here; they belong
 // in the individual module build.gradle files
 }
}
 
allprojects {
 repositories {
 google()
 jcenter()
 maven { url "https://jitpack.io" }
 }
}
 
task clean(type: Delete) {
 delete rootProject.buildDir
}

repositories方法中都增加了google(),build:gradle改和當(dāng)前AS版本號(hào)一致。

修改gradle-wrapper.properties

修改前:

#Tue Aug 29 08:07:34 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

修改后:

#Tue Aug 29 08:07:34 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

主要修改了:distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

這里告一段落,上面都改好之后同步項(xiàng)目(sync)。我為什么建議你把上面的都改好之后再同步,這樣省事兒,剛開(kāi)始的時(shí)候我也是改一點(diǎn)同步一下,問(wèn)題多且很浪費(fèi)時(shí)間,如果其中有些問(wèn)題沒(méi)能解決就容易走偏。

如果報(bào)錯(cuò):

<code class="language-html">Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details 
</code>

修改gradle.properties,增加如下代碼

android.enableAapt2=false

添加android.enableAapt2=false報(bào)如下錯(cuò)誤請(qǐng)移步Android Studio 3.0后出現(xiàn)AAPT2和“android.enableAapt2”問(wèn)題以有解決方法

如果有這個(gè)錯(cuò)誤:這需要更新SDK,點(diǎn)擊藍(lán)色文字下載就好。

Android Studio 3.1.X中如何導(dǎo)入項(xiàng)目

感謝各位的閱讀!關(guān)于“Android Studio 3.1.X中如何導(dǎo)入項(xiàng)目”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

名稱欄目:AndroidStudio3.1.X中如何導(dǎo)入項(xiàng)目-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)路徑:http://bm7419.com/article46/dihghg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、網(wǎng)站改版、服務(wù)器托管網(wǎng)站收錄、網(wǎng)站營(yíng)銷、微信公眾號(hào)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化