Error creating the .apk file

0

I get the following error when creating the .apk for production. He tells me among others that "can not find the file toolbar.xml", but in this file it is all correct. It works perfectly in emulator and physical device.

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]

I have added the following line to the file gradle.properties:

android.enableAapt2=false

but gives other errors:

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.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.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.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]
    
asked by Las Perseidas 20.03.2018 в 16:01
source

2 answers

1

The problem is in the resources,

can not find files, for example in the layout: activity_temperatura.xml and in activity_mail.xml exist but inside try to get other references that do not exist.

These resources do not exist:

layout/header_navview
layout/toolbar

Ensure that you add these elements.

In fact, when you sign the .apk, a thorough review of the elements and their references is done, in debug you do not do that revision.

    
answered by 20.03.2018 в 17:40
0

PROBLEM SOLVED. The problem was indeed that it did not recognize the mentioned files, the reason was that in Project view the mentioned files were inside the debug folder. I only changed them to the Main folder and everything is ready. Thanks for trying to help me. I put it in case it serves someone.

    
answered by 22.03.2018 в 00:58