0

Device Info:

windows 10 Android Studio 3.2 or 3.1

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip  
classpath 'com.android.tools.build:gradle:3.2.0'

Question: When I create a new Android Project,rebuilding cause this error. I cannot find the solution in google or stackoverflow. The error Log is "Aapt2Exception: Android resource linking failed Output: error: failed to open APK: Invalid file." I don't know which APK a building need "open",and cannot find the key point.

I think maybe something wrong with my pc. Can Anyone help?

log:

com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
**Output:  error: failed to open APK: Invalid file.**

Command: C:\Users\RABBIT\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\1f6bc70d6f61581570fe3ce3ff0cfffc\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
        D:\RA\PROGRAM\AndroidSDK\platforms\android-28\android.jar\
        --manifest\
        D:\RA\CODE\RA_CODE\Aapt2Test\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        D:\RA\CODE\RA_CODE\Aapt2Test\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @D:\RA\CODE\RA_CODE\Aapt2Test\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        D:\RA\CODE\RA_CODE\Aapt2Test\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --custom-package\
        com.aapt.rabbit.aapttest\
        -0\
        apk\
        --output-text-symbols\
        D:\RA\CODE\RA_CODE\Aapt2Test\app\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
    at com.android.builder.internal.aapt.v2.Aapt2DaemonImpl.doLink(Aapt2DaemonImpl.kt:177)
    at com.android.builder.internal.aapt.v2.Aapt2Daemon.link(Aapt2Daemon.kt:103)
    at com.android.builder.internal.aapt.v2.Aapt2DaemonManager$LeasedAaptDaemon.link(Aapt2DaemonManager.kt:176)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:823)
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:525)
    at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:275)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

3 Answers 3

2

problem solved

It is because my company's PC has a Encrypting Softwarehttp://www.wowostar.com,it encrypt all files which were created when building.

Need find the process name when building, and add to the Encrypting Software's whitelist.

find the process name

Sign up to request clarification or add additional context in comments.

Comments

0

for my case i deleted the ids.xml file (it was useless in the project)

Comments

0

For my case, add aapt.exe/aapt2.exe to the Encrypting Software whitelist

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.