Gradle equivelant for export checked off - android

What is the equivelant for export box unchecked for dependency?
what i currently have is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
repositories {
maven {
url 'https://github.com/tanab/mvn-repo/raw/master/'
}
mavenCentral()
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.3.1'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
}
but this is makes ABS be exported while compiling which causes Dex Errors which state that Android Support Lib has already been added.
I cant do this in the android studio dependency editor since any changes i make there will not go through when i run my app,

I'm not familiar with android-library plugin yet. But as you said you have dependency to support library added twice.
Normally I would run gradle dependencies to see all tree and after I would exclude transitive dependency to support library (ref):
dependencies {
compile('com.actionbarsherlock:actionbarsherlock:4.3.1') {
//excluding a particular transitive dependency:
exclude group: 'com.google.android', module: 'support-v4'
}
}

Related

Android Studio 3 gradle sync issue

i'm working on a project with Android Studio but i have no idea about the Android Studio..
can't solve the gradle sync error for hours. my build.gradle is like this: (not the wrong one, it's the app build.gradle)
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
repositories {
mavenCentral()
mavenLocal()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId 'com.kofax.sdk.samples.easysnap'
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
buildTypes {
release
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
lintOptions {
abortOnError false
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
def sdkRef
project.getRootProject().allprojects.each { proj ->
if (proj.name.toLowerCase().equals('sdk')) {
sdkRef = proj;
return true;
}
}
if (sdkRef) {
println "SDK present in project; using project reference as dependency"
compile sdkRef
} else {
println "SDK is not present in project; dependency reference"
repositories {
flatDir { dirs 'libs' }
}
compile (name: 'sdk-release', ext: 'aar')
}
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
}
i tried to clean project it's not about it, is it about the plugins or the missing filesor libs?
i've keep getting this error:
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Please help...
If you work on Android Studio 3.0. Change "2.0.0" to "3.0.0" in your project gradle :
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
In your gradle-wrapper.properties :
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
In your app gradle : "compile" become "implementation" :
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.0'
}
You should read that :
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Android plugin 3.0.0 requires Gradle version 4.1 or higher. If you're opening an existing project using Android Studio 3.0 or later, follow the prompts to automatically update an existing project to the compatible version of Gradle.
To update Gradle manually, edit the URL in gradle-wrapper.properties to the following: distributionUrl=\https\://services.gradle.org/distributions/gradle-4.1-all.zip
And include the maven repo and change the plugin version in your project-level build.gradle file as follows:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}

Gradle build error: Failed to resolve:

I just downloaded Android Studio and created a new project and I'm getting gradle build errors:
Failed to resolve: com.android.support.test.espresso-core:2.2.2
and
Failed to resolve: com.android.support.appcompat-v7:25.3.1
This error was resolved reinstalling the SDK Tools + Repository + API when launching android studio as admin.
I've installed API Level 25 which what I want to build on and have downloaded the SDK Build-Tools. I have also already download the support repository
Here's my app file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.jtsalas.mirrorcontrol"
minSdkVersion 25
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
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.3.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
}
From the SDK manager, make sure you have both the Android Support Repository and Google Repository installed and up to date. You should then be able to find the relevant artifacts in sub folders of your /extras/android/m2repository directory
From your error it seems that you are not including espresso libraries. The solution to this is adding espresso core library which is part Android Testing support library which is hosted in the google's Maven repository think this as kind of git repository but for dependencies.
So we tell the gradle build system to look in the Maven repository for dependencies by specifying its URL.
This is done by adding Maven url in the application level build.gradle file under repositories block
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
and in the module level build.gradle file mention the dependencies that you want from the maven repository by mention their name as follows:
dependencies{
//other dependencies go here
//testing dependencies
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
}
That is the reason for including Maven repository url in the app level build.gradle file, hope this helps.
In project.gradle file, the allprojects root align this way:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
jitpack is used as the dependency for multiple libraries, if you're not using any sort of library that don't requires it then not include maven line.
Well, I don't know the perfect answer but..... how about comparing with my SDK Tools?
I solved it by uninstalling Android Studios and deleting old versions of Android Studios in my C:\Users[Username] and reinstalled Android Studio as administrator.
It seems like you updated android studio and opening previous project in it.The simplest way is create new project and copy
1. compileSdkVersion 26
2. buildToolsVersion "26.0.1"
3. targetSdkVersion 26
4. compile 'com.android.support:appcompat-v7:26.+'
and paste them in appropriate places in app level build gradle.
it will ask to update to take advantages .. allow it to update.
best luck ... It worked for me.
if your project is Flutter,
clean project [by 'flutter clean' command]
In project.gradle file add [ google() ]
in Android studio: File Menu -> Invalidate...
project.gradle:
allprojects {
repositories {
google()
jcenter()
}
}

