Christian Bohli
Christian Bohli

Reputation: 341

AAPT2 error: check logs for details after Android Studio upgrade

I've upgraded my Android Studio, since this I get an error "AAPT2 error: check logs for details"

In the internet I didn't find a solution.

My androidmanifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ch.workouttracker"
    android:versionCode="1"
    android:versionName="1.0" >

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".TrackActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ProfileActivity"
            android:label="@string/title_activity_profile" >

        </activity>
        <activity
            android:name=".TrackCardioActivity"
            android:label="@string/title_activity_track_cardio">

        </activity>
        <activity
            android:name=".TrackWorkoutActivity"
            android:label="@string/title_activity_track_workout" >

        </activity>
        <activity
            android:name=".LogoutActivity"
            android:label="@string/title_activity_logout">

        </activity>
        <activity
            android:name=".SettingsActivity"
            android:label="@string/title_activity_settings" >

        </activity>
        <activity
            android:name=".DashbordActivity"
            android:label="@string/title_activity_dashboard" >

        </activity>
        <activity
            android:name=".CreatePlanActivity"
            android:label="@string/title_activity_create_plan" >

        </activity>
        <activity
            android:name=".CreateExerciseActivity"
            android:label="@string/title_activity_create_exercise" >

        </activity>
        <activity
            android:name=".EditActivity"
            android:label="@string/title_activity_edit" >

        </activity>
        <activity
            android:name=".LoginActivity"
            android:label="@string/title_activity_login" >

        </activity>
        <activity
            android:name=".WorkoutDetailActivity"
            android:label="@string/title_activity_workout_detail" >

        </activity>
        <activity
            android:name=".PlanDetailActivity"
            android:label="@string/title_activity_plan_detail" >

        </activity>
        <activity android:name=".CalendarActivity" >

        </activity>
        <activity android:name=".EditExerciseActivity">

        </activity>
    </application>
</manifest>

I tried a reinstall and downgrad of the android sdk. I deleted .gradle. I set the property android.enableAapt2=false in gradle.properties

What else can I try? What other information do you need?

Upvotes: 1

Views: 13743

Answers (5)

Vector
Vector

Reputation: 3235

Many ways to create this problem! Here is one that we created and had no idea why it happened. By accident we pasted our favorite color.xml file int the styles.xml folder. We had no warning when we did the paste and not while continuing to design the app. BUT when we closed the app and it needed to rebuild when loaded the fun began. We guess the solution might be to build before you close the app or review all your XML files before you build or close better yet LOOK WHERE YOU ARE PASTING

Upvotes: 0

Bogdan M
Bogdan M

Reputation: 9

I also solved the issue as per Paila Khagesh suggestion. I had

compileSdkVersion 26 

and

targetSdkVersion 25

After changing targetSdkVersion to 26 and sync gradle error was gone.

Upvotes: 1

Paila Khagesh
Paila Khagesh

Reputation: 11

I also got same problem.By changing build.gradle file like as follows i resolved that. android { compileSdkVersion 27 buildToolsVersion '27.0.3'

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
}

Upvotes: 1

Sagar
Sagar

Reputation: 24907

Based on Google's documentation:

If you are experiencing issues while using AAPT2, you can disable it by setting android.enableAapt2=false in your gradle.properties file and restarting the Gradle daemon by running ./gradlew --stop from the command line.

When you set the android.enableAapt2=false you have to restart the Gradle daemon. You should restart the Daemon and then Click on Sync Project with gradle file

Also ensure that you are using latest buildToolsVersion

Upvotes: 1

Tal Barda
Tal Barda

Reputation: 4277

I ran into this problem a while ago, after updating my Android Studio to the latest version. After searching for a long time, this answer was my savior.

As this answer suggests, the problem might be messed up XML files in your project. You can look for the messed up part by yourself, or run the assembleDebug command in your terminal (like this), which can find the exact line that should be fixed.

Upvotes: 4

Related Questions