一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Android - Android Studio 3.1.X中導入項目的正確方法分享

Android Studio 3.1.X中導入項目的正確方法分享

2022-03-09 15:34小紅妹 Android

這篇文章主要給大家介紹了關于Android Studio 3.1.X中導入項目的正確方法,文中一步步將解決的方法以及可能遇到的問題介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

前言

最近在使用Android Studio 3.1.2導入以前的項目遇到一些坑,借此機會把相關處理方法分享出來。

下面以導入Android Studio2.3.3項目為例:

在此之前先建議你用Android Studio 3.1.2創建一個新的項目,看看有哪些變化,這對你很有幫助。

修改app\build:gradle

修改compileSdkVersion和buildToolsVersion

修改前,

?
1
2
compileSdkVersion 23
buildToolsVersion '25.0.0'

修改后:

?
1
2
compileSdkVersion 27
buildToolsVersion '27.0.3'

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

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

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

修改前:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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'
}

修改后:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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'
}

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

修改前:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<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>

修改后:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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版本號保持一致
 
 // 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改和當前AS版本號一致。

修改gradle-wrapper.properties

修改前:

?
1
2
3
4
5
6
#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

修改后:

?
1
2
3
4
5
6
#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

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

如果報錯:

?
1
2
<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,增加如下代碼

?
1
android.enableAapt2=false

添加android.enableAapt2=false報如下錯誤請移步Android Studio 3.0后出現AAPT2和“android.enableAapt2”問題以有解決方法

如果有這個錯誤:這需要更新SDK,點擊藍色文字下載就好。

Android Studio 3.1.X中導入項目的正確方法分享

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對服務器之家的支持。

原文鏈接:https://blog.csdn.net/L_201607/article/details/80662415

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 天天乐影院 | 韩国免费视频 | 青草热久精品视频在线观看 | 欧美成人精品福利在线视频 | 日本一卡2卡3卡4卡乱 | 亚洲麻豆精品 | 欧美日韩一区二区综合在线视频 | sese在线 | 亚洲剧情在线观看 | 日本无遮挡亲吻膜下面免费 | 大乳孕妇一级毛片 | 精品乱lun小说 | 久草在线福利视频在线播放 | 久久视频精品3线视频在线观看 | 国内会所按摩推拿国产 | 亚洲国产精品二区久久 | 日韩欧美国产在线 | 99rv精品视频在线播放 | 男人视频网站 | 成人免费观看www视频 | 55夜色66夜亚州精品站 | 午夜在线观看免费观看 视频 | 欧美人体高清在线观看ggogo | 日本性生活免费看 | 国产精品原创永久在线观看 | 国产精品视频一区二区三区 | 69日本xxⅹxxxxx19 | 国产乱码一卡二卡3卡四卡 国产乱插 | 504神宫寺奈绪大战黑人 | 亚洲高清一区二区三区四区 | 亚洲国产天堂久久精品网 | 欧美精品一区二区三区免费 | 日韩在线天堂免费观看 | 男男按摩1069gⅴ | 精品亚洲视频在线观看 | 欧美色在线 | 欧美大片一区二区三区 | 亚洲同性男男gay1069 | 免费超级乱淫播放手机版 | 99精品视频在线观看 | 免费亚洲视频 |