1

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?

Sandip Fichadiya
  • 3,430
  • 2
  • 21
  • 47
Christian Bohli
  • 331
  • 1
  • 4
  • 15

5 Answers5

4

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.

Tal Barda
  • 4,067
  • 10
  • 28
  • 53
  • I tried this solution. I found `error: resource style/FirebaseUI (aka ch.workouttracker:style/FirebaseUI) not found.` So I guess something wirh firebase ui is wrong. I use `'com.firebaseui:firebase-ui:1.2.0'` should I use a different versipn? – Christian Bohli Mar 30 '18 at 10:13
  • @ChristianBohli Try changing all of your `Firebase` libraries to `12.0.1`. – Tal Barda Mar 30 '18 at 10:15
  • ` 'com.google.firebase:firebase-corpe:12.0.1' 'com.google.firebase:firebase-messaging:12.0.1' 'com.google.firebase:firebase-auth:12.0.1' 'com.google.firebase:firebase-database:12.0.1' 'com.google.firebase:firebase-storage:12.0.1' 'com.firebaseui:firebase-ui-auth:3.3.2''com.jjoe64:graphview:4.2.1' 'org.apache.commons:commons-lang3:3.4' 'com.google.android.gms:play-services-location:12.0.0' 'com.google.android.gms:play-services-auth:12.0.0' 'com.google.android.gms:play-services-maps:12.0.0'` still the same error – Christian Bohli Mar 30 '18 at 10:43
1

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

Sagar
  • 23,903
  • 4
  • 62
  • 62
  • ***DO NOT USE THIS!*** AAPT has been deprecated, and has been replaced by AAPT2. Doing this puts your problems far down the line instead of handling it now. – Zoe Apr 25 '19 at 14:56
1

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"
}
1

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.

Bogdan M
  • 9
  • 3
0

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

Vector
  • 3,066
  • 5
  • 27
  • 54