我的项目失败 运行 ,说 "build failed"
my project failed to run , saying "build failed"
我制作了一个项目,其中包含事件列表和一个按钮,用户可以将其设置为闹钟或提醒。
我根据我的观察进行了跟踪,似乎没有错误。
但是当我尝试 运行 我的应用程序时,错误显示
> Transform artifact materialdatetimepicker.aar (com.wdullaer:materialdatetimepicker:4.2.3) with DexingNoClasspathTransform
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): int com.wdullaer.materialdatetimepicker.date.DateRangeLimiter.getMaxYear()","sources":[{}],"tool":"D8"}
> Task :app:mergeExtDexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'materialdatetimepicker.aar (com.wdullaer:materialdatetimepicker:4.2.3)' to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=16}.
> Execution failed for DexingNoClasspathTransform: C:\Users\Gerilla Family\.gradle\caches\transforms-2\files-2.1dfb28f22b6828ae75d6c3c01e91a179\materialdatetimepicker-4.2.3\jars\classes.jar.
> Error while dexing.
* Try:
Run with --stacktrace option to get the stack trace. 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 52s
22 actionable tasks: 3 executed, 19 up-to-date
这是build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.notifier"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.jakebonk:NotifyMe:1.0.1'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
}
这个库最少只支持 Android N。
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
将此添加到 build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
您忘记添加 app/build.gradle
https://github.com/wdullaer/MaterialDateTimePicker#setup
Java
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
科特林
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
我制作了一个项目,其中包含事件列表和一个按钮,用户可以将其设置为闹钟或提醒。
我根据我的观察进行了跟踪,似乎没有错误。
但是当我尝试 运行 我的应用程序时,错误显示
> Transform artifact materialdatetimepicker.aar (com.wdullaer:materialdatetimepicker:4.2.3) with DexingNoClasspathTransform
AGPBI: {"kind":"error","text":"Default interface methods are only supported starting with Android N (--min-api 24): int com.wdullaer.materialdatetimepicker.date.DateRangeLimiter.getMaxYear()","sources":[{}],"tool":"D8"}
> Task :app:mergeExtDexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'materialdatetimepicker.aar (com.wdullaer:materialdatetimepicker:4.2.3)' to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=16}.
> Execution failed for DexingNoClasspathTransform: C:\Users\Gerilla Family\.gradle\caches\transforms-2\files-2.1dfb28f22b6828ae75d6c3c01e91a179\materialdatetimepicker-4.2.3\jars\classes.jar.
> Error while dexing.
* Try:
Run with --stacktrace option to get the stack trace. 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 52s
22 actionable tasks: 3 executed, 19 up-to-date
这是build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.notifier"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.jakebonk:NotifyMe:1.0.1'
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
}
这个库最少只支持 Android N。
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
将此添加到 build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
您忘记添加 app/build.gradle
https://github.com/wdullaer/MaterialDateTimePicker#setup
Java
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
科特林
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}