Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Compilation Error:Execution failed for task ':app:compileDebugJava'

I am facing the following error:

Error:(89, 39) error: incomparable types: CAP#1 and int  
where CAP#1 is a fresh type-variable:  
CAP#1 extends Object from capture of ?Note: Some input files use unchecked or   unsafe operations.  
Note: Recompile with -Xlint:unchecked for details.  
Error:Execution failed for task ':app:compileDebugJava'.  

Compilation failed; see the compiler error output for details.

My Gradle File looks like below:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0 rc3"

    repositories {
        maven { url "https://jitpack.io" }
        mavenCentral()
        jcenter()

    }

    defaultConfig {
        applicationId "wishlist.oj.app"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:21.+'
    compile 'com.android.support:cardview-v7:21.+'
}

The error is coming from My Recycler View Adaptor File which just inflates the multpile textviews into recycler view

like image 424
ojas Avatar asked Jun 29 '26 11:06

ojas


2 Answers

Error:Execution failed for task ':app:compileDebugJava'.

For Good Practice

At first enable multiDexEnabled ,Then upgrade your support:recyclerview ,support:appcompat ,support:cardview version

The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android Support Repository to the latest version using the SDK Manager before attempting to configure your app for multidex.

Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:

  1. Change your Gradle build configuration to enable multidex
  2. Modify your manifest to reference the MultiDexApplication class

Modify your app Gradle build file configuration to include the support library and enable multidex output .

     android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"

        defaultConfig {
            ...
            minSdkVersion 16
            targetSdkVersion 23
            ...

            // Enabling multidex support.
            multiDexEnabled true
        }
        ...
    }

    dependencies {
      compile 'com.android.support:multidex:1.0.0'
      compile 'com.android.support:appcompat-v7:23.1.1'
      compile 'com.android.support:recyclerview-v7:23.1.1"
      compile 'com.android.support:cardview-v7:23.1.1'
     }

Then Clean-Rebuild-Restart-Sync Your Project

like image 193
IntelliJ Amiya Avatar answered Jul 01 '26 01:07

IntelliJ Amiya


Change

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1"
compile 'com.android.support:cardview-v7:23.1.1'
like image 43
M D Avatar answered Jul 01 '26 03:07

M D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!