简体   繁体   English

Android Studio 2.0使用gradle-experimental插件打破ndk构建

[英]Android Studio 2.0 breaks ndk build with gradle-experimental plugin

After updating Android Studio to version 2.0 (stable), the Gradle sync for my project is broken. 将Android Studio更新到2.0版(稳定版)后,我的项目的Gradle同步已中断。

Error popup: 错误弹出:

Android Gradle Plugin Update Required

The project is using an incompatible version of the Android Gradle plugin.

To configure the project, the IDE will update the Android Gradle Plugin to version 2.0.0.

You can learn more about this version of the plugin from this [release notes][1].

-> Update   -> Cancel and update manually

Gradle Sync Issue (in the messages view): Gradle Sync问题(在消息视图中):

Error:The project is using an incompatible version of the Android Gradle plugin.
Please update your project to use version 2.0.0.
-> Search in build.gradle files

I'm using the gradle-experimental plugin ( classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha5' ) for the ndk build as it has been recommended, eg here , thus my build.gradle looks like this (with the com.android.model.application plugin) and I cannot simply 'update' to classpath 'com.android.tools.build:gradle:2.0.0' : 我正在使用gradle-experimental插件( classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha5' gradle-experimental:0.6.0-alpha5 classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha5' )来推荐ndk,例如这里 ,因此我的build.gradle看起来很像像这样(使用com.android.model.application插件)我不能简单地'更新'到classpath 'com.android.tools.build:gradle:2.0.0'classpath 'com.android.tools.build:gradle:2.0.0'

apply plugin: 'com.android.model.application'

def superpowered_path = file('.').absolutePath + "/src/main/jni/Superpowered"

model {

    repositories {
        libs(PrebuiltLibraries) {
            superpowered {
                headers.srcDir "${superpowered_path}"
                binaries.withType(StaticLibraryBinary) {
                    staticLibraryFile = file("${superpowered_path}/lib/${targetPlatform.getName()}/libSuperpoweredAndroid.a")
                }
            }
        }
    }

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.3"

        defaultConfig {
            applicationId "APPID"
            minSdkVersion.apiLevel 15
            targetSdkVersion.apiLevel 23
            versionCode 1
            versionName "1.0"

            archivesBaseName = "APPNAME-$versionCode-$versionName"

            renderscriptTargetApi 20
            renderscriptSupportModeEnabled true
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles.add(file('proguard-rules.pro'))
                signingConfig = $("android.signingConfigs.releaseSigning")
            }
            debug {
                applicationIdSuffix ".debug"
                versionNameSuffix "-DEBUG"
                signingConfig = $("android.signingConfigs.debugSigning")
            }
        }

        sources {
            main {
                jni {
                    dependencies {
                        library "superpowered" linkage "static"
                    }
                }
            }
        }

        /*
         * native build settings
         */
        ndk {
            moduleName = "NDKMODULE-jni"
            cppFlags.add("-std=c++11")
            ldLibs.addAll(["android", "log", "OpenSLES"])
            abiFilters.addAll(["armeabi-v7a", "x86", "arm64-v8a"])
        }
    }

    android.signingConfigs {
        create("releaseSigning") {
            keyAlias 'release'
            keyPassword 'PASSWORD'
            storeFile file('KEYSTORE.jks')
            storePassword 'PASSWORD'
            storeType "jks"
        }
        create("debugSigning") {
            keyAlias 'debug'
            keyPassword 'PASSWORD'
            storeFile file('KEYSTORE.jks')
            storePassword 'PASSWORD'
            storeType "jks"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar', '*.a'])
    testCompile 'junit:junit:4.12'

    // Android support libs
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.android.support:support-v4:23.2.1'
    compile 'com.android.support:recyclerview-v7:23.2.1'

    // Android Async Http
    // Apache 2.0 http://loopj.com/android-async-http/
    compile 'com.loopj.android:android-async-http:1.4.9'

    // OkHttp http://square.github.io/okhttp/
    // Apache v2
    compile 'com.squareup.okhttp3:okhttp:3.2.0'

    // Picasso http://square.github.io/picasso/
    // Apache v2
    compile 'com.squareup.picasso:picasso:2.5.2'

    // Retrofit http://square.github.io/retrofit/
    // Apache v2
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
}

All I could find on issues with Android Studio 2.0 was about the canary / beta builds and seems to have different problems than this one. 我在Android Studio 2.0问题上找到的所有内容都是关于canary / beta版本的,并且似乎与此问题有不同的问题。 Before the update, the Gradle sync worked as expected. 在更新之前,Gradle同步按预期工作。 (I've been using the last stable build, 1.5.1 I think?). (我一直在使用最后一个稳定的版本,1.5.1我认为?)。

I'm hoping for some ideas on how to use the ndk with Android Studio 2.0. 我希望有关于如何在Android Studio 2.0中使用ndk的一些想法。

使用gradle-experimental:0.7.0-alpha1为我修复了Gradle同步: classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1' :gradle-experimental:0.7.0-alpha1 classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1'

使用以下类路径修复了我的问题。

classpath 'com.android.tools.build:gradle-experimental:0.7.0'

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

相关问题 带有gradle-experimental:0.6.0-alpha6的Android Studio 2.0 Preview 5中的Android NDK - Android NDK in Android studio 2.0 preview 5 with gradle-experimental:0.6.0-alpha6 没有gradle-experimental插件的Android Ndk调试 - Android Ndk debug without gradle-experimental plugin Android Studio 2.2或实验性Gradle插件是否支持NDK? - Android Studio 2.2 or Experimental Gradle Plugin for NDK Support? 如何使用实验性Gradle插件(NDK)在Android Studio中添加openssl lib? - How to add openssl lib in android studio with experimental gradle plugin (NDK)? 使用gradle-experimental签署android apk:0.2.0 - Signing android apk with gradle-experimental:0.2.0 Android gradle-experimental与数据绑定无法正常工作? - Android gradle-experimental with databinding not working? 在Android工作室的NDK与实验gradle 0.2.0 - NDK in Android studio with experimental gradle 0.2.0 Gradle实验包括 - Gradle-experimental includes Android Studio NDK:使用 ndk-build 编译并使用 Gradle Experimental 获得本机支持 - Android Studio NDK: Compile with ndk-build and get native support with Gradle Experimental Gradle 同步失败:找不到 com.android.tools.build:gradle-experimental:3.3.2 - Gradle sync failed: Could not find com.android.tools.build:gradle-experimental:3.3.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM