Tag Archives: grade

Execution failed for task ‘:app:kaptDebugKotlin‘ [How to Solve]

Error compiling project with kotlin:

Execution failed for task ‘:app:kaptDebugKotlin’.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
java.lang.reflect.InvocationTargetException (no error message)
various kotlin annotation errors will be reported

The problem is that the version of kotlin plug-in is inconsistent with that in build

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

Check the version of the org.jetbrains.kotlin:kotlin-gradle-plugin is consistent with the version of the kotlin that the module depends on or not.

Android studio configurate intent-filter and compile error [Solved]

The error contents are as follows:

Manifest merger failed : android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined.

 

When targeting is greater than or equal to Android 12, if some activities are configured with intent-filter, the exported property must be configured at the same time.

According to the error report, there are two solutions:

1. Modify the targetSdk of build.gradle less than 30.

2. Or add the export attribute to the <Intent-filter> tag in AndroidManifest.xml and assign it to true

Last hammer

No problem!

[Solved] Android Gradle configure error: Location: Class buildconfig

Error message:

D:\002_Project\002_Android_Learn\ClassLoader_Demo\app\build\generated\source\buildConfig\debug\com\example\classloader_demo\BuildConfig.java:15: Error: Symbol not found
  public static final String market = GooglePlay;
                                      ^
  Symbol: Variable GooglePlay
  Location: Class BuildConfig

In the gradle.properties configuration file in the root of the Android Studio project, configure as:

# Configure whether to be on Google Play
isGooglePlay=true
# Configure the current app marketplace
market=GooglePlay

The corresponding configuration in build.gradle is as follows :

android {

    defaultConfig {
        // Whether the app is available on Google Play
        buildConfigField("boolean", "isGooglePlay", isGooglePlay)
        // The current app marketplace
        buildConfigField("String", "market", market)
    }
}

The generated BuildConfig.java configuration is as follows :

/**
 * Automatically generated file. DO NOT MODIFY
 */
package com.example.classloader_demo;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.example.classloader_demo";
  public static final String BUILD_TYPE = "debug";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0";
  // Field from default config.
  public static final boolean isGooglePlay = true;
  // Field from default config.
  public static final String market = GooglePlay;
}

The last googleplay string has no double quotation marks, resulting in an error;

 

2. Solution

use

buildConfigField("String", "market", "\"${market}\"")

Groovy code , you can generate the following configuration in BuildConfig.java :

public static final String market = "GooglePlay";

The double quotes in the string need to be added with their own escape characters, otherwise they are invalid;

The first level of double quotes in “\”${market}\”” is because the buildConfigField function requires three string variables to be passed in, and the third parameter must be a string;

The second double-quote \” \”” uses the transfer character, which is the double-quote displayed in BuildConfig, and the internal ${market} is the GooglePlay configuration content ;

[Solved] Execution failed for task ‘:app:checkDebugAarMetadata‘

After updating Fuller, the following problems will be reported:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-30).
        Dependency: androidx.window:window-java:1.0.0-beta04.
        AAR metadata file: C:\Users\liqiang\.gradle\caches\transforms-2\files-2.1\9f515ee58db509b5f4759e97c8eb6aa2\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > The minCompileSdk (31) specified in a
        dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
        is greater than this module's compileSdkVersion (android-30).
        Dependency: androidx.window:window:1.0.0-beta04.
        AAR metadata file: C:\Users\liqiang\.gradle\caches\transforms-2\files-2.1\a909ff21160c236fa8213aba5c707997\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.
* 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

BUILD FAILED in 4s
Exception: Gradle task assembleDebug failed with exit code 1

According to the error message The minCompileSdk (31) specified, the final sdk needs to be version 31, but our current sdk version is 30, which is greater than this version, so we need to modify the following configuration to 31

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        /*configurations.all {
            resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
        }*/
        applicationId "cn.liginfo.kqjhq_app"
        minSdkVersion 16
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

