親身經歷的報錯集錦。
在Android開發中會遇到各種奇奇怪怪的報錯。很多報錯利用搜索引擎能夠解決,但是還有一部分是要靠自己摸索才能克服的,於是把這部分報錯記錄在這篇博客裏面,做一個參考。有很多報錯原因是有多種的,具體情況需要具體分析,這裏只是提供一種解決方案或思路。
文章目錄
- 1. Error:Could not find com.android.tools.build:gradle:4.1
- 2. Error:The SDK directory 'C:\Users\Darko\AppData\Local\Android\sdk' does not exist.
- 3. Android Studio: cannot resolve symbol R
- 4. No resource found that matches the given name “xxx”
- 5. No resource found that matches the given name 'Theme.AppCompat.Light"
- 6. This element has no attached source and the Javadoc could not be found in the attached Javadoc.
- 7. You need to use a Theme.AppCompat theme (or descendant) with this activity
- 8. Failed to transform file 'android.jar' to match attributes.
1. Error:Could not find com.android.tools.build:gradle:4.1
見:https://blog.csdn.net/zengsidou/article/details/79797417
2. Error:The SDK directory ‘C:\Users\Darko\AppData\Local\Android\sdk’ does not exist.
見:https://blog.csdn.net/zengsidou/article/details/56845869
3. Android Studio: cannot resolve symbol R
見:https://blog.csdn.net/zengsidou/article/details/56016931
4. No resource found that matches the given name “xxx”
見:https://blog.csdn.net/zengsidou/article/details/45933215
5. No resource found that matches the given name 'Theme.AppCompat.Light"
見:https://blog.csdn.net/zengsidou/article/details/45783925
6. This element has no attached source and the Javadoc could not be found in the attached Javadoc.
見:https://blog.csdn.net/zengsidou/article/details/45772837
7. You need to use a Theme.AppCompat theme (or descendant) with this activity
見:https://blog.csdn.net/zengsidou/article/details/45731385
8. Failed to transform file ‘android.jar’ to match attributes.
報錯提示:
Failed to transform file ‘android.jar’ to match attributes.
原因:Android SDK中的android.jar有錯誤。因爲之前替換過android.sdk,導致其不是原版的jar。
解決方案:替換爲正確的android.jar,使用SDK Manager或者從官網下載。