繁体   English   中英

更改Build.gradle文件后,生成失败,出现异常错误

[英]Build Fail error with exception after changing Build.gradle file

我正在为Udacity进行分配,作为工作的一部分,我必须将以下行复制到应用程序的build.gradle文件中: compile "com.android.support:appcompat-v7:22.1.0". 完成此操作并运行该应用程序后,我注意到诸如无法解析符号R,构建失败以及预设值问题之类的错误。 因此,到目前为止,我已经尝试卸载Android Studio,更新sdk,确保其他所有内容都是最新的,但仍未找到解决方案。 请帮忙。 (顺便说一句,我是初学者)

这是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

建档:

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);
    }

}

尝试这个

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'
}

您不需要包括

compile 'com.android.tools.build:gradle:2.1.2'

在应用程序的依赖项中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM