[英]Android Studio: Gradle Build Problems/“R can't be resolved”
我剛剛在android studio調試中開始了一個小項目,一切都很好,但是大約一個小時前,我遇到一個錯誤,即“ R”無法解析,因此我無法再引用我的布局了。 我在網上和Stackoverflow上尋求幫助,但似乎沒有解決方案適合我。 我嘗試清理我的項目,但隨后在構建gradle時出現此錯誤:
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Admin\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1
有人知道解決方案嗎? 這以前從未發生過,並且不需要將我鏈接到現有線程,因為在這里我已經閱讀了與該主題相關的所有線程,而且沒有人能夠幫助我。 提前致謝
構建gradle控制台:執行任務:[:app:assembleDebug]
Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Admin\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.51 secs
無法解決R在Android Studio中發生了某些原因:
解決方案:
我的問題2如下:我的styles.xml文件是:
<style name="MyCustomToolbar" parent="ThemeOverlay.AppCompat.Light">
<item name="colorPrimary">#5974AB</item>
</style>
在xml文件中,我已經寫過
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
....
android:popupTheme="@style/MyCustomToolber"
>
</android.support.v7.widget.Toolbar>
在xml中查看
android:popupTheme="@style/MyCustomToolber"
我輸入了錯誤的樣式名稱,所以我發現錯誤R無法解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.