Gradle DSL method not found: 'applicationId()' - android

I am getting this error on building the application in Android Studio.
Gradle DSL method not found: 'applicationId()'
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
applicationId "com.ms.knowursensor.android"
minSdkVersion 13
defaultConfig {
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "sensorgraph"
stl "c++_static"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk {
debuggable = true
}
}
debug {
debuggable true
jniDebuggable true
}
}
sourceSets {
main {
jniLibs.srcDir 'src/main/jniLibs'
// use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
This issue came when i recently update the SDK. How to resolve this issue?

Move applicationId and minSdkVersion into your defaultConfig closure.

Related

Room Persistence inside of Lib

I am looking for a good way to import Room Persistence inside of my Lib to export .aar . I have the following issue that .aar cannot handle dependencies.
When I export my arr and import into another project as lib, it seems as it has no scope to room.
my lib Gradle file :
apply plugin: 'com.android.library'
apply plugin: 'maven'
archivesBaseName = '*****'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 5
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Write out the current schema of Room
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
deployerJars
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'android.arch.persistence.room:runtime:1.1.0-beta3'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.0-beta3'
}
Thanks.

gradle dsl method not found: ' armv7a'

my build.grandle code is this one:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.assus.appweather"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName = "odroid_weather"
abiFilter "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDirs 'main/src/libs'
}
}
productFlavors{
x86 {
ndk {
abiFilter "x86"
}
armv7a{
ndk {
abiFilter "armeabi-v7a"
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
and when I build my project, always this error is shown :
gradle dsl method not found: ' armv7a'
Gradle sync failed: Gradle DSL method not found: 'armv7a()'
Consult IDE log for more details (Help | Show Log)
some one can help me please !
Perhaps you meant to have a productFlavors that looks like this instead (it looks like you missing a closing brace):
productFlavors{
x86 {
ndk {
abiFilter "x86"
}
}
armv7a {
ndk {
abiFilter "armeabi-v7a"
}
}
}

Plugin not found when importing project as library in Android Studio

I am trying to integrate an application to another one. To do that I compiled the first one as a library and after that I added it to the dependencies of the application project after I added it as a module following some guides in stackoverflow.
The problem is that after doing that, I got an error about a missing plugin. Although I have researched a bit over google I have had no luck on that one.
The error is Error:(4, 0) Plugin with id 'com.google.protobuf' not found.
Open File
Both applications work very well, each on their own... What am I doing wrong ?
Here is my build graddle of the main app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.arlind.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
Here is the build graddle of the added library
import java.text.SimpleDateFormat
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
}
}
android {
signingConfigs {
global {
keyAlias "Lind"
keyPassword "gators"
storeFile file("lindkey.keystore")
storePassword "gators"
}
}
compileSdkVersion 22
buildToolsVersion "23.0.0"
android {
lintOptions {
abortOnError false
}
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.global
}
}
productFlavors {
catapult {
versionCode getLongDate().toInteger()
versionName '12.1-' + getShortDate()
}
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '18.0'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile project(path: ':wallpaperPicker')
}
sourceSets {
main {
manifest.srcFile '../AndroidManifest.xml'
java.srcDirs = ['../src', '../util', '../extra/src']
res.srcDirs = ['../res', '../extra/res']
proto {
srcDir '../protos'
}
}
}
}
def getDate(String dateFormat) {
def df = new SimpleDateFormat(dateFormat)
Calendar c = Calendar.getInstance();
TimeZone tz = c.getTimeZone();
df.setTimeZone(tz)
return df.format(new Date())
}
def getLongDate() {
return getDate("yyMMddHH")
}
def getShortDate() {
return getDate("yyMMdd")
}

Android Studio 1.3 gradle plugin returns error when defining jni and jniLibs in Source sets

Could not find property jni and source set 'main'
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 21
buildToolsVersion = "22.0.1"
defaultConfig.with {
applicationId = "com.example.native_activity"
minSdkVersion.apiLevel = 9
targetSdkVersion.apiLevel = 9
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir = 'src/main/libs'
// This is not necessary unless you have precompiled libraries in your project.
}
}
Here is the stacktrace:
Caused by: org.gradle.model.internal.core.ModelRuleExecutionException: Exception thrown while executing model rule: model.android
at org.gradle.model.internal.registry.DefaultModelRegistry.fireMutation(DefaultModelRegistry.java:485)
at org.gradle.model.internal.registry.DefaultModelRegistry.access$1500(DefaultModelRegistry.java:45)
at org.gradle.model.internal.registry.DefaultModelRegistry$RunModelAction.apply(DefaultModelRegistry.java:1464)
at org.gradle.model.internal.registry.DefaultModelRegistry.transitionTo(DefaultModelRegistry.java:341)
at org.gradle.model.internal.registry.DefaultModelRegistry.transition(DefaultModelRegistry.java:419)
at org.gradle.model.internal.registry.DefaultModelRegistry.atStateOrMaybeLater(DefaultModelRegistry.java:183)
at org.gradle.model.internal.registry.DefaultModelRegistry.atStateOrLater(DefaultModelRegistry.java:175)
at org.gradle.execution.TaskNameResolver.selfClose(TaskNameResolver.java:101)
at org.gradle.execution.TaskNameResolver.selfClosedTasksNode(TaskNameResolver.java:114)
... 60 more
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method main() for arguments [build_f1cmjkxjjzysskbrs6852ixyj$_run_closure1_closure2_closure7#8c09fa7] on SourceSet container.
I googled like mad for the last 2 hours...
As Awanish said - read the Experimental Plugin User Guide step by step VERY carefully. For even more clearance check the build.gradle files in the ndk-samples provided by google.
sourceSets.main { } has different syntax and should be outside the android { } block. In your case it should look something like this:
model {
android {
//...
}
android.sources {
main {
jniLibs {
source {
srcDirs 'libs'
}
}
}
}
}
In my case it was an exact opposite to tochkov answer:
This syntax - with the jniLibs outside android block - gave me an error:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.myproject"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
and this syntax - inside android block - fixed it:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.myproject"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
}
It seems like you are trying to use the grade experimental plugin!
Make sure you have grade-2.5 in your gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
and this in your project's build.gradle dependencies tag
classpath 'com.android.tools.build:gradle-experimental:0.1.0'
Instead of guessing a lot of things, let me redirect you to the user guide, where the documentation explains migration from the standard to experimental plugin in detail. Take a look here!
Try these fixes. Post more details if these don't work for you, I will try to help. :)
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.jeremy.test"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles.add(file('proguard-android.txt'))
}
}
ndk {
moduleName "hello-android-jni"
}
}
android.sources.main {
java.source.srcDirs = ["src/main/java", "/Users/jeremy/Repositories/hello/src/android/java"]
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
The above is copied from my experimental ndk project, this works for me.
See the android.sources.main section.

Gradle cannot find target sdk

I need to write a small library with submodules. When i try sync my project i get error.
if i use gradle gradle:1.0.1
Error:Configuration with name 'default' not found.
if build:gradle:1.2.3
Error:Cause: failed to find target 21
but this sdk already installed.
Here is my build.gradle
uildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':libs:UniversalImageLoader')
}
project(':libs:UniversalImageLoader') {
apply plugin: 'com.android.library'
android.compileSdkVersion = 21
android.buildToolsVersion = "21.1.2"
android.sourceSets.main {
manifest.srcFile 'library/AndroidManifest.xml'
java.srcDirs = ['library/src']
res.srcDirs = ['library/res']
}
}
Any ideas on this subject? Thx for help.

Categories

Resources