我的应用build. gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.marcus.exceltest"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'org.apache.poi:poi:4.1.1'
implementation 'org.apache.poi:poiooxml:4.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
}
我的Gradle build. gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我Gradle.properties
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
错误:
错误:找不到GradleDSL方法:“实现()”可能的原因:项目“Exceltest”可能正在使用不包含该方法的Android Gradle插件版本(例如,在1.1.0中添加了“testCompile”)。将插件升级到版本3.5.2并同步项目
项目“Exceltest”可能正在使用不包含该方法的Gradle版本。打开Gradle包装文件
构建文件可能缺少Gradle插件。应用Gradle插件
事件日志:18:27 Gradle同步失败:找不到org.gradle.api.内部.artifacts.dsl.依赖项.DefaultDependencyHandler类型对象上参数[androidx.appcompat:appcompat:1.1.0]的方法实现()。(950毫秒)
18:27 NDK分辨率结果:项目设置:Gradle模型版本=5.4.1,NDK版本未知
18:28运行“Exceltest”时出错:Gradle项目同步失败。请修复您的项目并重试。
在我升级到Android Studio v3.5.2之前,一切都正常,尝试了AS提供的所有建议,但我很难尝试手动更新,包括gradle升级和工具升级。我对AS很陌生,我看过以前的答案,但它们与更旧的版本有关,或者我的版本中不存在文件系统。请有人帮忙吗?
你把它写在错误的地方实现androidx. appcompat:appcompat:1.1.0
从gradle类路径下面的gradlebuild.gradle
中删除这一行
您的项目的build. gradle文件中存在错误。它应该看起来像这样
// Top-level build file where you can add configuration options common to all sub- projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
一切看起来都很好,但是,1.你迁移到Androidx的一些库,有些没有,所以我要求你将项目的所有库迁移到androidx。2.从项目级gradle文件中删除实现行或将其移动到应用级gradle文件。