I am importing a Eclipse Project to Android Studio. But it occur error like below. How do resolve this type of error
Error:Circular reference between projects: :app -> :app
below is settings.gradle file
include ':app'
here is build.gradle file
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
android {
buildToolsVersion "23.0.1"
compileSdkVersion 23
defaultConfig {
targetSdkVersion 22
}
productFlavors {
}
sourceSets {
main {
manifest.srcFile 'app/src/main/AndroidManifest.xml'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
}
Sol1:same name(:app) will not add in Android Studio.
sol2:if the :app name is not there in your Project,
Create new Project and import again, it will work
sol3:in settings.gradle file
include ':app',':core'
add like this.
Related
I created a project as a library and I wrote a class in that. Now I want to have an aar file from that using build.gradle.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
}
What changes are needed in the above code?
Just make sure that your <modulename>/build.gradle contains the right plugin:
apply plugin: 'com.android.library'
Then you can create with
gradlew aR
your release aar file. Which will land in <modulename>\build\outputs\aar directory with the name modulename-release.aar.
The more tricky part is to include that aar file to your project (if you don't use maven or jcenter).
You need to put this lines to your <projectroot>/build.gradle:
allprojects {
repositories {
mavenCentral()
flatDir { dirs('aars') }
}
}
When you put your aar files in <modulename>/aars, then you can include your aar file in your desired module like this:
compile(name:'<your-aar-file-name>', ext:'aar')
I tried to find answer for the below error message from the forum. I could not.
Error:
Error:A problem occurred configuring project ':app'.
Cannot evaluate module soundprocessing : Configuration with name 'default' not found.
Details
Project Structure:
Android
|__ app
|__ net (java library)
|__ soundprocessing (Android Library without any activity)
Build.gradle at the top level (Android)
// 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.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
settings.gradle (at top level Android)
include ':app',':net', ':soundprocessing'
Build.gradle inside app
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.clinicloud.app"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':net')
compile 'io.realm:realm-android:0.80.1'
compile project(':soundprocessing')
}
build.gradle (inside net)
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
build.gradle (inside soundprocessing)
// 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.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Settings.gradle at the top level has this code
include ':app',':net', ':soundprocessing'
************I deleted settings.gradle from soundprocessing app as one of the forum answers said there should only one settings.gradle in multi project dependency.
Error:A problem occurred configuring project ':app'.
Cannot evaluate module soundprocessing : Configuration with name 'default' not found.
Now I added my settings.gradle as well. So what could be the problem?
I had the same problem when I added a library project to an app. I solved it like this...
In the settings.gradle (in your app, not the library) edit it to include your libraries sub-folder :
include ':app', ':library_project'
project(':library_project').projectDir = new File('../library_project/library')
in my example, observe the /library subfolder. As soon as I specified it, the error was fixed.
NOTE: this subfolder will depend on your library project and will likely be something different.
Change the file "build.gradle" inside "soundprocessing":
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 19
targetSdkVersion 21
}
// Change this section or remove
sourceSets {
..........
}
}
// Change this section or remove
dependencies {
.......
}
The section "sourceSets" need only if your project has custom paths to elements: sources, AndroidManifest.xml, resources and etc.
In my Android application project I want to use https://github.com/Bearded-Hen/Android-Bootstrap/tree/master/AndroidBootstrap as a dependency (I use Android Studio 0.8.8).
This is my settings.gradle
include ':gui', ':client', ':Android-Bootstrap'
project(':Android-Bootstrap').projectDir=new File('/abs/path/to/Android-Bootstrap/AndroidBootstrap')
And my gui/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.3'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
}
...
skipped
...
}
dependencies {
...skipped...
compile 'com.android.support:appcompat-v7:19.1.0'
...skipped...
compile project(':client')
compile project(':AndroidBootstrap')
}
When I gradle sync I get::
Error:(1, 0) Plugin with id 'android-library' not found.
If I remove
project(':Android-Bootstrap').projectDir=new File('/abs/path/to/Android-Bootstrap/AndroidBootstrap')
I get
Error:(44, 0) Project with path ':AndroidBootstrap' could not be found in project ':gui'.
If I change https://github.com/Bearded-Hen/Android-Bootstrap/blob/master/AndroidBootstrap/build.gradle with
apply plugin: 'com.android.library'
I get
Error:(1, 0) Plugin with id 'com.android.library' not found.
If I add to https://github.com/Bearded-Hen/Android-Bootstrap/blob/master/AndroidBootstrap/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.3'
}
}
I get
Error:(44, 0) Project with path ':AndroidBootstrap' could not be found in project ':gui'.
How to fix it? I want this module be external, no import and copying into main project. Why fixing gradle plugin dependency leads to path not found issue?
Fix as follows in settings.gradle:
include ':gui', ':client', ':AndroidBootstrap'
project(':AndroidBootstrap').projectDir=new File('/abs/path/to/Android-Bootstrap/AndroidBootstrap')
Note that Android-Bootstrap is replaced with AndroidBootstrap (not dash)
And in root build.gradle (./build.gradle)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.3'
}
}
It will override (set) buildscript dependencies in AndroidBootstrap.
There is not need to make changes in AndroidBootstrap itself.
In Android Studio I'm trying to compile an Android application module which uses an Android library.
The library includes a jar file for Bugsense (included automatically by gradle).
Although the library module compiles correctly, the application module fails because it is looking for the Bugsense jar file that is used within the library module.
I do have a workaround which allows the project to compile. By also including the Bugsense dependency in the project everything works.
My question is: How do I make the project compile without duplicating the Bugsense dependency?
Here is my build.gradle file for the library project.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
android {
compileSdkVersion 15
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
}
dependencies {
compile 'com.bugsense.trace:bugsense:3.6'
}
The library project is called "util"
Following is the android section of the build.gradle for the application
android {
compileSdkVersion 15
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
dependencies {
compile project(':util')
}
}
When I compile this I get the following error:
* What went wrong:
A problem occurred configuring project ':br'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':br:_DebugCompile'.
> Could not find com.bugsense.trace:bugsense:3.6.
Required by:
dss:br:unspecified > dss:util:unspecified
I can make the compile work by adding Bugsense to the repositories section of the build.gradle file for the application. Following is the code I added to the build.gradle file for the application project.
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
Remember, the above code is in the build.gradle for the application project AND the library.
How do I avoid adding the Bugsense dependency to both the application and library projects?
UPDATES:
I'm using Gradle 1.8
I'm compiling from the command line with "gradle clean assembleDebug"
The following is the complete build.gradle file for the application project:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
//maven { url 'http://www.bugsense.com/gradle/' }
}
android {
compileSdkVersion 15
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
testPackageName "com.myapp.test"
}
dependencies {
compile project(':common')
compile project(':util')
}
}
dependencies {
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'com.squareup.spoon:spoon-client:1.0.+'
instrumentTestCompile 'com.google.guava:guava:15.0'
}
configurations { spoon }
dependencies { spoon 'com.squareup.spoon:spoon-runner:1.0.5' }
It's the expected behavior. Only the repository declarations for the project whose configuration is currently resolved are taken into account, even when transitive dependencies are involved. Typically, repositories are declared inside the root project's allprojects { .. } or subprojects { ... } block, in which case this problem can never occur.
PS: dependencies { .. } needs to go outside the android { ... } block.
I have been following this tutorial for integrating ActionBarSherlock in the Android Studio IDE.
After following all the steps I get the following error:
Gradle: A problem occurred evaluating project ':MyApp'.
> Could not find property ':actionbarsherlock' on DefaultProjectDependency{dependencyProject='project ':MyApp'', configuration='default'}.
The source of the error is my AndroidStudioProjects\MyApp\myapp\build.gradle file with the contents as follows:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
compile 'com.google.code.gson:gson:2.2.+'
compile project ':actionbarsherlock'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Maybe a late answer, but try like that :
compile project(':actionbarsherlock')