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

ぐ巨炮叔叔 提交于 2019-12-06 05:15:16

问题


I'm trying to run some native code with the NDK in Android Studio. I have followed the steps shown HERE to use the experimental Gradle, but obviously it's not all going smoothly. I'm getting this error: The android or android-library plugin must be applied to the project
Here is my gradle file:

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


回答1:


I faced with this problem to some weeks ago. The com.neenbedankt.android-apt plugin require android or android-library plugin.

I wrote a letter to apt plugin author https://bitbucket.org/hvisser/android-apt.

Hello! Google announced android studio preview 1.3 with jni support few days ago. For this purpose they use plugin 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.

I also tried to make my own fork of android-apt, but I am not a gradle guru, and I have not enough time.

So you should create separate module only for NDK (for example to compute something).




回答2:


Try to use this plugin

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

instead of android-apt



来源:https://stackoverflow.com/questions/32001570/issue-with-experimental-gradle-the-android-plugin-must-be-applied-to-the-projec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!