亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android開發(fā)中的錯誤及解決辦法總結(jié)

 更新時間:2022年02月17日 10:13:15   作者:PGzxc  
本文屬于個人平時項目開發(fā)過程遇到的一些問題,記錄下來并總結(jié)解決方案,希望能幫到大家解決問題,需要的朋友可以參考下

一 概述

開發(fā)工具升級,依賴庫,運行環(huán)境(jdk)等都會造成項目運行出現(xiàn)錯誤

掌握開發(fā)中常見錯誤現(xiàn)象和問題及解決辦法,能節(jié)省時間

本文將不定期更新

二 錯誤類

2.1 Cannot inline bytecode built with JVM target 1.8

現(xiàn)象

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target

解決方案

android {
    ...
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }
 
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

2.2 Unable to find EOCD signature

現(xiàn)象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

現(xiàn)象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)

原因

依賴中添加了有關(guān)ABI相關(guān)的配置,打包輸出時,未指定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}-${output.getFilter(OutputFile.ABI)}-${variant.name}-${variant.versionName}.apk"
                }
            }
        }
    }

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

現(xiàn)象

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

解決辦法

在app/build.gradle文件中加以下代碼后,重構(gòu)項目

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

現(xiàn)象(項目創(chuàng)建時)

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

現(xiàn)象

The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) 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

現(xiàn)象

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

解決辦法(buildToolsVersion引起-修改前)

compileSdkVersion 30
buildToolsVersion "30.0.3"

去掉buildToolsVersion或?qū)uildToolsVersion版本降低

compileSdkVersion 30
buildToolsVersion "30.0.2"

四 工具類

4.1 Task list not build

現(xiàn)象

解決辦法

  1. 點擊Task list not build,進入Settings——>Experimental,將Do not build Gradle task list duraing Gradle sync前面的勾選去掉,并應用
  2. 點擊Sync Project with Gradle Files同步一下項目

總結(jié)

到此這篇關(guān)于Android開發(fā)中的錯誤及解決辦法的文章就介紹到這了,更多相關(guān)Android開發(fā)錯誤及解決內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android 三級NestedScroll嵌套滾動實踐

    Android 三級NestedScroll嵌套滾動實踐

    這篇文章主要介紹了Android 三級NestedScroll嵌套滾動實踐,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-02-02
  • Android中利用xml文件布局修改Helloworld程序

    Android中利用xml文件布局修改Helloworld程序

    這篇文章主要介紹了Android中利用xml文件布局修改Helloworld程序 的相關(guān)資料,需要的朋友可以參考下
    2016-07-07
  • Android自定義View仿華為圓形加載進度條

    Android自定義View仿華為圓形加載進度條

    這篇文章主要為大家詳細介紹了Android自定義View仿華為圓形加載進度條,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Android Activity之間傳遞圖片(Bitmap)的方法

    Android Activity之間傳遞圖片(Bitmap)的方法

    這篇文章介紹了Android Activity之間傳遞圖片(Bitmap)的方法,有需要的朋友可以參考一下
    2013-08-08
  • Android使用WebView播放flash的方法

    Android使用WebView播放flash的方法

    這篇文章主要介紹了Android使用WebView播放flash及判斷是否安裝flash插件的方法,以實例形式詳細講述了從布局、邏輯判斷到功能最終實現(xiàn)播放Flash的方法,是Android程序設(shè)計中比較典型的應用,需要的朋友可以參考下
    2014-11-11
  • 快速解決android webview https圖片不顯示的問題

    快速解決android webview https圖片不顯示的問題

    今天小編就為大家分享一篇快速解決android webview https圖片不顯示的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • Android使用代碼動態(tài)生成界面

    Android使用代碼動態(tài)生成界面

    這篇文章主要為大家詳細介紹了Android使用代碼動態(tài)生成界面,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Android開發(fā)InputManagerService創(chuàng)建與啟動流程

    Android開發(fā)InputManagerService創(chuàng)建與啟動流程

    這篇文章主要為大家介紹了Android開發(fā)InputManagerService創(chuàng)建與啟動流程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • Android?Hilt?Retrofit?Paging3使用實例

    Android?Hilt?Retrofit?Paging3使用實例

    這篇文章主要介紹了Android?Hilt依賴注入的使用,首先,某個類的成員變量稱為依賴,如若此變量想要實例化引用其類的方法,可以通過構(gòu)造函數(shù)傳參或者通過某個方法獲取對象,此等通過外部方法獲取對象實例的稱為依賴注入
    2023-01-01
  • Android UI實現(xiàn)底部切換標簽fragment

    Android UI實現(xiàn)底部切換標簽fragment

    這篇文章主要為大家詳細介紹了Android UI實現(xiàn)底部切換標簽的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12

最新評論