Android开发之——开发中的错误及解决办法

348 阅读2分钟

2.2 Unable to find EOCD signature

现象1

Execution failed for task ':app:packagexxxxRelease'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

Unable to find EOCD signature

现象2

Execution failed for task ':app:packageGame_ZHRelease'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

java.lang.IllegalArgumentException (no error message)

原因

依赖中添加了有关ABI相关的配置,打包输出时,未指定ABI版本

解决办法(添加ABI输出)

import com.android.build.OutputFile

static def releaseTime() {

return new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+8"))

}

buildTypes {

release {

minifyEnabled true

shrinkResources true

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

applicationVariants.all { variant ->

variant.outputs.all { output ->

project.ext { appName = 'YourApkName' }

outputFileName = "appName{appName}-{output.getFilter(OutputFile.ABI)}-variant.name{variant.name}-{variant.versionName}.apk"

}

}

}

}

2.3 failed to read PNG signature: file does not start with PNG signature

现象

AAPT: error: failed to read PNG signature: file does not start with PNG signature.

解决办法

在app/build.gradle文件中加以下代码后,重构项目

android {

compileSdkVersion 28

flavorDimensions "mode"

aaptOptions.cruncherEnabled = false

aaptOptions.useNewCruncher = false

defaultConfig {

}

2.4 Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

现象(项目创建时)

An exception occurred applying plugin request [id: 'com.android.application']

Failed to apply plugin 'com.android.internal.application'.

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.

You can try some of the following options:

  • changing the IDE settings.

  • changing the JAVA_HOME environment variable.

  • changing org.gradle.java.home in gradle.properties.

解决办法

依次点击:File——>Project Struct——>SDK Location——>JDK location was moved to Gradle Settings,在打开的对话框中,将Gradle JDK修改为11

三 警告类


3.1 The ‘kotlin-android-extensions’ Gradle plugin is deprecated

现象

The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (goo.gle/kotlin-andr…) to start working with View Binding (developer.android.com/topic/libra…) and the 'kotlin-parcelize' plugin.

解决办法

删除 apply plugin: 'kotlin-android-extensions'

使用binding赋值

binding.name.text = viewModel.nameString

3.2 Warning: Mapping new ns xx/common/02 to old ns xx/common/01

现象

Warning: Mapping new ns schemas.android.com/repository/… to old ns schemas.android.com/repository/…

Warning: Mapping new ns schemas.android.com/repository/… to old ns schemas.android.com/repository/…

Warning: Mapping new ns schemas.android.com/sdk/android… to old ns schemas.android.com/sdk/android…

Warning: Mapping new ns schemas.android.com/sdk/android… to old ns schemas.android.com/sdk/android…

Warning: Mapping new ns schemas.android.com/sdk/android… to old ns schemas.android.com/sdk/android…

解决办法(buildToolsVersion引起-修改前)

compileSdkVersion 30

buildToolsVersion "30.0.3"

最后

针对Android程序员,我这边给大家整理了一些资料,包括不限于高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!

  • Android前沿技术大纲

  • 全套体系化高级架构视频

资料领取:点赞+点击GitHub免费获取

往期Android高级架构资料、源码、笔记、视频。高级UI、性能优化、架构师课程、混合式开发(ReactNative+Weex)全方面的Android进阶实践技术,群内还有技术大牛一起讨论交流解决问题。