如何添加与 android studio 集成的 mopub 广告库
我正在尝试将 MoPub SDK 添加到我的应用程序中.我尝试在 Android Studio 中导入和添加库,但在我的应用中没有看到任何广告.
I am trying to add the MoPub SDK to my application. I try to import and add the library in Android Studio, but I do not see any ad in my app.
我最初使用 Eclipse 添加库,但我正在尝试使用 Android Studio,因为它现在是 Google 支持的新工具.
I used Eclipse to add the library originally, but I am trying Android Studio because it is the new Google-supported tool now.
如何使用 Android Studio 将 MoPub 的 SDK 添加到我的应用中?
How do I add MoPub's SDK to my app using Android Studio?
可能是Android studio更新了,根据abaar或pyus13的回答我没能解决.
Maybe Android studio has updated, I couldn't solve it according to abaar or pyus13's answer.
此答案基于 Android Studio 0.6.1.
This answer is based on Android Studio 0.6.1.
解压你下载的
mopub-sdk.zip
在 Android Studio 中打开项目结构(文件 -> 项目结构)
Open project structure(File -> Project Structure) in Android Studio
点击左上角的+"按钮添加一个新模块
Click the '+' button on the upper left to add a new module
您可以看到新建模块向导,选择导入现有项目并点击下一步
You can see the New Module wizzard, choose Import Existing Project and click next
选择刚刚解压的mopub-sdk文件夹
Choose the mopub-sdk folder you just unzipped
点击下一步并完成.现在您可以看到 Android Studio 将 mopub-sdk 导入到您的项目中.并且 settings.gradle
文件已添加到您的项目中
Click next and finish. Now you can see that Android Studio import the mopub-sdk into your project. And a settings.gradle
file has been added into your project
打开settings.gradle
,添加一行include ':'
打开你项目的build.gradle
文件,在依赖项中,添加compile project('mopubsdk')
(mopubsdk就是你的项目名刚刚添加)
Open the build.gradle
file of your project, in the dependencies entry, add compile project('mopubsdk')
(mopubsdk is the project name you just added)
再次打开项目结构,可以看到左侧的mopubsdk
模块,点击它,然后选择顶部的Dependencies
标签,更改com.android.support:support-v4:+
的范围从 Compile
到 Provided
Open project structure again, you can see the mopubsdk
module on the left, click on it, then choose Dependencies
tab on the top, change com.android.support:support-v4:+
's scope from Compile
to Provided
现在完成了.它对我有用.
Now it's done. It works for me.