android-studioadmobvpngreat-firewall-of-china

Android Studio - Admob error - China


I am trying to add admob to my app, following the instructions

added to the build.gradle (project) section maven

   allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

}

added to build.gradle (app) section for play service

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'

}

In mainactivity

import com.google.android.gms.ads.MobileAds;

public class MainActivity extends AppCompatActivity { ... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

    // Sample AdMob app ID:
    MobileAds.initialize(this, "MY_ADMOB_APP");

When try to sync project get error message

FAILED TO SYNC : COM.GOOGLE.ANDROID.GMS:PLAY-SERVICE-ADS:11.8.0

I am in China so using a VPN, is this causing the issue.?


Solution

  • Try not using a VPN and check if Gradle is in offline mode