After modification, because there is no version 31 sdk, it will download automatically, but after downloading, the following error message appears again

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/0dd39ff9faeeb501ffb52162e269003e/jetified-kotlin-stdlib-1.5.31.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/2ea246a87a592f122121cfd0846ffbea/jetified-kotlin-stdlib-jdk7-1.5.30.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/9234cfcee40ec23fc2213363e9726513/jetified-window-1.0.0-beta04-api.jar!/META-INF/window_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/9af1d6ff9000d18681a83cd875960957/jetified-kotlinx-coroutines-core-jvm-1.5.2.jar!/META-INF/kotlinx-coroutines-core.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/b0b1eecff74e71ed1ef092403ad1018c/jetified-kotlin-stdlib-common-1.5.31.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/d91778f7878bf943ae593906c9fd7c75/jetified-kotlin-stdlib-jdk8-1.5.30.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/df6880e9350e429186aa0973bbf49093/jetified-window-java-1.0.0-beta04-api.jar!/META-INF/window-java_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
e: C:/Users/liqiang/.gradle/caches/transforms-2/files-2.1/e484fc5cda5fe73d156ca3b50e47d38e/jetified-kotlinx-coroutines-android-1.5.2.jar!/META-INF/kotlinx-coroutines-android.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

* 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

BUILD FAILED in 7s

┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                       │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │
│ update D:\javadeveloping\Android\workspace\kqjhq_app\android\build.gradle:                   │
│ ext.kotlin_version = '<latest-version>'                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1

From the error message, it is said that the version of kotlin is wrong, and a specific solution is given

Your project requires a newer version of the Kotlin Gradle plugin.                       │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │
│ update D:\javadeveloping\Android\workspace\kqjhq_app\android\build.gradle:                   │
│ ext.kotlin_version = '<latest-version>'   

You need an up-to-date plugin named kotlin gradle, Find the recent version in https://kotlinlang.org/docs/gradle.html#plugin-and-versions and update the the latest-version value in ext.kotlin_version = ‘’ of the D:\javadeveloping\Android\workspace\kqjhq_app\android\build.gradle file.

after opening the web page, we found that the latest version is 1.6.10, while our previous version is 1.3.5:

just change to 1.6.10 and package normally

[Solved] Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com.and

Error message of Android Studio:

> Task :app:processDebugResources FAILED
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\Administrator\\.gradle\\wrapper\\dists\\gradle-6.7.1-all\\caches\\transforms-2\\files-2.1\\4bc395114f57931320ace6dae20d2b04\\support-compat-27.1.1\\res\\values\\values.xml","position":{"startLine":15,"startColumn":4,"startOffset":880,"endLine":18,"endColumn":207,"endOffset":1240}}],"original":"ERROR:C:\\Users\\Administrator\\.gradle\\wrapper\\dists\\gradle-6.7.1-all\\caches\\transforms-2\\files-2.1\\4bc395114f57931320ace6dae20d2b04\\support-compat-27.1.1\\res\\values\\values.xml:16:5-19:208: AAPT: error: resource android:attr/fontStyle not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\Administrator\\.gradle\\wrapper\\dists\\gradle-6.7.1-all\\caches\\transforms-2\\files-2.1\\4bc395114f57931320ace6dae20d2b04\\support-compat-27.1.1\\res\\values\\values.xml","position":{"startLine":15,"startColumn":4,"startOffset":880,"endLine":18,"endColumn":207,"endOffset":1240}}],"original":"ERROR:C:\\Users\\Administrator\\.gradle\\wrapper\\dists\\gradle-6.7.1-all\\caches\\transforms-2\\files-2.1\\4bc395114f57931320ace6dae20d2b04\\support-compat-27.1.1\\res\\values\\values.xml:16:5-19:208: AAPT: error: resource android:attr/font not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\Administrator\\.gradle\\wrapper\\dists\\gradle-6.7.1-all\\caches\\transforms-2\\files-2.1\\4bc395114f57931320ace6dae20d2b04\\support-compat-27.1.1\\res\\values\\values.xml","position":{"startLine":15,"startColumn":4,"startOffset":880,"endLine":18,"endColumn":207,"endOffset":1240}}],"original":"ERROR:C:\\Users\\Administrator\\.gradle\\wrapper\\dists\\gradle-6.7.1-all\\caches\\transforms-2\\files-2.1\\4bc395114f57931320ace6dae20d2b04\\support-compat-27.1.1\\res\\values\\values.xml:16:5-19:208: AAPT: error: resource android:attr/fontWeight not found.\n    ","tool":"AAPT"}

Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR:C:\Users\Administrator\.gradle\wrapper\dists\gradle-6.7.1-all\caches\transforms-2\files-2.1\4bc395114f57931320ace6dae20d2b04\support-compat-27.1.1\res\values\values.xml:16:5-19:208: AAPT: error: resource android:attr/fontStyle not found.

