I am new at developing android.I use Android Studio.I am getting an error Gradle DSL method not found:'android()'.Then I googled the error.Someone says that Android Studio incorrectly adds the android() method in the top-level build.gradle file. and delete the method.After I deleted android() from build.gradle.I am getting a new error Install Build Tools 23.0.0 rc2 and sync project.I am so tired with.
How can I overcome it.
I can see you don't have the right Android plugin in your gradle file, it should be:
apply plugin: 'com.android.application'
Besides, you need the android extension to be something like:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.your.package.id"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Also, I think you are not editing the right Gradle file. You have a "general" build.gradle, which you should not edit generally, and your module build.gradle (typically in your app folder), where all these things need to be.
This is very similar to what you obtain by default when you create a new Android project.
After upgrading android studio, I always clean it by manually removing the build/ and app/build/ folders, and by building the project again.
Also: File -> Invalidate Caches / Restart -> Invalidate and Restart
Related
I am doing a project on Beaglebone Black and i have ported Android KitKat on it. Now i need an android app that could help me access those gpios on beaglebone for a project.
So i am using android studio 1.3.1 to create my application for my project and so to access the hardware pins via android i have to use NDK for it. Now when i am trying to sync gradle 2.2.1 with my NDK files it prints an error that i should set android.useDeprecatedNdk=true. Now when i do that it again shows the error that DeprecatedNdk() is not defined.
Although i have downloaded the latest version of NDK i.e. android-ndk-r10e from android developers website but the error still persists.
Following is the build.gradle file from the module.
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.packt.gpio"
minSdkVersion 19
targetSdkVersion 19
ndk {
moduleName "packtHAL"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.+'
}
Also the error that it is showing is:
Error:(14, 0) Error: NDK integration is deprecated in the current plugin.
Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.
And if i add the property to the file then it shows the following error:
Error:(6, 0) Gradle DSL method not found: 'useDeprecatedNdk()'
Possible causes:The project 'gpio' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
If anyone has any idea as to what should be done regarding this. Please share your ideas.
Thank you
Please check the new documentation: http://tools.android.com/tech-docs/android-ndk-preview
Here are the latest project setup instructions: http://tools.android.com/tech-docs/new-build-system/gradle-experimental
This just popped up too: http://ph0b.com/new-android-studio-ndk-support/
I'm having some strange issue with Android Studio recently. I'm trying to build a project after few modification in code. But the APK got installed is of old code. (I found this by debugging. When I debugged it was going to empty lines) But all my latest code are saved and it's there. I have tried the following steps which I know.
Delete the build folders of Project and Module manually > Restart Studio > Clean Project > Rebuild Project
Restart Android Studio and (I don't know why I restarted but I did that too)
Invalidate and Cache Restart
At some point I found a issue in XML related to style attribute for button which was like style:attr/buttonBarButtonStyle I later corrected to style:"?android:attr/buttonBarButtonStyle"I hope this change is correct because it don't show any more error.
And finally it doesn't give me any error in stacktrace. Project always shows BUILD SUCCESSFUL
Nothing above helped me.
EDIT 1 : I have updated my Android Support Library to 22.1.1 latest version which released a couple of days ago
EDIT 2 : I uninstalled Android Studio. Deleted Android Studio related folders in C:\Program Files\Android\Android Studio and also deleted C:\Users\MyUserName\.android & .AndroidStudio & .gradle folders. And did fresh install of Android Studio. Later I imported a same project and build it. Again it happens in same way! I have also tried running the same project in other lap and it runs without any problem. I Don't know what else I'm missing here
EDIT 3 : Updating my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
signingConfigs {
debug {
storeFile file("./debugkeystore/MyAppDebug.keystore")
}
}
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
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:22.0.0'
compile 'com.google.android.gms:play-services:6.1.+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:support-v4:22.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
}
I just again uninstalled AndroidStudio and clear the registery and made it like a fresh install for the 3rd time and I don't know how but this time it worked! But didn't get what exactly happened!
I solved it by rebuilding the project. Go to the build tab
you should configure Run/Debug Configuration again and add to "Before launch" section "Gradle-aware Make"
that's it
This is not a migrated project.
I've made a small project in android studio 1.0.2 with all the default settings. It was working well until I encountered a weird problem. It recently just fell apart - literally, nothing works and I don't even know what to look at for the issue.
Background
I had a strange problem with v21/something.xml where graddle cmplained about syntax error (it was complaining about lack of /. I saw it looks different ten other similar lines and corrected it to look like the others, but something (gradle script creator?) chaged it back to the form with syntax error.
Problem
I've found that similar issue is related to wrong sdk version, I've tried changing minSdkVersion to 21 (from 11) and updated gradle to see red marks pretty much everywhere.
THe puzzling thing is, that when I looked into the event log I saw this:
12:28:43 AssertionError: Already disposed: Module: 'app': Already disposed: Module: 'app'
12:28:43 All files are up-to-date
12:30:55 Project Sync
The project 'Yamba' is not a Gradle-based project
More Information about migrating to Gradle
Clearly the project stopped being a grale one - What a Terrible Failure...
In the project tree, the .idea directory is red and everything within it plus local.properties
All .java files have a red mark on them.
When I try to run the project, it opens edit configuration dialog and there is no module specified.
How can I find the error source, and more importantly how to fix it? I can upload any code you need - just tell me what is relevant here, as there are too many files to put them all and keep it readable.
the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.asteroth.yamba"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
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'
}
EDIT:
I've made a new project under the same name, copied all the files over to it and it builds - something caused corruption in the actual project. I'll try to reproduce it
I want to build an app in Android Studio with the support library but I get the following error when adding the dependency for the support library:
Error:Failed to find: com.android.support:support-v4:19.1.0
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
applicationId "sample.myapplication"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.1.0'
}
I have downloaded the support library via the sdk manager.
Ok, found the problem. The Android support repository was missing. After installing and restarting Android Studio it worked.
If you are using Android Studio, then as an addition to changing the build.gradle file manually, you can also lookup the dependency via the library dependencies under the Project Structure menu item.
Double clicking that dependency will generate this line in build.gradle:
dependencies {
compile 'com.android.support:support-v13:+'
}
And also, if you are wondering what this library is about, it's described at the developer pages at developer.android.com; Support Library.
My Android Studio version is 1.1. I select tools->Android->SDK Manager, check the Android Support Library then click Install packages, solved this issue.
In my case the solution was as simple as running Build:Make Project. No amount of gradle syncing or clearing caches would do it. Of course, that required getting my project into a state where it would build successfully.
In my case I needed to add Google Maven repository.
It shows as part of the error in Android Studio and only needed to click on it to add itself.
Then Gradle built the project on its own.
Following the instruction here helped me. For whatever reason when I had to reinstall the latest version of android studio the initial download of the extras section android support library failed. I simply retried it. Followed the steps mentioned and verified it was added to the build.gradle file and did a rebuild project and good to go.
http://developer.android.com/tools/support-library/setup.html
I am going to start develop application for fire TV i can create an application using Eclipse successfully, But when i try the same procedure to create new application which compile with Firetv SDK got some Gradle error on android studio.. i am stuck with this issues for around one week.
The error is Gradle app neame project refresh failed:
Unexpected lock protocol found in lock file. Expected 3, found 0.
Gradle settings
I searched lot about this error in google but cant get any solution
Sorry for my bad English.
My even log says:
Gradle 'Test' project refresh failed:
Unexpected lock protocol found in lock file. Expected 3, found 0.
Gradle settings
My build gradle
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
My case, delete ~/.gradle/ and suddenly all working well again.
good luck!
Invalidate Caches And Restart Also Works. Try It Out By Going
To File and selecting Invalidate caches and restart
Just go to Android Studio -> File -> Close project. After closing the project,reopen it afresh. This solved the problem for me.
I couldn't understand about ~/.gradle/ folder... but now I got it
and solved! delete here folder!