入门构建失败,出现异常的Andr​​oid工作室0.4.3和0.4.4 [英] Getting Build failed with an Exception Android Studio 0.4.3 and 0.4.4

查看:215
本文介绍了入门构建失败,出现异常的Andr​​oid工作室0.4.3和0.4.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:

因为我已经更新的Andr​​oid Studio来.4.3每次我尝试做一个新项目,我得到一些构建失败,事情发生在每一个新项目,我没有自己的code有...

让我们来看一看:

Android的code:

 包com.appgcm;

进口android.support.v7.app.ActionBarActivity;
进口android.support.v7.app.ActionBar;
进口android.support.v4.app.Fragment;
进口android.os.Bundle;
进口android.view.LayoutInflater;
进口android.view.Menu;
进口android.view.MenuItem;
进口android.view.View;
进口android.view.ViewGroup;
进口android.os.Build;

公共类MainActivity扩展ActionBarActivity {

@覆盖
保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);

    如果(savedInstanceState == NULL){
        getSupportFragmentManager()的BeginTransaction()
                。新增(R.id.container,新PlaceholderFragment())
                。承诺();
    }
}


@覆盖
公共布尔onCreateOptionsMenu(功能菜单){

    //充气菜单;这增加了项目操作栏,如果它是present。
    。getMenuInflater()膨胀(R.menu.main,菜单);
    返回true;
}

@覆盖
公共布尔onOptionsItemSelected(菜单项项){
    //处理动作栏项目点击这里。将操作栏
    //自动在主/向上按钮操作的点击,只要
    //你在AndroidManifest.xml中指定一个父活动。
    INT的id = item.getItemId();
    如果(ID == R.id.action_settings){
        返回true;
    }
    返回super.onOptionsItemSelected(项目);
}

/ **
 *包含一个简单的视图的占位符片段。
 * /
公共静态类PlaceholderFragment扩展片段{

    公共PlaceholderFragment(){
    }

    @覆盖
    公共查看onCreateView(LayoutInflater充气,容器的ViewGroup,
            捆绑savedInstanceState){
        查看rootView = inflater.inflate(R.layout.fragment_main,集装箱,假);
        返回rootView;
    }
}
 

}

Build.gradle

 应用插件:'机器人'

安卓{
compileSdkVersion 19
buildToolsVersion17.0.0

defaultConfig {
    的minSdkVersion 7
    targetSdkVersion 19
    版本code 1
    VERSIONNAME1.0
}
buildTypes {
    推出 {
        runProguard假
        proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的rules.txt
    }
}
}

依赖{
    编译com.android.support:appcompat-v7:+
    编译文件树(导演:库,包括:['的* .jar,* .aar'])
}
 

摇篮控制台错误:

 执行任务:[:appgcm:generateDebugSources]

依靠包装来定义主神器的扩展已经去precated,并计划在摇篮2.0被删除
:appgcm:preBuild失败

失败:建立失败,一个例外。

* 什么地方出了错:
执行失败的任务:appgcm:preBuild。
>构建工具修订19.0.0+是必需的。

* 尝试:
与--stacktrace选项获取堆栈跟踪运行。与--info或--debug选项运行,以获得更多的日志输出。

构建失败

总时间:3.265秒
 

好吧,我认为这是足够的信息来取出来的东西,我还没有真正专家摇篮,所以详细的说明就更好了。

非常感谢!

编辑:

我从pyus13了意见,现在我盖特另一种类型的错误,那就是:

 失败:建立失败,一个例外。

* 哪里:
构建文件'C:\ Users \用户pandolet \工作区\ APPGCM \ appgcm \ build.gradle'行:1

* 什么地方出了错:
出现了故障评估项目:appgcm。
>未找到插件ID为机器人。

* 尝试:
与--stacktrace选项获取堆栈跟踪运行。与--info或--debug选项运行,以获得更多的日志输出。

构建失败

总时间:0.306秒
 

根级别build.gradle:

  //顶级构建文件,你可以到各子项目/模块添加常用的配置选项。

buildscript {
    库{
        mavenCentral()
    }
    依赖{
        com.android.tools.build:gradle:0.8.+
    }
}

allprojects {
    库{
        mavenCentral()
    }
}
 

解决方案

使用Android SDK管理器首先下载最新版本的工具19.0.0和19.0.1。

那么就改变buildToolsVersion17.0.0中indside你的 build.gradle 文件

  buildToolsVersion19.0.0
 

由于中提到的发行文件摇篮1.10和Android 0.8的插件需要buildTools 19.0.0 +

另外,还要确保你的根目录的项目级别 build.gradle 文件有摇篮的插件0.8作为类路径是这样

 类路径com.android.tools.build:gradle:0.8.+
 

This is my problem:

since I have updated Android Studio to .4.3 everytime I try to make a new project I get some Build failure, the thing happens with each and every new project, no code of my own there...

Let's take a look:

Android code:

package com.appgcm;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);
        return rootView;
    }
}

}

Build.gradle

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "17.0.0"

defaultConfig {
    minSdkVersion 7
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard rules.txt'
    }
}
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}

Gradle console error:

Executing tasks: [:appgcm:generateDebugSources]

Relying on packaging to define the extension of the main artifact has been deprecated     and is scheduled to be removed in Gradle 2.0
:appgcm:preBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':appgcm:preBuild'.
> Build Tools Revision 19.0.0+ is required.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option     to get more log output.

BUILD FAILED

Total time: 3.265 secs

Ok, I think that is enough information to take something out, I'm still not really expert with gradle, so the detailed your explanations the better.

Thanks a lot!

EDIT:

I took advice from pyus13 and now i'm gatting another sort of error, here it is:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\pandolet\workspace\APPGCM\appgcm\build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':appgcm'.
> Plugin with id 'android' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.306 secs

Root level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        'com.android.tools.build:gradle:0.8.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

解决方案

First download latest Build Tools 19.0.0 and 19.0.1 using your Android SDK Manager.

Then do change buildToolsVersion "17.0.0" in to indside your build.gradle file

buildToolsVersion "19.0.0"

Because as mentioned in release documents Gradle 1.10 and android plugin 0.8 requires buildTools 19.0.0+

Also make sure your root project level build.gradle file has gradle plugin 0.8 as classpath like this

    classpath 'com.android.tools.build:gradle:0.8.+'

这篇关于入门构建失败,出现异常的Andr​​oid工作室0.4.3和0.4.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