问题描述
我在Android Studio创建了一个项目。 即使没有修改项目中的任何单个字符,我也无法运行它。它会给出以下错误信息。
这些代码。
MainActivity.java:
package com.kk.myapplication;
导入android.support.v7.app.AppCompatActivity;
导入android.os.Bundle;
$ b $ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Manifest.xml:
<?xml version =1.0encoding =utf-8?>
< manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.kk.myapplication>
< application
android:allowBackup =true
android:icon =@ mipmap / ic_launcher
android:label =@ string / app_name
android:supportsRtl =true
android:theme =@ style / AppTheme>
< activity android:name =。MainActivity>
< intent-filter>
< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< / activity>
< / application>
< / manifest>
build.gradle:
apply plugin:'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion24.0.0
defaultConfig {
applicationIdcom.kk.myapplication
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName1.0
$ b buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
testCompile'junit: junit:4.12'
compile'com.android.support:appcompat-v7:24.2.0'
}
> build.gradle(顶级)
// Top-级别构建文件在哪里您可以添加所有子项目/模块通用的配置选项。
$ b buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle: 1.5.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}
allprojects {
存储库{
jcenter()
任务清理(类型:删除){
删除rootProject.buildDir
}
我该如何解决这个问题?我没有改变任何项目的任何帮助被评价。
在这里你会得到这个问题。 b
$ b
解决方案是将
gradle插件升级到v2.0 +(升级至2.1.0)
在您的依赖项中添加此项。
{
classpath'com.android.tools.build:gradle:2.1.0'
}
并同步该项目。
编辑:
改变这个
依赖关系{
classpath'com.android.tools.build :gradle:1.5.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件
//
$ b $ /
依赖关系{
classpath'com.android.tools.build:gradle:2.1.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
$ b
I created a project in Android studio. Even without modifying any single character in the project I cannot run it. It gives following error.
These are the codes.
MainActivity.java :
package com.kk.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Manifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kk.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.kk.myapplication"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
}
build.gradle(Top Level)
// 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:1.5.0'
// 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
}
How can I fix this issue? I did not change anything in the project Any Help be Appreciated.
解决方案 Here you will get this issue.
https://code.google.com/p/android/issues/detail?id=214182
Solution was to upgrade the gradle plugin to v2.0+ (upgraded to 2.1.0)
add this in your dependency.
{
classpath 'com.android.tools.build:gradle:2.1.0'
}
and sync the project.
Edit :
change this
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
to this
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
这篇关于如何解决Android Studio中的VectorDrawableCompat配置错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!