2016-09-20 98 views
-1

我採用了android 2.1.3工作室從 Create Hello-JNI with Android Studio搖籃的Dsl方法未找到:機器人()的Android 2.1.3工作室

以下指導是同時編譯輸出。

Error:(3, 0) Gradle DSL method not found: 'android()' Possible causes:

  • The project 'FirstDemo' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Fix plugin version and sync project
  • The project 'FirstDemo' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • 的build.gradle(模塊):

    apply plugin: 'com.android.model.application' 
    android { 
        compileSdkVersion 23 
        buildToolsVersion "23.0.1" 
        defaultConfig { 
         applicationId "com.example.sprinkle.firstdemo" 
         minSdkVersion 22 
         targetSdkVersion 23 
         versionCode 1 
         versionName "1.0" 
        } 
        buildTypes { 
         release { 
          minifyEnabled false 
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
         } 
        } 
    } 
    

    buil.gradle(頂部)

    // Top-level build file where you can add configuration options common to all sub-projects/modules. 
    
    buildscript { 
        repositories { 
         jcenter() 
        } 
        dependencies { 
         classpath 'com.android.tools.build:gradle-experimental:0.7.2' 
    
         // NOTE: Do not place your application dependencies here; they belong 
         // in the individual module build.gradle files 
        } 
    } 
    
    allprojects { 
        repositories { 
         jcenter() 
        } 
    } 
    
    //task clean(type: Delete) { 
    // delete rootProject.buildDir 
    //} 
    
    +0

    機器人{}是應該被包裹在模型{}。它在教程中。 –

    +0

    嗨我試着用相同的我得到錯誤org.gradle.api.internal.ExtensibleDynamicObject – Nilesh

    +0

    因此試圖刪除模型 – Nilesh

    回答

    0

    其工作

    更改

    proguardFiles getDefaultProguardFile('proguard的-androi d.txt'), 'proguard-rules.pro'

    TO

    proguardFiles.add(file('proguard-android.txt')) 
    proguardFiles.add(file('proguard-rules.txt')) 
    
    +0

    Proguard-android.txt位於sdk目錄中,而不是在您的項目目錄中。你確定這些規則實際上是否適用? –

    +0

    它爲我工作,編譯成功,沒有任何警告/錯誤在android studio 2.1.3 – Nilesh

    +0

    當然,它編譯,這不是問題。你嘗試運行釋放APK嗎? –

    相關問題