1

我在使用 Gradle 3 编译我的项目时遇到了一些麻烦。当我更新我的项目以使用这个版本的 Gradle 时,gradle 同步是可以的,但是只要我点击运行按钮,它就会给我这个:

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

使用较旧的 gradle (2.3.3) 它可以完美运行,但出于不可公开的专业原因,我需要更新项目。这两个 gradle 版本之间会出现什么问题,一个看到 FyberSDK 而另一个没有?

这是我的gradle脚本

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'
4

1 回答 1

1

我也遇到了这个问题,最终解决了这个问题。

你可能会使用这样的注释:

@FyberSDK

你需要做的就是找到这个注释,并build.gradle用这个改变它的文件:

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'
// ...
}

试试这个代码,并同步你的项目。希望工作正常,对我来说工作正常。如果您想了解更多详细信息,可以在此处阅读我的博客:

https://segmentfault.com/a/1190000012245056

于 2017-12-01T08:12:47.210 回答