2016-07-23 69 views
1

我对Udacity一个分配工作后,随着工作的一部分,我不得不复制以下行到我的应用程序的文件的build.gradle:compile "com.android.support:appcompat-v7:22.1.0".这样做后和运行应用程序我发现像无法解决符号R,构建失败,以及与预先设置的值有关的错误。所以,到目前为止,我已经试过卸载Android Studio中,更新了SDK,并确保其他一切都是最新的,但至今还没有找到一个解决方案。请帮忙。 (顺便说一句,我是一个初学者)构建失败的错误,出现异常变化的build.gradle文件

下面是在控制台的gradle错误:

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\Hende\AppData\Local\Android\Sdk\build-tools\23.0.3\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 

的的build.gradle:

Apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.example.hende.justjava" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 

    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.tools.build:gradle:2.1.2' 
} 

及MAINACTIVITY.JAVA:

package com.example.hende.justjava; 


import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 
import android.widget.TextView; 

/** 
* This app displays an order form to order coffee. 
*/ 
public class MainActivity extends AppCompatActivity { 
    int quantity = 2; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
    } 

     /** 
     * This method is called when the plus button is clicked. 
     */ 
    public void increment(View view) { 
     quantity = quantity + 1; 
     displayQuantity(quantity); 



     /** 
     * This method is called when the minus button is clicked. 
     */ 
    }public void decrement(View view) { 
     quantity = quantity - 1; 
     displayQuantity(quantity); 

    } 

    /** 
    * This method is called when the order button is clicked. 
    */ 
    public void submit0rder(View view) { 
     int price = calculatePrice(); 
     String priceMessage = createOrderSummary(price); 
     displayMessage(createOrderSummary(price)); 
    } 
    /** 
    * Calculates the price of the order. 
    * @return total price 
    */ 
    private int calculatePrice() { 
     return quantity = quantity * 5; 

    } 
    /** 
    * Creates summary of order. 
    * @param price of order 
    * @return text summary 
    */ 
    private String createOrderSummary (int price){ 
     String priceMessage = "Name: Awesome + Alison "; 
     priceMessage+= "\nQuantity: " + quantity; 
     priceMessage+= "\nTotal: $" + price; 
     priceMessage+= "\nThank You!"; 
     return priceMessage; 
    } 

    /** 
    * This method displays the given quantity value on the screen. 
    */ 
    private void displayQuantity(int numberOfCoffees) { 
     TextView zeroTextView = (TextView) zeroTextView.findViewById(); 
     zeroTextView.setText("" + numberOfCoffees); 
    } 

    /** 
    * This method displays the given text on the screen. 
    */ 
    private void displayMessage(String message) { 
     TextView orderSummaryTextView = (TextView) findViewById(R.id.order_summary_text_view); 
     orderSummaryTextView.setText(message); 
    } 

} 
+0

你在Android工作室?有两个'build.gradle'文件吗? – Bill

+0

@quidproquo是的,我使用的是Android工作室。 *** build.gradle ***我指的是在app文件夹中,当您向下滚动其第6个选项时。 – Nahidaa

回答

0

试试这个

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.1.0' 
} 

或取得SDK版本24,然后用

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:24.1.0' 
} 
0

你并不需要包括

compile 'com.android.tools.build:gradle:2.1.2' 
在应用的依赖

相关问题