任何项目在构建时都会抛出相同的3个错误。
"Android resource linking failed
Output: W/ziparchive( ХХХХ): Zip: didn't find signature at start of lfh, offset=38366251
error: failed to open APK: Invalid offset."
XXXX是四位数字,每次重新构建时都会更改。
我已经尝试更改sdk和gradle版本,并使用“清理项目”和“使缓存无效/重新启动”。我也尝试过重新安装Android Studio,但这没有帮助。
有build.gradle代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ludumus.ziruak.spacescavenger"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion = '28.0.3'
compileOptions {
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-core-utils:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta1'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
由于我的声誉,我无法发布图片,因此文本中出现错误消息。
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
Output: W/ziparchive( 2844): Zip: didn't find signature at start of lfh, offset=38366251
error: failed to open APK: Invalid offset.
Command: C:\Users\User\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\5b940b8f62f283eeef2e51edeab02209\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
C:\Users\User\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
--manifest\
D:\code\Apr\Spacescavenger\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
D:\code\Apr\Spacescavenger\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@D:\code\Apr\Spacescavenger\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
D:\code\Apr\Spacescavenger\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.ludumus.ziruak.spacescavenger\
-0\
apk\
--output-text-symbols\
D:\code\Apr\Spacescavenger\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-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)<119 internal calls>
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)