2016-07-24 32 views
1

這是的build.gradle文件的ARToolKit buildToolsVersion

apply plugin: 'com.android.application' 

    model { 
     android { 
      compileSdkVersion = 23 
      buildToolsVersion = "23.0.3" 

      defaultConfig.with { 
       applicationId = "org.artoolkit.ar.samples.ARSimpleNativeCars" 
       minSdkVersion.apiLevel = 15 
       targetSdkVersion.apiLevel = 22 
       versionCode = 1 
       versionName = "1.0.2" 
       buildConfigFields.with { 
        create() {   
         type = "int"  
         name = "VALUE" 
         value = "1"  
        } 
       } 

       ndk.with { 
        moduleName = "ARSimpleNativeCars" 
       } 
      } 
     } 

     android.buildTypes { 
      release { 
       minifyEnabled = false 
       proguardFiles += file('proguard-rules.pro') 
      } 
     } 

     android.productFlavors { 
     } 

     android.sources { 
      main.jni { 
       source { 
        srcDirs = ['src/main/nop'] 
       } 
      } 
      main.jniLibs { 
       source { 
        srcDirs = ['src/main/libs'] 
       } 
      } 
     } 

     android.compileOptions { 
      sourceCompatibility JavaVersion.VERSION_1_7 
      targetCompatibility JavaVersion.VERSION_1_7 
     } 
    } 

    dependencies { 
     //compile 'com.android.support:support-v4:23.0.1' 
     //compile 'com.android.support:appcompat-v7:23.0.1' 
     compile project(':aRBaseLib') 
    } 

這是最高級別的build.gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
buildscript { 
    repositories { 
     jcenter() 
    } 

    dependencies { 

     repositories { 
      mavenCentral() 
     } 
     classpath 'com.android.tools.build:gradle:2.1.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 
allprojects { 
    repositories { 
     jcenter() 
    } 
} 

這是我試圖運行 的ARToolkit樣本Android項目每當我嘗試運行這個項目時,都會說

Gradle 'ARSimpleNativeCarsProj' project refresh failed 

Error: Cause: buildToolsVersion is not specified. 

apply plugin: 'com.android.application' <---- in this line it is actually 

apply plugin: 'com.android.model.application' which if I kept it keep saying 
failed to find plugin com.android.model.application 

b如果我從插件部分刪除模型 它說沒有指定buildToolsVersion。

Thanx尋求幫助提前...

回答

1

首先你需要保持模型。該模型引用了支持Android Studio中的本機代碼的新實驗gradle插件。有關更多詳細信息,請參閱此處: http://tools.android.com/tech-docs/new-build-system/gradle-experimental

如果您刪除該模型,則無法找到buildToolsVersion,因爲舊的(當前)gradle版本在DSL中沒有「模型」。因此,您需要從gradle.build文件中刪除完整的「model {...}」部分。但是你需要這個,否則你不能建立這個項目。 (所以這只是一個側面說明)

而且你的頂層文件的Gradle其實應該是這樣的

buildscript { 
    repositories { 
     jcenter() 
    } 

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

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 
    } 
} 

我不知道爲什麼你有你的另一版本的Gradle。

除此之外請給這個文件讀取到使用本機C/C++代碼和NDK開始使用Android開發: http://artoolkit.org/documentation/doku.php?id=4_Android:android_native

讓我知道,如果這有助於