-
关于使用Android Studio 2024.3.1版本构建项目的编译时遇见的问题
-
jdk版本 11.0.13 、构建下载gradle版本gradle-8.10-bin.zip 对应的插件版本 com.android.tools.build:gradle:8.3.1报错问题如下
运行结果及详细报错内容
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\workspace_mi\******\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> java.lang.NoClassDefFoundError: com/android/tools/lint/model/LintModelModuleLoaderProvider
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$1(DefaultScriptPluginFactory.java:143)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:79)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:146)
尝试删除本地缓存并重新下载,更换gradle版本及对应的插件,使用国内阿里云的maven镜像去下载均不成功
项目根目录下面的build.gradle文件如下
allprojects {
buildscript {
repositories {
google()
maven { url 'https://maven.aliyun.com/repository/public' } // 阿里云镜像
mavenCentral() // 保留中央仓库作为备用
// jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:8.3.1" // 使用最新的 AGP 版本
// if you happen a plugin problem when uese thirdpart gradle plugin oppen this
}
}
repositories {
google()
maven { url 'https://maven.aliyun.com/repository/public' } // 阿里云镜像
mavenCentral() // 保留中央仓库作为备用
// jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
项目模块下的build.gradle代码
apply plugin: "com.android.application"
dependencies {
implementation fileTree(dir: 'javaScaffoding', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
android {
compileSdkVersion 34
buildToolsVersion '34.0.0'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
applicationId 'com.****.mi'
externalNativeBuild {
cmake {
cppFlags "-std=c++11"
}
}
ndk {
abiFilters 'arm64-v8a' // you can make one only for dev to improve building speed
}
versionCode 1001
versionName '1.0.1'
multiDexEnabled true
}
aaptOptions {//TODO NOTE when you happen a asset file access problem you can try add pattern here
noCompress = ['.unity3d', '.ress', '.resource', '.obb']
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.debug
jniDebuggable true
}
release {
debuggable false
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
sensitiveOptions {//when build type debuggable is false this feature working only and with this feature working building speed will slow down ,you can make it working when building a release apk
//collapseToAssetFile 'dex' //keep this string same as c++ fakeDex method last param
/**confing packages or classe with no ext but this cant include application class or application ref classes **/
//collapsePackage 'com.google'
//collapsePackage 'com.vungle'
//collapsePackage 'com.inmobi'
//collapsePackage 'com.adcolony'
//collapsePackage 'com.applovin'
//collapsePackage 'com.chartboost'
}
ndkVersion '21.1.6352462'
}
请问为啥会出现这种问题