Android Gradle 3 build failed

333 Views Asked by At

I have some troubles compiling my project with Gradle 3. When I update my project to use this version of Gradle, the gradle sync is okay, but as soon as I hit the run button, it gives me this:

Error:Execution failed for task 
':app:compileBetaGoogleWebkitDebuggableReleaseJavaWithJavac'.
> java.lang.NoClassDefFoundError: com/fyber/annotations/FyberSDK

With older gradle (2.3.3) it works just perfect, but I need to update the project, for undisclosable, professional reason. What can go wrong between those two gradle versions, that one sees the FyberSDK and the other does not?

Here is my gradle script

apply plugin: 'com.android.application'

def mVersionCode = 16;
def mVersionName = "1.16"

android {
signingConfigs {
    releaseSigning {
        keyAlias 'redacted'
        keyPassword 'redacted'
        storeFile file('redacted')
        storePassword 'redacted'
    }
}
compileSdkVersion 23
defaultConfig {
    applicationId "redacted"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode mVersionCode
    versionName mVersionName
    resValue "string", "app_version_name", mVersionName
    resValue "string", "app_name", "redacted"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.releaseSigning
    }
    debuggableRelease {
        debuggable true
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.releaseSigning
    }
}

flavorDimensions "server", "lib"

productFlavors {
    pubGoogle {
        dimension "server"
        minSdkVersion 19
        buildConfigField("boolean", "isGoogleBuild", "true")
    }
    betaGoogle {
        dimension "server"
        minSdkVersion 14
        resValue "string", "app_version_name", mVersionName + "beta"
        resValue "string", "app_name", "redacted Beta"
        buildConfigField("boolean", "isGoogleBuild", "true")
    }
    pubAmazon {
        dimension "server"
        minSdkVersion 19
        buildConfigField("boolean", "isGoogleBuild", "false")
    }
    betaAmazon {
        dimension "server"
        minSdkVersion 14
        resValue "string", "app_version_name", mVersionName + "beta"
        resValue "string", "app_name", "redacted Beta"
        buildConfigField("boolean", "isGoogleBuild", "false")
    }
    /*xwalk {
        dimension "lib"
    }*/
    webkit {
        dimension "lib"
    }
}
}

repositories {
mavenCentral()
maven {
    name "Fyber's maven repo"
    url "https://fyber.bintray.com/maven"
}
}

configurations {
provided
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.sponsorpay:sponsorpay-android-sdk:7.2.8'

compile 'com.fyber:fyber-sdk:8.17.0'
// Fyber Annotations
provided 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// Fyber mediation services
// UnityAds Mediation
compile 'com.fyber.mediation:unityads:2.1.1-r1@aar'
// ChartBoost Mediation
compile 'com.fyber.mediation:chartboost:6.6.3-r2@aar'
// Vungle Mediation
compile 'com.fyber.mediation:vungle:5.3.0-r1@aar'

// Vungle third-party dependencies
compile 'com.google.dagger:dagger:2.7'
compile 'javax.inject:javax.inject:1'
compile 'de.greenrobot:eventbus:2.2.1'
compile 'io.reactivex:rxjava:1.2.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.google.android.gms:play-services-basement:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'

// For AppsFlyer
compile 'com.appsflyer:af-android-sdk:4.6.0@aar'
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
//xwalkCompile 'org.xwalk:xwalk_core_library:23.53.589.4'
}

apply plugin: 'com.google.gms.google-services'
1

There are 1 best solutions below

0
On BEST ANSWER

I also encountered this problem, eventually solved the problem.

you maybe use a annotations like this:

@FyberSDK

all you need to is find this annotations ,and change it's build.gradle file with this:

apply plugin: 'com.android.library'

android {
// ...
// add this code to enable annotationProcessor
   javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath = true
        }
    }
}

dependencies {
// ...
// Fyber Annotations
compileOnly 'com.fyber:fyber-annotations:1.3.0'
annotationProcessor 'com.fyber:fyber-annotations-compiler:1.4.0'
// ...
}

try this code ,and sync your project.hope is work fine, it's work fine for me. if you want learn more for detail, you can read my blog here:

https://segmentfault.com/a/1190000012245056