Me aparece el siguiente error al crear el .apk para producción. Me dice entre otros que "no encuentra el fichero toolbar.xml", pero en éste fichero está todo correcto. Funciona perfectamente en emulador y dispositivo físico.
Information:BUILD FAILED in 30s
Information:See complete output in console
Information:13 errors
Information:0 warnings
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processReleaseResources'.
Failed to execute aapt
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:failed linking file resources.
Error:resource layout/toolbar (aka activate.sgm.com.activate:layout/toolbar) not found.
Error:error: resource layout/toolbar (aka activate.sgm.com.activate:layout/toolbar) not found.
C:\Users\franc\AndroidStudioProjects\activate\app\src\main\res\layout\activity_temperatura.xml
Error:resource layout/header_navview (aka activate.sgm.com.activate:layout/header_navview) not found.
Error:resource layout/toolbar (aka activate.sgm.com.activate:layout/toolbar) not found.
Error:error: resource layout/header_navview (aka activate.sgm.com.activate:layout/header_navview) not found.
Error:error: resource layout/toolbar (aka activate.sgm.com.activate:layout/toolbar) not found.
C:\Users\franc\AndroidStudioProjects\activate\app\src\main\res\layout\activity_main.xml
Error:resource layout/toolbar (aka activate.sgm.com.activate:layout/toolbar) not found.
Error:error: resource layout/toolbar (aka activate.sgm.com.activate:layout/toolbar) not found.
C:\Users\franc\AndroidStudioProjects\activate\app\src\main\res\layout\activity_mail.xml
Information:Gradle tasks [:app:assembleRelease]
He añadido al fichero gradle.properties la siguiente línea:
android.enableAapt2=false
pero da otros errores:
Information:See complete output in console
Information:0 warnings
Information:12 errors
Information:BUILD FAILED in 11s
Error:Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt
Error:org.gradle.process.internal.ExecException: Process 'command 'C:\Users\franc\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe'' finished with non-zero exit value 1
Error:com.android.ide.common.process.ProcessException: Error while executing process C:\Users\franc\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I C:\Users\franc\AppData\Local\Android\Sdk\platforms\android-26\android.jar -M \\?\C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\manifests\full\release\AndroidManifest.xml -S C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\merged\release -m -J \\?\C:\Users\franc\AndroidStudioProjects\activate\app\build\generated\source\r\release -F C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\release\resources-release.ap_ --custom-package activate.sgm.com.activate-0 apk --output-text-symbols \\?\C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\symbols\release --no-version-vectors}
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing process C:\Users\franc\AppData\Local\Android\Sdk\build-tools\26.0.2\aapt.exe with arguments {package -f --no-crunch -I C:\Users\franc\AppData\Local\Android\Sdk\platforms\android-26\android.jar -M \\?\C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\manifests\full\release\AndroidManifest.xml -S C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\merged\release -m -J \\?\C:\Users\franc\AndroidStudioProjects\activate\app\build\generated\source\r\release -F C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\release\resources-release.ap_ --custom-package activate.sgm.com.activate-0 apk --output-text-symbols \\?\C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\symbols\release --no-version-vectors}
Error:(11, 22) No resource found that matches the given name (at 'layout' with value '@layout/toolbar').
Error:(25, 22) No resource found that matches the given name (at 'layout' with value '@layout/toolbar').
Error:(13, 22) No resource found that matches the given name (at 'layout' with value '@layout/toolbar').
C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\merged\release\layout\activity_temperatura.xml
Error:(417, 27) No resource found that matches the given name (at 'headerLayout' with value '@layout/header_navview').
C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\merged\release\layout\activity_main.xml
C:\Users\franc\AndroidStudioProjects\activate\app\build\intermediates\res\merged\release\layout\activity_mail.xml
Error:(417, 27) No resource found that matches the given name (at 'headerLayout' with value '@layout/header_navview').
Error:(11, 22) No resource found that matches the given name (at 'layout' with value '@layout/toolbar').
C:\Users\franc\AndroidStudioProjects\activate\app\src\main\res\layout\activity_temperatura.xml
Error:(25, 22) No resource found that matches the given name (at 'layout' with value '@layout/toolbar').
C:\Users\franc\AndroidStudioProjects\activate\app\src\main\res\layout\activity_main.xml
Error:(13, 22) No resource found that matches the given name (at 'layout' with value '@layout/toolbar').
C:\Users\franc\AndroidStudioProjects\activate\app\src\main\res\layout\activity_mail.xml
Information:Gradle tasks [:app:assembleRelease]