[Android Studio]在使用時,遇到的問題,持續更新

 

前言

        儘管AS已經使用了很久,但其中會遇到的問題並沒有較爲合理、整齊規範的整理過,今天這篇文章就用來整理這些內容,並且後面會持續更新。希望記錄下問題,也能幫助小夥伴們。吐舌頭

 

正文

 

************************************************************* 分 割 線 ****************************************************************

Warning:Conflict with dependency ‘com.android.support:multidex’ in 
project ‘:app’. Resolved versions for app (1.0.2) and test app (1.0.1) 
differ. See http://g.co/androidstudio/app-test-app-conflict for 
details.Error Execution failed for 
taskapp:prepareDebugAndroidTestDependencies Dependency Error. See 
console for details.

解決:

        在裏一個項目中將build.gradle文件中依賴的包,都根據AS提示將版本改成最新的之後, 沒有將project的build.gradle中的gradle版本安裝提示換成新的,構建是報了此錯誤, 將gradle版本修改後問題解決.

************************************************************* 分 割 線 ****************************************************************

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
 > Conflict with dependency 'com.android.support:support-annotations' in project ':app'. 
Resolved versions for app (25.4.0) and test app (27.1.1) differ. 

解決:

        在dependencies中添加如下代碼,強制去掉提示的依賴內容

dependencies{
......
androidTestCompile('com.android.support:support-annotations:25.4.0') {
    force = true
  }
......
}

************************************************************* 分 割 線 ****************************************************************

Error:Execution failed for task ':app: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-5.1.1.jar (com.jakewharton:butterknife:5.1.1)
  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中添加如下配置

android{
defaultConfig{
    javaCompileOptions {
      annotationProcessorOptions {
        includeCompileClasspath = true
      }
    }
  }
}

 ************************************************************* 分 割 線 ****************************************************************

Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.4/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------

解決辦法:

將gradle.properties文件中的jvm設置設置的值小一些。如512、1024

org.gradle.jvmargs=-Xmx512m

後來有一次,設置了這些小的值都沒用。然後各種Clean,Rebuild Project,Restart Android Studio都無效,可能跟電腦的配置也是有關係的,給jvm的內存太小不夠用。實在沒辦法解決的情況下可以卸載並重裝Android Studio可以解決。但這是最終沒辦法的辦法。一般設置一下小些的值就能夠解決。

 

持續更新ing...

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章