shj*_*shj 6 android android-ndk gradle-experimental
我正在尝试使用NDK构建项目.但是Gradle构建会出错.
这是我的build.gradle(主项目)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// classpath 'com.android.tools.build:gradle-experimental:0.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用这个gradle时:1.5.0它给出了错误'错误:(17,0)插件,id'com.android.model.application'找不到.
另一方面,如果我使用gradle-experimental:0.1.0则会出现错误'错误:(17,0)插件,但未找到id"com.android.application".
我该如何解决这个错误?我的项目中有几个模块.如何设置满足所有模块的gradle?
编辑:
build.gradle(主项目)
buildscript {
repositories {
jcenter()
}
dependencies {
// classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle-experimental:0.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
def isReleaseBuild() {
return isTag() && !isSnapshot()
}
def isSnapshot() {
return version.contains("SNAPSHOT")
}
boolean isTravis() {
return System.getenv('TRAVIS_BUILD_NUMBER') ? true : false
}
boolean isTag() {
def tag = System.getenv('TRAVIS_TAG')
return !(tag == null || tag.isEmpty())
}
def buildNumber() {
return System.getenv('TRAVIS_BUILD_NUMBER') ?: "0"
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle(APP)
apply plugin: 'com.android.model.application'
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url "https://oss.sonatype.org/content/repositories/releases"
}
maven {
url "https://oss.sonatype.org/content/repositories/staging"
}
}
model {
android {
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
defaultConfig.with {
applicationId = "com.ToxicBakery.viewpager.transforms"
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.lintOptions {
checkReleaseBuilds = false
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'info.hoang8f:fbutton:1.0.5'
compile project(':contextMenu')
compile project(':library')
compile project(':library2')
compile project(':titanic')
compile files('libs/universal-image-loader-1.9.4.jar')
compile project(':staggeredview')
compile project(':min3d')
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle(文本菜单)
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 21
buildToolsVersion = "21.1.2"
defaultConfig.with {
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 21
}
}
android.lintOptions {
checkReleaseBuilds = false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.nineoldandroids:library:2.4.0'
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle(库)
apply plugin: 'com.android.model.library'
apply plugin: 'signing'
model {
android {
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
defaultConfig.with {
minSdkVersion.apiLevel = 13
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.lintOptions {
checkReleaseBuilds = false
}
}
dependencies {
compile 'com.android.support:support-v13:22.1.1'
}
apply from: '../maven_push.gradle'
Run Code Online (Sandbox Code Playgroud)
的build.gradle(library2)
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
defaultConfig.with {
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.lintOptions {
checkReleaseBuilds = false
}
}
dependencies {
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle(min3d)
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 15
buildToolsVersion = "21.0.2"
defaultConfig.with {
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
debug {
}
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
}
android.lintOptions {
checkReleaseBuilds = false
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.0'
compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle(staggerdview)
apply plugin: 'com.android.model.library'
dependencies {
compile 'com.android.support:support-v4:19.1.+'
}
model {
android {
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
defaultConfig.with {
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.lintOptions {
checkReleaseBuilds = false
}
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle(泰坦尼克号)
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 22
buildToolsVersion = '22.0.1'
defaultConfig.with {
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 19
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes{
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.lintOptions {
checkReleaseBuilds = false
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)
您应该使用实验性插件进行NDK目的:
所以你的build.gradle(主项目)将如下所示:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.4.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
和build.gradle(app)看起来像:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "com.sample.codecator"
minSdkVersion.apiLevel = 19
targetSdkVersion.apiLevel = 19
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是任何库模块,那么build.gradle它将如下所示:
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
minSdkVersion.apiLevel = 19
targetSdkVersion.apiLevel = 19
}
}
}
Run Code Online (Sandbox Code Playgroud)
您应该将以下内容排除在外android{...}:
android.buildTypes
android.sources
android.productFlavors
Run Code Online (Sandbox Code Playgroud)
喜欢:
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
minSdkVersion.apiLevel = 19
targetSdkVersion.apiLevel = 19
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file("proguard-rules.pro"))
}
}
android.productFlavors {
//
}
android.sources {
//
}
}
Run Code Online (Sandbox Code Playgroud)
不要忘记ndk.dir=ndk_path在您的local.properties文件中设置.
UPDATE
更新android.buildTypes所有文件中的代码,如下所示:
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file("proguard-rules.pro"))
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9239 次 |
| 最近记录: |