I am attempting to run my project in Android Studio but the error appears below:
I have followed many sources just to get this to run and have wound up here, but do not know what else to do.
How can I configure this project to run?
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
settings.gradle:
include ':app'
local.properties:
sdk.dir=C\:\\Users\\KJA\\AppData\\Local\\Android\\sdk
gradle.propertes:
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
I went ahead and downloaded the project from the link you provided: http://javapapers.com/android/android-chat-bubble/
Since this is an old tutorial, you simply need to upgrade the software, gradle, the android build tools and plugin.
Make sure you have the latest Gradle and Android Studio:
https://www.gradle.org/
http://tools.android.com/tech-docs/new-build-system/version-compatibility
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
}
Then run gradle:
gradle installDebug
In your top level build.gradle you seem to have the code
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
You can't have this code at the top level build.gradle because the android build plugin isn't loaded just yet. You can define the compile version and build tools version in the app level build.gradle.
For some unknown reason, Android Studio incorrectly adds the android()
method in the top-level build.gradle file.
Just delete the method and it works for me.
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
}
I have tried to manage this issue via below steps :
Delete android { ... } block in top level root gradle file
Look into
compileSdkVersion 22
buildToolsVersion "22.0.0"
lines of code in app/gradle file here only one of the version persent in below dropdown should be present else it would give provide option to downloaad the same.
I got this same error when I was trying to import an Eclipse NDK project into Android Studio. It turns out, for NDK support in Android Studio, you need to use a new gradle and android plugin (and gradle version 2.5+ for that matter). This plugin, requires changes in the module's build.gradle file. Specifically the "android{...}" object should be inside "model{...}" object like this:
apply plugin: 'com.android.model.application'
model {
android {
....
}
}
So if you have updated your gradle configuration to use the new gradle plugin, and the new android plugin, but didn't change the module's build.gradle syntax, you could get "Gradle DSL method not found: 'android()'" error.
I prepared a patch file here that has some further explanations in the comments:
https://gist.github.com/shumoapp/91d815de6e01f5921d1f
These are the changes I had to do after importing the native-audio ndk project into Android Studio.
Correcting gradle settings is quite difficult. If you don't know much about Gradle it requires you to learn alot. Instead you can do the following:
1) Start a new project in a new folder. Choose the same settings with your project with gradle problem but keep it simple: Choose an empty main activity.
2) Delete all the files in ...\NewProjectName\app\src\main folder
3) Copy all the files in ...\ProjectWithGradleProblem\app\src\main folder to ...\NewProjectName\app\src\main folder.
4) If you are using the Test project (\ProjectWithGradleProblem\app\src\AndroidTest) you can do the same for that too.
this method works fine if your Gradle installation is healthy. If you just installed Android studio and did not modify it, the Gradle installation should be fine.
Actually i tried many combinations nothing worked
but when i modified my application gradle file with following
buildTypes {
release {
minifyEnabled false
}
}
By removing the Line
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
it worked Normally :)) cheers
Another solution if you have installed android-studio-bundle-143.2915827-windows
and gradle2.14
You can verify in
C:\Program Files\Android\Android Studio\gradle if you have gradle-2.14.
Then you must go to
C:\Users\\AndroidStudioProjects\android_app\
And in this build.gradle you put this code:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Then, go to C:\Users\Raul\AndroidStudioProjects\android_app\Desnutricion_infantil\app
And in this build.gradle you put:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
}
You must check your sdk version and the buildTools.
compileSdkVersion 23
buildToolsVersion '24.0.0'
Save all changes and restart AndroidStudio and all should be fine !
Just delete these lines from the root build.gradle
android {
compileSdkVersion 19
buildToolsVersion '19.1' }
Now trying and compile again. It should work.
Change to root build.gradle file
to
// 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:1.5.0'
// 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
}
What worked for me was to import the project with "File -> New -> Project from Version Control" then choose your online source (GitHub for example). This way all the .gradle files were created in the import.
I also meet that problems,and just delete bottom code:
DELETE THESE LINES:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
}
it worked。
This error has occurred when i was importing a project from Github. This happens as the project was of older version. Just try to delete these methods below from your root gradle.
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
then try again.
I hope it works.
Related
I am trying to import an external library into my application, the library is FFmpeg. Here is a link to the module.
I add the library to my libs folder (after downloading it), then from File > New > Import module > select FFmpeg. Now within my apps build gradle I add the line
compile project(':FFmpeg')
Now when I try and sync the project I get this error:
Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.
When I open the file, this is the affected line
apply plugin: 'com.github.dcendents.android-maven'
Basically my end goal is to get the above lib into my project as an external library so I can modify the source code to fix some bugs within the library.
Any help is much appreciated, I have been trying to fix this problem for a really long time but I am not too good with Gradle besides just using dependencies.
Update 1
Apply problems are now fixed however it cant find variables like version name and rootProject.ext.compileSdkVersion as Integer
Error:(6, 0) Could not get unknown property 'VERSION_NAME' for project ':FFmpegAndroid' of type org.gradle.api.Project.
You need to add the plugin to your classpath root build.gradle. You can found it in the Gradle Android Maven plugin. Something like this:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// This is the classpath for the plugin
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
allprojects {
repositories {
jcenter()
}
}
UPDATED:
You should look at the ffmpeg android gradle.properties and add it to your root project, here it is:
VERSION_NAME=0.3.2
VERSION_CODE=28
GROUP=com.writingminds
POM_DESCRIPTION=Java implementation of ffmpeg for Android
POM_URL=https://github.com/writingminds/ffmpeg-android-java
POM_SCM_URL=https://github.com/writingminds/ffmpeg-android-java.git
POM_SCM_CONNECTION=scm:https://github.com/writingminds/ffmpeg-android-java.git
POM_SCM_DEV_CONNECTION=scm:https://github.com/writingminds/ffmpeg-android-java.git
POM_LICENCE_NAME=GNU GPLv3
POM_LICENCE_URL=https://github.com/writingminds/ffmpeg-android-java/blob/master/LICENSE.GPLv3
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=hiteshsondhi88
POM_DEVELOPER_NAME=Hitesh Sondhi
The VERSION_NAME is needed in the Ffmpeg Android build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
// This is the library version used when deploying the artifact
version = VERSION_NAME
...
ADVICE:
It's better if you run the ffmpeg-android-java as independent project and then configure it so it can be installed to local maven. Read the details at my answer https://stackoverflow.com/a/46330142/4758255
You have to add the plugin in your buildscript block. You can add in the top-level build.gradle file or in your module/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
//..current plugins
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
About the variables not found you have to check the build.gradle in the library on github
You have to define in your project these variables. Of course use your values.
ext {
compileSdkVersion = 22
buildToolsVersion = '22.0.1'
targetSdkVersion = 22
minSdkVersion = 16
versionCode = 28
versionName = "0.3.2"
}
Today, I'm newbie in android studio.
I have updated the latest version of andriod studio
When I have opened an old projekct and started compiling the project I retrieve a
error message that is "Cause: failed to find target with hash string 'android-N'"
What should I do in order to use this old project in the updated android studio?
Thank you!
Sourcecode from the file build.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:2.1.0'
// 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
}
android N is not installed in your sdk
Just click on the link written in the error:
Open Android SDK Manager
and it will show you the dialogs that will help you to install the required sdk for your project.
you have to change
in app/build.gradle before opening your project
compileSdkVersion 'N'
buildToolsVersion '24.0.0 rc1'
targetSdkVersion 'N'
to
compileSdkVersion '24'
buildToolsVersion '24.0.0'
targetSdkVersion '24'
First of all, I know there are a lot of subjects about this problems, but I still can't fix it.
I'm just trying to customize aviary sdk by following the guide here : https://developers.aviary.com/docs/android/setup-guide# (section 4.2, not 4.1)
here are my root gradle files :
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.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
}
settings.gradle :
include ':app', ':Aviary-Android-Sample-App'
here is my app build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.agaze.myapplication"
minSdkVersion 10
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:20.0.0'
compile project(':Aviary-Android-Sample-App')
}
Here my files tree:
Thanks in advance for your tips.
Antonin
Check your submodules and make sure each submodule in your project has its own build.gradle file.
Check this guide for more info
tools.android.com/tech-docs/new-build-system/user-guide
Each library you add to your project should have it's own build.gradle file. If it does not have you can get this error.
For a solution you can add your sdk as a module with Android Studio. To do this you can follow the path in Android Studio:
File > New > Import Module and select directory of your sdk and add to your project.
Select Gradle System and let Android Studio create gradle files for your sdk.
You can check the link below for more information and how to add a module to your project.
http://www.truiton.com/2015/02/android-studio-add-library-project/
I hope this'll help you.
From your screen shot.It's obvious that the Aviary-Android-Sample-App is an eclipse project(no gradle file there) but not a valid gradle module.
If you want to import it into android studio, in android studio, click File -> new module -import eclipse adt project and go on under the instruction.
And you are good to go.
Edit:
Also, it seems that you want to modified the Aviary sdk, but the module you want to import is a sample app. Maybe you have downloaded the wrong file. The correct link looks like this one https://creativesdk.adobe.com/downloads.html
I'm trying to use RomainGuy's ViewServer (https://github.com/romainguy/ViewServer) with my Android Studio project using Gradle, and I can't get it to work.
My understanding is to add a folder in project root ('libraries'), drop the ViewServer directory into it (not the full ViewServer directory but the actual library viewserver folder within ViewServer, and reference it in settings.gradle
include ':VendorSearch'
include ':libraries:ViewServer'
and also in my build.gradle file
compile project(":libraries:ViewServer")
When I do this I get a message that says
Could not find any version that matches com.android.tools.build.gradle:0.5.+
I tried then manually updating build.gradle in ViewServer to use the latest build tools (0.7.+ at the time of posting), but I get the same error with the new gradle version.
Any help and general clarification of how to include non-jar third party libraries would be appreciated!
You probably need to add the repository. Change the gradle.build from:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
}
to
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 18
buildToolsVersion '18.0.1'
}
I'm only just starting with Android development so I'm sure this is incredibly basic and a dumb question, but I'm getting the following error when I try and include a library to use in my code with Gradle:
Gradle 'MyApp' project refresh failed: You are using an old, unsupported version of Gradle. Please use version 1.6 or greater.
The library I'm trying to use is ION. All I've tried so far is adding the following lines into the build.gradle file.
dependencies {
compile 'com.koushikdutta.ion:ion:1.1.5'
}
Which I guessed at based on this section of Koush's GitHub account, but what else do I need to do? Still download the jar and put it somewhere? I have looked at other questions/searched for guides on the basics of Gradle, but bizarrely I can't find a solid, definitive answer.
And how do I upgrade Gradle? Can it be done from within Android studio? I'm using Android Studio 0.2.13 on Windows 7 64bit:
SOLUTION: - Make sure you're putting the dependencies in the correct build.gradle file! Doh! It should be in the one just above your src folder, not the root!
Make sure that your buildscript contains the classpath with "gradle:0.5.+". Afterwards, navigate to the root directory of your project (one directory level above the build.gradle file) and (in the command line) run "./gradlew clean"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'MyApp\src\main\AndroidManifest.xml'
}
}
}
dependencies {
compile "com.koushikdutta.ion:ion:1.1.5"
}