本文介紹了Android此功能需要ASM7的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
Possible duplicate
我已將我的Android Studio更新為
'Android Studio Arctic Fox | 2020.3.1 Patch 3'
Java從JDK 1.8更新到JDK 11
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
我還將Gradle升級到
'com.android.tools.build:gradle:7.0.3'
這是我的完整Gradle構建文件
Gradle(模塊)
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-kapt'
id 'io.michaelrocks.paranoid'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.company.project"
minSdk 21
targetSdk 32
versionCode 13
versionName "2.0.34"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
//cppFlags "-pie -fPIE"
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
}
packagingOptions {
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/atomicfu.kotlin_module'
}
kotlinOptions {
jvmTarget = '11'
}
dataBinding {
enabled = true
}
externalNativeBuild {
cmake {
path "src/main/jni/CMakeLists.txt"
version "3.10.2"
}
}
ndkVersion '21.0.6113669'
signingConfigs {
debug {
// Signing configs
storeFile file("../keystore/debug.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
// Signing configs
storeFile file("../keystore/release.keystore")
storePassword 'company1234'
keyAlias 'company_key'
keyPassword 'company1234'
enableV2Signing = true
enableV3Signing = true
enableV4Signing = true
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
minifyEnabled false
applicationVariants.all {
variant - >
renameAPK(variant, applicationName, defaultConfig, 'D')
}
}
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
applicationVariants.all {
variant - >
renameAPK(variant, applicationName, defaultConfig, 'R')
}
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86"
}
}
}
flavorDimensions "ht"
productFlavors {
dev {
applicationId "com.company.project"
buildConfigField "int", "FlavorCode", "1"
}
staging {
applicationId "com.company.project"
buildConfigField "int", "FlavorCode", "2"
}
prod {
applicationId "com.company.project"
buildConfigField "int", "FlavorCode", "3"
}
}
}
static def renameAPK(variant, applicationName, defaultConfig, buildType) {
variant.outputs.each {
output - >
def formattedDate = new Date().format('dd-MM-yyyy_HH_mm')
def fileName = applicationName + "_V" + defaultConfig.versionName + "_" + formattedDate + "_" + variant.flavorName + "_" + buildType + ".apk"
output.outputFileName = new File(fileName)
}
}
dependencies {
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
////////////////////////// Testing frameworks //////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//Testing frameworks
testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation 'org.mockito:mockito-core:3.5.13'
testImplementation 'org.robolectric:robolectric:4.4'
testImplementation 'org.robolectric:shadows-multidex:4.4'
testImplementation "io.mockk:mockk:1.10.2"
testImplementation 'io.mockk:mockk-common:1.10.2'
testImplementation 'com.google.truth:truth:1.1.3'
testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3'
// Android Tests
androidTestImplementation "androidx.navigation:navigation-testing:$rootProject.ext.navigation"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.arch.core:core-testing:2.1.0'
androidTestImplementation "androidx.test:core:1.4.0"
androidTestImplementation "androidx.fragment:fragment-testing:$rootProject.ext.fragment_version"
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
////////////////////////// Normal Frameworks //////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.annotation:annotation:1.3.0'
implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.ext.navigation"
implementation "androidx.navigation:navigation-ui-ktx:$rootProject.ext.navigation"
implementation "androidx.navigation:navigation-runtime-ktx:$rootProject.ext.navigation"
implementation "androidx.fragment:fragment-ktx:1.2.5"
// Kotlin & JetBrains
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3'
implementation 'com.github.florent37:inline-activity-result-kotlin:1.0.4'
implementation 'org.jetbrains.anko:anko-appcompat-v7-commons:0.10.2'
//Androidx UI Components
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation "androidx.cardview:cardview:1.0.0"
// ViewModel LifeCycle
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
//Koin
implementation "org.koin:koin-core:$rootProject.ext.koin_version"
implementation "org.koin:koin-android:$rootProject.ext.koin_version"
implementation "org.koin:koin-android-viewmodel:$rootProject.ext.koin_version"
implementation "org.koin:koin-android-architecture:$rootProject.ext.koin_architecture_version"
//ok http
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.7.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.code.gson:gson:2.8.8'
// Room components
implementation 'androidx.room:room-runtime:2.4.1'
implementation 'androidx.room:room-ktx:2.4.1'
kapt 'androidx.room:room-compiler:2.4.1'
androidTestImplementation 'androidx.room:room-testing:2.4.1'
// Navigation component
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.4.0')
// Firebase library dependencies
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-dynamic-links-ktx'
// sdp and ssp for dp and sp values
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
//permissions helper
implementation 'com.karumi:dexter:6.2.0'
//Facebook text encryption
implementation 'com.facebook.conceal:conceal:2.0.1@aar'
//Lottie animations
implementation 'com.airbnb.android:lottie:3.4.2'
// Location services
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.tbuonomo:dotsindicator:4.2'
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.bumptech.glide:annotations:4.11.0'
implementation "org.ow2.asm:asm:7.0"
}
Gradle(根/應用程序)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext{
koin_version = '2.0.1'
koin_architecture_version = "0.8.2"
navigation = "2.3.5"
fragment_version = "1.4.0"
}
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5'
classpath 'io.michaelrocks:paranoid-gradle-plugin:0.3.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
升級后,生成失敗,出現以下異常
Execution failed for task ':app:transformClassesWithParanoidForDevDebug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalArgumentException: Unable to read a ClassMirror for com/data/model/response/ParsingHelper$CharSequenceDeserializer
This feature requires ASM7
我曾嘗試修復特定的ParsingHelper類,并將其代碼更新為Kotlin,但隨后在不同的類中得到相同的異常。因此,我認為修復整個項目中的每個Java類都不是一個好主意。
根據this線程更新到AGP 7.0.1版可以解決此問題,但我已經在7.0.3的較新版本上。
推薦答案
您可以通過添加maven { url 'https://jitpack.io' }
來嘗試
至Settings.gradle
像這樣的代碼:
Settings.Gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://www.jitpack.io' } //here you can add this
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "YourAppName"
include ':app'
并在build.gradle (Module)
中添加以下內容:
implementation 'org.ow2.asm:asm:7.0'
并重新生成您的項目。
這篇關于Android此功能需要ASM7的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,