Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Dúvida no Ex. 3 da Aula 3 - Utilizandos menus

Olá,

Bem, meu projeto não consegue reconhecer os atributos "elevation" e "stateListAnimator" e por consequência disso o build do projeto falha.

Log do Build do Gradle

Executing tasks: [: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:prepareComAndroidSupportAppcompatV72000Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42000Library 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
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
AGPBI: {"kind":"error","text":"No resource identifier found for attribute \u0027elevation\u0027 in package \u0027android\u0027","sources":[{"file":"/home/lucas/AndroidStudioProjects/Agenda/app/src/main/res/layout/activity_lista_alunos.xml","position":{"startLine":10}}],"original":"","tool":"AAPT"}

AGPBI: {"kind":"error","text":"No resource identifier found for attribute \u0027stateListAnimator\u0027 in package \u0027android\u0027","sources":[{"file":"/home/lucas/AndroidStudioProjects/Agenda/app/src/main/res/layout/activity_lista_alunos.xml","position":{"startLine":10}}],"original":"","tool":"AAPT"}


 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 '/home/lucas/Documentos/adt-bundle-linux-x86_64-20140702/sdk/build-tools/23.0.2/aapt'' 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 mins 11.132 secs

activity_lista_alunos.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        android:id="@+id/lista_alunos"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <Button
        android:id="@+id/novo_aluno"
        android:layout_width="56dp"
        android:layout_height="56dp"
        android:text="+"
        android:textSize="40dp"
        android:textColor="#ffffff"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="16dp"
        android:background="@drawable/fundo"
        android:elevation="6dp"
        android:stateListAnimator="@null"/>

</RelativeLayout>

ListaAlunosActivity.java

package br.com.alura.agenda;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListaAlunosActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lista_alunos);

        String[] alunos = {"Daniel", "Ronaldo", "Jeferson", "Felipe"};

        ListView listaAlunos = (ListView) findViewById(R.id.lista_alunos);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, alunos);

        listaAlunos.setAdapter(adapter);
    }

}
4 respostas

Posta os seus arquivos build.gradle e AndroidManifest.xml, por favor?

Felipe, segue o conteúdo dos arquivos:

build.gradle (Project:Agenda)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (Module:App)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "br.com.alura.agenda"
        minSdkVersion 15
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="br.com.alura.agenda">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".ListaAlunosActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".FormularioActivity"
            android:label="@string/title_activity_formulario">
        </activity>
    </application>

</manifest>
solução!

Esse erro acontece quando tentamos usar alguma funcionalidade que está presente em versões mais recentes àquela que você está usando para compilar o projeto.

No seu build.gradle (Module: App), você diz para usar o Android lvl 20 para compilar e usa a lib de compatibilidade correspondente ('com.android.support:appcompat-v7:20.0.0'). No entanto, as propriedades android:elevation e android:stateListAnimator só existem a partir da versão 21.

Então, altere as entradas compileSdkVersion, targetSdkVersion e a dependência no seu build.gradle (Module: App) para o seguinte:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "br.com.alura.agenda"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

Funcionou Felipe, obrigado.