1
我在我的android studio项目中发现了一个错误。它显示:Android studio错误 - 无法解析:com.google.android.gms:play-services-ads
Error:(29, 13) Failed to resolve:com.google.android.gms:play-services-ads:+ Install Repository and sync project
,当我点击安装库和同步项目它显示:
我应该怎么办?
我的XML -
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hanumanbeniwal.www.hanumanbeniwal.MainActivity">
<WebView
android:id="@+id/WebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="586dp"
android:layout_y="948dp" />
</WebView>
</android.support.constraint.ConstraintLayout>
我的Java编码 -
package com.hanumanbeniwal.www.hanumanbeniwal;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
public WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView =(WebView)findViewById(R.id.WebView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
myWebView.loadUrl("http://www.hanumanbeniwal.com/");
myWebView.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed() {
}
}
build.gradle
(项目)请检查一下......
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.hanumanbeniwal.www.hanumanbeniwal"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:+'
}
builed.gradle
(模块:APP)请检查它......
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
现在它显示 - 错误:(1,0)未找到id为'com.android.application'的插件。我该怎么办 ? –
检查您的项目级别build.gradle文件。查看'repositories'部分是否缺少任何东西。 –
我已经检查过,并且附有我的问题的build.gradle文件,所以请检查并解决我的问题。 –