* 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.



It seems that the error message may be the problem of dependent packages
I just added dependent packages:

implementation 'com.github.bumptech.glide:glide:4.7.1'

This dependency package version 4.7.1 may refer to the androidx library, 4.7.1 back to which version (Just google to find the corresponding version) to refer to the android library, there should be no problem

[Solved] Manifest merger failed with multiple errors, see logs

Adding a dependent library is an error when running, because the current project version is lower than the minimum trial version of the third-party dependent library

1. As shown in the current project’s build.gradle without setting the buildToolsVersion.

2. Set minSdkVersion to the minimum version of the dependency library in the current project’s build.gradle as shown here.

[Solved] Android resource linking failed, error: failed linking references.

Problem description

Android studio 4.0.1 in APP/build Gradle declares to use appcompat-v7, and the compilation times the following errors:

Android resource linking failed
Output:  D:\code\demo\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
D:\code\demo\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
D:\code\demo\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1086: error: resource android:attr/fontVariationSettings not found.
D:\code\demo\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1087: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Command: D:\gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\67766513f93fbda68bd5705c60a70b26\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
        D:\Android\SDK\platforms\android-27\android.jar\
        --manifest\
        D:\code\demo\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        D:\code\demo\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @D:\code\demo\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        D:\code\demo\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --custom-package\
        com.demo\
        -0\
        apk\
        --output-text-symbols\
        D:\code\demo\app\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

Solution:

In the root directory gradle In the properties file, disable Android X:

# android.useAndroidX=true
# android.enableJetifier=true

It can be solved by rebuilding.

[Solved] IntelliJ IDEA Compile Groovy Error: GroovyRuntimeException: This script or class could not be run.

1. Error record

function

class Student1 {
}

Groovy code will report an error;

 

Error message:

groovy.lang.GroovyRuntimeException: This script or class could not be run.
It should either:
- have a main method,
- be a JUnit test or extend GroovyTestCase,
- implement the Runnable interface,
- or be compatible with a registered script runner. Known runners:
  * <none>

 

2. Problem analysis

Only groovy code that meets the following requirements can run:

With main function

test case, used as JUnit test or extended GroovyTestCase

Thread related and implements the runnable interface
It is compatible with the registered script running program

Groovy code in other cases cannot be run;

[Solved] AAPT: error: resource android:attr/lStar not found

Recently, I want to try the KTX expansion Library of Android core in the project:

implementation "androidx.core:core-ktx:1.7.0"

After adding dependency, we happily start to use various concise syntax sugars provided by KTX to fly happily~

Once running, wow, I reported an error:

Android resource linking failed /Users/xxx/.gradle/caches/transforms-2/files-
2.1/5d04bb4852dc27334fe36f129faf6500/res/values/values.xml:115:5-162:25:
 AAPT: error: resource android:attr/lStar not found.

 

Solution 1:

If the dependency method is
AndroidX.Core: core-ktx:+
you need to replace it with a specific version
AndroidX.core:core-ktx:1.6.0

Solution 2:

If the version is  1.7.0, the compilesdkversion of the project is 31, because my project is 30, an error will be reported and changed to 1.6.0 version is good

[Solved] Android Studio Error: CreateProcess error = 206 file name or extension is too long

When Android studio develops Android projects, the error “CreateProcess error = 206” is easy to appear every time it runs. The console error message says that the file name or extension is too long. I used openjdk to solve this problem. I found many ways to solve it. For a long time, I can only restart Android studio or forcibly end the JDK process in the application manager. Later, I just changed the open JDK to Oracle JDK.