Android的工作室输血 [英] Android Studio with Transfuse

查看:212
本文介绍了Android的工作室输血的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以成功地建立了输血在我的Andr​​oid项目,但是当涉及到​​运行采用Android Studio中的应用程序,它失败。大概是因为清单XML已经是空的输血照顾。

I can successfully set up Transfuse in my android project but when it comes to running the app using Android Studio, it fails. Probably because the Manifest xml has to be empty for Transfuse to take care of.

有没有人有这种合作?

推荐答案

输血和Android Studio的工作非常好起来。关键是要得到输血集成摇篮。一旦你得到工作的摇篮,该版本将刚刚揭开序幕注解处理器并运行输血。

Transfuse and Android Studio work remarkably well together. The trick is to get Transfuse integrated with Gradle. Once you get Gradle working, the build will just kick off the annotation processor and run Transfuse.

我已经把一个例子参考项目位置:的https:// github上.COM / johncarl81 /输血/树/主/例子/摇篮

I've put together an example reference project here: https://github.com/johncarl81/transfuse/tree/master/examples/gradle

下面是步骤那里:

  1. 让机器人工作室生成一个新的Andr​​oid项目
  2. 将AndroidManifest.xml文件到Android项目,即根目录:     〜/项目/ src目录/主/ AndroidManifest.xml中 - >〜/项目/ AndroidManifest.xml中

  1. Have Android Studio generate a new Android project
  2. Move the AndroidManifest.xml file to the root of the Android project, ie: ~/project/src/main/AndroidManifest.xml -> ~/project/AndroidManifest.xml

设置新的Andr​​oidManifest.xml中的位置,在gradle.build文件:

Setup the new AndroidManifest.xml location in the gradle.build file:

android {
    ...
    sourceSets.main {
        manifest.srcFile 'AndroidManifest.xml'
    }
}

  • 添加APT插件:

  • Add the APT plugin:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.1'
            classpath 'com.android.tools.build:gradle:0.6.+'
        }
    }
    apply plugin: 'android'
    apply plugin: 'android-apt'
    

  • 最后补充转熔和输血-API:

  • Finally add transfuse and transfuse-api:

    dependencies {
        apt 'org.androidtransfuse:transfuse:0.2.7'
        compile 'org.androidtransfuse:transfuse-api:0.2.7'
    }
    

  • 您最后gradle.build将是这样的:

    Your final gradle.build will look like this:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.1'
            classpath 'com.android.tools.build:gradle:0.6.+'
        }
    }
    apply plugin: 'android'
    apply plugin: 'android-apt'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        apt 'org.androidtransfuse:transfuse:0.2.7'
        compile 'org.androidtransfuse:transfuse-api:0.2.7'
    }
    
    android {
        compileSdkVersion 19
        buildToolsVersion "19.0.0"
    
        defaultConfig {
            minSdkVersion 7
            targetSdkVersion 19
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_6
            targetCompatibility JavaVersion.VERSION_1_6
        }
        sourceSets.main {
            manifest.srcFile 'AndroidManifest.xml'
        }
    }
    

    编辑:

    最后,你可能要下添加项目配置的源/ apt_generated /调试或源/ apt_generated /释放文件夹作为源文件夹。

    Finally you probably want to add the source/apt_generated/debug or source/apt_generated/release folders as source folders under the project configuration.

    第二个编辑:

    我更新了上面的例子中使用新的Andr​​oid APT插件

    I updated the above example with the new Android-APT plugin

    这篇关于Android的工作室输血的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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