简体   繁体   English

实验gradle问题:android插件必须应用于项目

[英]Issue with experimental gradle: The android plugin must be applied to the project

I'm trying to run some native code with the NDK in Android Studio. 我正在尝试使用Android Studio中的NDK运行一些本机代码。 I have followed the steps shown HERE to use the experimental Gradle, but obviously it's not all going smoothly. 我已按照此处显示的步骤使用实验Gradle,但显然并非一切顺利。 I'm getting this error: The android or android-library plugin must be applied to the project 我收到此错误: The android or android-library plugin must be applied to the project
Here is my gradle file: 这是我的gradle文件:

apply plugin: 'com.android.model.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'io.fabric'

model {
    android {
        compileSdkVersion = 22
        buildToolsVersion = "22.0.1"

        android.ndk {
            moduleName = "test"
        }

        defaultConfig.with {
            applicationId = "com.shaperstudio.dartboard"
            minSdkVersion.apiLevel = 15
            targetSdkVersion.apiLevel = 22
            versionCode = 1
            versionName = "1.0"
        }
    }
    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles += file('proguard-rules.pro')
        }
    }
    packagingOptions {
        exclude = 'META-INF/services/javax.annotation.processing.Processor'
    }
}

    repositories {
        maven {
            url "https://jitpack.io"
        }
        maven { url 'https://maven.fabric.io/public' }
    }

    buildscript {
        repositories {
            jcenter()
            maven { url 'https://maven.fabric.io/public' }
        }
        dependencies {
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.0'
        compile 'com.android.support:recyclerview-v7:22.2.0'
        compile 'com.android.support:design:22.2.0'
        compile 'com.jakewharton:butterknife:6.1.0'
        compile 'de.greenrobot:eventbus:2.4.0'
        apt 'com.bluelinelabs:logansquare-compiler:1.1.0'
        compile 'com.bluelinelabs:logansquare:1.1.0'
        compile 'com.birbit:android-priority-jobqueue:1.3'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.facebook.android:facebook-android-sdk:4.1.0'
        compile 'com.parse.bolts:bolts-android:1.+'
        compile fileTree(dir: 'libs', include: '*.jar')
        compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
            transitive = true;
        }
    }

Any help as to why I'm getting this error would be appreciated 任何帮助,为什么我得到这个错误将不胜感激

Try to use this plugin 尝试使用此插件

https://bitbucket.org/pvoid/android-apt-experemental/overview https://bitbucket.org/pvoid/android-apt-experemental/overview

instead of android-apt 而不是android-apt

I faced with this problem to some weeks ago. 几周前我遇到了这个问题。 The com.neenbedankt.android-apt plugin require android or android-library plugin. com.neenbedankt.android-apt插件需要android或android-library插件。

I wrote a letter to apt plugin author https://bitbucket.org/hvisser/android-apt . 我给apt插件作者https://bitbucket.org/hvisser/android-apt写了一封信。

Hello! 你好! Google announced android studio preview 1.3 with jni support few days ago. 谷歌几天前宣布推出jni支持的android studio预览版1.3。 For this purpose they use plugin com.android.model.application (classpath "com.android.tools.build:gradle-experimental:0.1.0"). 为此,他们使用插件com.android.model.application(classpath“com.android.tools.build:gradle-experimental:0.1.0”)。 It is not compatible with your plugin. 它与您的插件不兼容。 I tried to do my own fork, but I am not good in plugin development. 我试着做自己的分叉,但我不擅长插件开发。 Are you going to support new plugin? 你打算支持新的插件吗?

Answer. 回答。

Not in the short term, since the required hooks are still missing and it looks like it would be a rewrite since a lot has changed. 不是在短期内,因为所需的钩子仍然缺失,看起来它将是一个重写,因为很多已经改变。 You should be able to create a separate module for NDK stuff using the experimental plugin, and another for all other Android stuff using the stable plugin. 您应该能够使用实验插件为NDK创建单独的模块,并使用stable插件为所有其他Android内容创建另一个模块。

I also tried to make my own fork of android-apt, but I am not a gradle guru, and I have not enough time. 我也尝试自己创建android-apt的分支,但我不是一个gradle guru,我没有足够的时间。

So you should create separate module only for NDK (for example to compute something). 所以你应该只为NDK创建单独的模块(例如计算某些东西)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM