I had a project in Android studio and I needed to delete .idea directory. So I importet it again, but after this, all modules in libs/ can't resolve anything from android (but app module can).
Is there any setting which connects module with android?
Thanks very much
This is screen from stickyListHeaders library:
biuld.gradle from stickyList:
apply plugin: 'android-library'
apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 18
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
And project's settings.gradle
include ':libs/bakuDroidLibrary'
include ':libs/photoView'
include ':libs/pullToRefresh'
include ':libs/slidingMenu'
include ':libs/spinnerWheel'
include ':libs/stickyListHeaders_lib'
include ':##PROJECTNAME##'
Some other screenns which may help:
Top level 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.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
First Check whether File » Project Structure » Android SDK is pointing to right SDK.
Than make sure below lines are added before apply plugin: 'android-library'inside build.gradle file of your stickyheader library or inside Project root's build.gradle file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
My suggestion is to avoid downloading and adding libraries in to your project, use maven dependency instead.
For stickyheader which you have used can be used just by adding dependency like this in your module's build.gradle file
dependencies {
compile 'se.emilsjolander:stickylistheaders:2.1.3'
}
Nothing else needs to be done.
Related
I tried to add the Fresco library by to my project by adding this to my app-level gradle file
implementation 'com.facebook.fresco:fresco:1.8.0'
Then I get the follwing error message:
Gradle DSL method not found: 'implementation()' Possible causes:
The project may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 3.0.1 and sync project
The project may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
When I run gradle --version it tells me that I am using gradle 4.5.
This is my top-level gradle file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven"}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my app-level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "com.example.project1.3"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "state1.0"
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// lots of other dependencies
implementation 'com.facebook.fresco:fresco:1.8.0'
}
I also have this in my gradle-wrapper.properties file.
distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-all.zip
I have basically tried everything from here https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html but the problem persists.
Any help would be greatly appreciated. Thank you!
My guess is that probably one of your other dependencies is causing the issue,
I run the exact same app & project gradle files you provided in a new project and synced with no problem.
You can try the following:
1) substitute implementation 'com.facebook.fresco:fresco:1.8.0' with compile'com.facebook.fresco:fresco:1.8.0' (deprecated but it will help with the troubleshooting) and see if it will sync properly.
2) start a new project and use the same gradle file and see if the problem still exists.
If nothing works please post the complete app level gradle file to check again.
I am trying to install Picasso (http://square.github.io/picasso/) for use in Android Studio. One of the steps is to add this line: compile 'com.squareup.picasso:picasso:2.5.2' in build.gradle under dependencies. However, there is a message in gradle that tells me not to insert individual dependencies in the dependencies folder. What should I do?
// 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.3.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
}
You need to add it to the gradle.build file that is located in the "app" directory, not the one in your project directory. find the gradle.build file that sits within the "app" directory of your project.
Here is mine as an example:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.your.packagename"
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories { mavenCentral() }
dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}
And a link to some supporting documentation:
http://developer.android.com/tools/building/configuring-gradle.html
Screenshot of the build.gradle(Module:app file)
Take a look at the image.
Do you see that there are actually 2 build.gradle files?
what you need is the (Module:app) gradle build file select that and paste the link in the dependencies part in the bottom of that file just like what i have done , then Android Studio will ask you to sync the file.
Do it.
It will download the dependency from your link provided and integrate with the project
Hope this helps..
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.