2016-07-23 10 views
1

Ich arbeite an einer Aufgabe für Udacity, und als Teil der Arbeit musste ich die Zeile unten in die Build.gradle-Datei meiner App kopieren: compile "com.android.support:appcompat-v7:22.1.0". Danach und Beim Ausführen der App sind mir Fehler aufgefallen, die das Symbol R nicht auflösen können, Fehler beim Erstellen und Probleme mit Werten, die zuvor festgelegt wurden. So weit, habe ich versucht, Android Studio zu deinstallieren, die SDK zu aktualisieren, sicherzustellen, dass alles andere auf dem neuesten Stand war, aber immer noch keine Lösung gefunden. Bitte helfen Sie. (btw, ich bin ein Anfänger)Build Fehler Fehler mit Ausnahme nach dem Ändern Build.gradle-Datei

Hier ist der Fehler in der gradle Konsole:

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 

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

UND DIE 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

sind Sie auf Android Studio? Gibt es zwei 'build.gradle' Dateien? – Bill

+0

@quidproquo Ja, ich benutze Android Studio. Die *** build.gradle *** Ich beziehe mich auf im App-Ordner, wenn Sie die 6. Option nach unten scrollen. – Nahidaa

Antwort

0

Versuchen Sie diese

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

Oder die SDK-Version 24 erhalten und verwenden dann

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

Sie brauchen nicht

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

in Ihrer App Abhängigkeiten enthalten.