2017-05-25 138 views
-1

我在引用這個https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started來將mopub集成到我的應用中。我在我的項目的build.gradle文件中添加mopub-sdk依賴項時出現錯誤「找不到方法編譯參數」。請幫助我。 的build.gradle文件:Gradle Sync失敗:找不到方法compile()參數

buildscript { 
    repositories { 

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

    dependencies { 
    classpath 'com.android.tools.build:gradle:2.2.3' 
    }} 
    allprojects { 


    repositories { 
    jcenter() 

} 
dependencies { 

    compile('com.mopub:mopub-sdk:[email protected]') { 
     transitive = true 
    } 
    // For banners 
    compile('com.mopub:mopub-sdk-banner:[email protected]') { 
     transitive = true 
    } 

    // For interstitials 
    compile('com.mopub:mopub-sdk-interstitial:[email protected]') { 
     transitive = true 
    } 
    // For rewarded videos. This will automatically also include 
     interstitials 
    compile('com.mopub:mopub-sdk-rewardedvideo:[email protected]') { 
     transitive = true 
    } 
    // For native static (images). 
    compile('com.mopub:mopub-sdk-native-static:[email protected]') { 
     transitive = true 
    } 

    // For native video. This will automatically also include native static 
    compile('com.mopub:mopub-sdk-native-video:[email protected]') 
    {transitive = true} 
    } 
    } 
    task clean(type: Delete) { 
    delete rootProject.buildDir 
    } 

實際誤差: -

Error:(31, 0) Could not find method compile() for arguments [com.mopub:mopub-sdk:[email protected], bu[email protected]1c36532] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 

回答

0

你需要把你的依賴在其他build.gradle。它們屬於單個模塊build.gradle文件。

此外,您正在導入com.mopub:mopub-sdk:[email protected],其中包含所有的廣告格式依賴關係,您已在下面的Gradle文件中包含這些依賴關係。您只需要模塊化文物com.mopub:mopub-sdk:[email protected]

相關問題