configuration issue. "Configuration with name 'default' not found"

I am relatively new to Android development and VERY new to Android Studio (much more experienced with Eclipse + android plugin). I am trying to edit a github project, but I can't seem to get it to even compile! I have been reading up, and my error seems to have to do with the build.gradle/locations of libraries themselves.
My error is:
Error:Configuration with name 'default' not found.
It also says "Gradle project sync failed, but I think its related to the above error…whatever that means.
My outer build.gradle is:
// 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:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And my inner build.gradle file is:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
defaultConfig {
applicationId "com.wisely.loyalty"
minSdkVersion 14
targetSdkVersion 18
versionCode 17
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':facebook')
compile project(':cwac')
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
compile('org.apache.httpcomponents:httpmime:4.3.5') {
exclude module: "httpclient"
}
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.android.gms:play-services:5.0.+'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.crashlytics.android:crashlytics:1.+'
}
EDIT:
General file hierarchy
root
.idea
app
libs
cwac
fb
utils
src
… all source files
gradle
build.gradle
settings.gradle
External Libraries
Android API 20 Platform
JDK
EDIT: Settings.gradle:
include ':app', ':facebook', ':cwac', ':utils'
project(':facebook').projectDir = new File('app/libs/facebook')
project(':cwac').projectDir = new File('app/libs/cwac')
project(':utils').projectDir = new File('app/libs/utils')
Progress Update:
I've tried moving the library files around in the directory to no avail. I also tried using my eclipse environment which just seemed to have even more issues. I really need to get this project configured properly!
UPDATE #2:
I have a strong feeling that this has to do with the gradle version since the file configuration seems fine, and its likely my computer that is lacking something. I am new to using gradle. Is there a way to update it? Or is it simply updated through the support libraries in the sdk manager?
Add your library folder in your root location of your project and copy all the library files there. For ex YourProject/library then sync it

What is the correct way to specify an Android library project to include its dependencies

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.

Android Studio could not find any version that matches com.android.support:appcompat-v7:+

Running a project in Android Studio fails with this error: could not find any version that matches com.android.support:appcompat-v7:+
How can I fix this error?
From Android Studio go to:
Tools >> Android >> SDK Manager
Select and install "Extras|Android Support Repository"
For me it worked after changing the version from 7:27.+ to 7:+
In Project > app > build.gradle file replace the line
implementation 'com.android.support:appcompat-v7:+'29.+'
with
implementation 'com.android.support:appcompat-v7:+'
and line
implementation 'com.android.support:design:29.+'
with
implementation 'com.android.support:design:+'
Then clean build
Also as as said on How to update Android platform-tools in a headless linux?
android list sdk
android update sdk --no-ui --filter extra
It is very simple.
Kindly update and replace the below code in build.gradle(Project :App Name).
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
After installing Extras|Android Support Repository, It does not work for me. Then I change v7:1.6 to v7:1.8 in the app build.gradle file.
com.android.support:appcompat-v7:1.8.+! and It works for me.
Open SDK Manager.exe in your Android Studio folder and install a matching API.
I found all these answers incorrect for me. Instead in your android studio look below on the left. There will be some help for this.
For example, you will notice
This support library should not use a different version (32) than the compilesdkVersion (23)
Then you change the version of to 23 like this
compile 'com.android.support:support-v4:23'
Now, you will see a message
A newer version of com.android.support-v4 than 23 is available 23.4.0.
Thats how I knew that the correct version is 23.4.0
If you see this after you've just created a new project in Intellij then try to recreate it again with "Use AndroidX artifacts" checked
To whom came here for same error but version 29, change your support library to version 28:
build.gradle(app):
dependencies {
...
implementation 'com.android.support:appcompat-v7:28.+'
...
}
None of googled solutions worked for me. Then I saw Android has only support library up to version 28. It is weird that I got this error in an out-of-box created Android Studio project.
I'm not sure which Android Studio version was, cause I upgraded Studio after got error. Now in Android Studio 3.6.3, new projects coming with 'androidx.appcompat:appcompat:1.0.2'.
This worked for me to build and run this project.
I had to add google in both sections.
build.gradle (project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "29.0.2" //25.0.2"
defaultConfig {
applicationId 'com.github.nkzawa.socketio.androidchat'
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
////noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:25.0.+'
////noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:25.0.+'
implementation ('io.socket:socket.io-client:0.8.3') {
exclude group: 'org.json', module: 'json'
}
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
}
Got the same error but version 26.
Downloading the libraries through the SDK Manager is no longer supported. The support libraries are now available through Google's Maven repository.
Solution:
In build.gradle (project) inside both buildscript/repositories and allprojects/repositories add this:
maven {
url 'https://maven.google.com/'
name 'Google'
}
Result:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
It worked for me.

Categories

Resources