溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Android Studio3.0.1有哪些需要注意的地方

發(fā)布時(shí)間:2021-09-10 13:37:18 來源:億速云 閱讀:115 作者:小新 欄目:移動開發(fā)

這篇文章主要介紹Android Studio3.0.1有哪些需要注意的地方,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

(一)關(guān)于注解

Error:Execution failed for task ':Framework:javaPreCompileDebug'.

Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.

- butterknife-7.0.1.jar (butterknife-7.0.1.jar)

Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.

See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

Android Studio官網(wǎng)的說明如下:

Use the annotation processor dependency configuration

一開始我是先找到了解決方法,后面才看到上面的鏈接。先說一下解決方法。在build.gradle 的defaultConfig 中添加下列內(nèi)容:

apply plugin: 'com.android.application'
android {
 ...
 defaultConfig {
 ...
 //大兄弟,這邊~
 javaCompileOptions {
  annotationProcessorOptions {
  includeCompileClasspath true
  }
 }
 }
}

(二)關(guān)于渠道

Error:All flavors must now belong to a named flavor dimension.Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

所有的flavors都必須屬于同一個(gè)風(fēng)格。官網(wǎng)中文解釋:組合多個(gè)產(chǎn)品風(fēng)味

解決方法就是在build.gradle中添加相應(yīng)的標(biāo)志的內(nèi)容。

flavorDimensions("vas", "normal") //介個(gè)
 productFlavors {
 vas {
  dimension 'vas'
  buildConfigField "boolean", "ENABL_VAS", "true"
  dimension "vas" //介個(gè)
 }
 normal {
  dimension 'normal'
  buildConfigField "boolean", "ENABL_VAS", "false"
  dimension "normal" //還有介個(gè)
 }
 }

(三)關(guān)于Sugar

3.0Android: Sugar ORM No Such Table Exception

項(xiàng)目中用到Sugar,在3.0AS中老是提示找不到表。其實(shí)解決方法很簡單,而且瀏覽的網(wǎng)站也老早就說了該如何處理,但因?yàn)槲衣┑袅岁P(guān)鍵的點(diǎn),所以老是沒成功。

Android Studio3.0.1有哪些需要注意的地方 

instant run莫勾選

最后!卸載設(shè)備上的舊應(yīng)用,一定要卸載!然后重新運(yùn)行新的應(yīng)用就OK了。

(四)關(guān)于Manifest merger

Execution failed for task ':AppMain:processVasNormalDebugManifest'.  Manifest merger failed with multiple errors, see logs

這是我第一次知道原來Manifest還有merge沖突的情況出現(xiàn)。有趣有趣。

Android Studio3.0.1有哪些需要注意的地方 

項(xiàng)目目錄

我的項(xiàng)目中有一個(gè)application和一個(gè)library,這兩個(gè)module都有自己的manifest。原來as最后會幫我們將兩個(gè)manifest合并起來,所以當(dāng)二者設(shè)置的內(nèi)容不一致,就會起沖突,merge失敗。原理就是這樣了。對比一下兩個(gè)manifest中有什么值是大不同的,修改一下就好了。那要怎么看合并的結(jié)果是怎么樣的呢?

比如我打開AppMain的manifest,選擇下面的Merged Manifest 模式,就可以看到最終合并結(jié)果了。

Android Studio3.0.1有哪些需要注意的地方 

AppMain的manifest

我記得自己的情況是:AppMain的manifest我設(shè)置android:allowBackup="false",然后FramewFramework的manifest為android:allowBackup="true",然后改成都為false就好了。大家要看自己的實(shí)際情況是什么,再做相應(yīng)的修改。

以上是“Android Studio3.0.1有哪些需要注意的地方”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI