【发布时间】:2016-11-27 12:16:58
【问题描述】:
我正在为 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
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);
}
}
【问题讨论】:
-
您在使用 Android Studio 吗?有两个
build.gradle文件吗? -
@quidproquo 是的,我正在使用 Android Studio。我指的build.gradle在app文件夹中,当你向下滚动它的第6个选项时。
标签: java android android-studio build.gradle