USing Android Studio 2 I get this error while compiling the code
Gradle: Execution failed for task ':dummy002:compileDebug'.
Compilation failed; see the compiler error output for details. C:\\Android_XML\\dummy002Project\\dummy002\\src\\main\\java\\com\\example\\dummy002\\MainActivity.java\\ Gradle: package com.google.ads does not exist
I have add the file GoogleAdMobAdsSdk-6.4.1.jar in the lib directory and also as library file.
When coding the code does not show any error highlight.
If I use the AdView in Actitvity the preview in studio show banner ads by google.
Where am I going wrong.
添加依赖项到build.gradle
文件中的行解决了该问题
"compile fileTree(dir: 'libs', include: '*.jar')"
adView = new AdView(this, AdSize.BANNER, "your key");
AdRequest request = new AdRequest();
request.setTesting(false);
adView.loadAd(request);
XML File
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId=" a1510b619xxxxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.