Gradle not Respecting Ivy Standard Version Requirement - android

In my build.gradle file:
compile 'com.android.support:support-v4:[10.0.0,26.0.0['
compile 'com.android.support:appcompat-v7:[10.0.0,26.0.0['
Running gradle dependencies, shows:
sourcesReleaseCompile - Classpath for compiling the sourcesRelease sources.
+--- project :MyProject
| +--- com.android.support:support-v4:[10.0.0,26.0.0[ -> 26.0.0-alpha1
[...]
| \--- com.android.support:appcompat-v7:[10.0.0,26.0.0[ -> 26.0.0-alpha1
I want to avoid including 26.0.0-alpha1... Why isn't gradle respecting ivy standard notation here?
Test project: https://github.com/benmarten/gradle-dependency-test
Ivy Standard: http://ant.apache.org/ivy/history/latest-milestone/settings/version-matchers.html

Your version is wrong, 26.0.0 has not be released yet. Check the versions you have locally:
$ ls ~/android-sdk/extras/android/m2repository/com/android/support/appcompat-v7/
18.0.0/ 22.1.1/ 23.4.0/ 25.0.1/
19.0.0/ 22.2.0/ 24.0.0/ 25.1.0/
19.0.1/ 22.2.1/ 24.0.0-alpha1/ 25.1.1/
19.1.0/ 23.0.0/ 24.0.0-alpha2/ 25.2.0/
20.0.0/ 23.0.1/ 24.0.0-beta1/ 25.3.0/
21.0.0/ 23.1.0/ 24.1.0/ 25.3.1/
21.0.2/ 23.1.1/ 24.1.1/ 26.0.0-alpha1/
21.0.3/ 23.2.0/ 24.2.0/ maven-metadata.xml
22.0.0/ 23.2.1/ 24.2.1/ maven-metadata.xml.md5
22.1.0/ 23.3.0/ 25.0.0/ maven-metadata.xml.sha1
Since 26.0.0-alpha1 is out but 26.0.0 is not, you will need to use +. This works for me with Gradle 3.5:
dependencies {
compile 'com.android.support:support-v4:[10.0.0,26.0.+['
compile 'com.android.support:appcompat-v7:[10.0.0,26.0.+['
}
Possibly unrelated to your question but your project does not compile:
/Users/<>/repo/gradle-dependency-test/app/src/main/AndroidManifest.xml Error:
uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library [com.android.support:appcompat-v7:26.0.0-alpha1] /Users/<>/.android/build-cache/72b0bd3c930a8826bf341b591250d185129357b9/output/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
:app:processDebugManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library [com.android.support:appcompat-v7:26.0.0-alpha1] /Users/<>/.android/build-cache/72b0bd3c930a8826bf341b591250d185129357b9/output/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.136 secs
It turns out, it is your minSdkVersion version. In your app/build.gradle, set your minSdkVersion to 14:
android {
defaultConfig {
minSdkVersion 14
}
}

compileSdkVersion 26 Release Now
Setting up Gradle for api 26 (Android)
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.keshav.retroft2arrayinsidearrayexamplekeshav"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'

Related

Gradle sync failed: Could not find method defaultConfig()

In the first instance my problem was Cause 1: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
but this has escalated since then and now my gradle is broken.
this is the error I am getting:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\stackstorage\android projecten\Converter\build.gradle' line: 26
* What went wrong:
A problem occurred evaluating root project 'Converter'.
> Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2#b894d83] on root project 'Converter' of type org.gradle.api.Project.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 0s
Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2#b894d83] on root project 'Converter' of type org.gradle.api.Project.
Open File
event log:
12:13 Gradle sync started with IDEA sync
12:13 Gradle sync failed: Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2#55d7744a] on root project 'Converter' of type org.gradle.api.Project.
Consult IDE log for more details (Help | Show Log) (287 ms)
12:13 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN
12:13 Gradle sync started with IDEA sync
12:13 Gradle sync failed: Could not find method defaultConfig() for arguments [build_7komq7i2k7pl5720grjx3kada$_run_closure2#b894d83] on root project 'Converter' of type org.gradle.api.Project.
Consult IDE log for more details (Help | Show Log) (230 ms)
12:13 NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN
I am unsure what code I need to post for this to get helped but I've seen people posting their build.gradle and gradle.properties, so i'll post mine.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# 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.
org.gradle.jvmargs=-Xmx4608m
# 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
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
Thanks in advance to anyone willing to help. I kinda messed up here.
Check your app> build.gradle file. there will be defaultConfig() tag like this
defaultConfig {
applicationId "com.example.myApp"// your appId
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
In android studio, go to your project. Make sure you are in the view mode "Android". Just like this image:
Should be like this in android studio
Go to Gradle-Scripts -> build.gradle (module:app) and make sure it is composed similarly to this:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "your app id"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//your dependencies
}
Move defaultConfig{} from gradle project to build.gradle's app module inside android tag.
Should be similar to this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
mavenCentral()
}
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

"package does not exit" error while compiling project after converted from Eclipse

I've converted an Eclipse project for AndroidStudio then I got some errors "package does not exits", it package is library module.
library project's gradle scripts as follows.
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
}
debug {
minifyEnabled false
}
}
lintOptions {
abortOnError false
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
}
and the project's gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "xxxxxxxxxxxxxxxxx"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
}
debug {
minifyEnabled false
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile project(':library')
}
It's weird because IDE does not show any errors while coding and can import package properly but when I try to "run" the project, then error occurs.
I would appreciate it if someone could solve this problem.
Edited
Project Structure is like below.
- app (com.sample.apps)
- library (com.sample.library)
Actual Error Messages
package com.sample.library.xxx does not exits // <- My Custom Class. There are hundreds of errors.
Gradle Errors
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
100 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.344 secs
Solved
I solved this by using product flavors.
This is because library project is going to apply proguard and that's why application project can't find package.
I changed 'com:android:library' to 'com:android:application' and move app project as product flavors.

Error:(24, 11) Failed to resolve: com.android.support:appcompat-v7:8.0.+

Pleas help with this error cause it's my first android project !
Gradle Sync:
pply plugin: 'com.android.application'
android {
compileSdkVersion 8
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.interceptor.myapplication"
minSdkVersion 5
targetSdkVersion 8
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:8.0.+'
}
On Gradle console i get:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find any version that matches com.android.support:appcompat-v7:8.0.+.
Versions that do not match:
24.0.0-alpha1
23.2.1
23.2.0
23.1.1
23.1.0
+ 14 more
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/maven-metadata.xml
https://jcenter.bintray.com/com/android/support/appcompat-v7/
file:/D:/Users/INTERCEPTOR/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/D:/Users/INTERCEPTOR/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/maven-metadata.xml
file:/D:/Users/INTERCEPTOR/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/
Required by:
MyApplication:app:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
You should use the correct version for the appcompat-v7 dependency.
The latest stable version of the above-mentioned dependency to now is:
compile 'com.android.support:appcompat-v7:23.2.1'
Use it as above and make sure you installed/updated to the latest version in SDK Manager before.

Adding a productFlavor in Gradle (Android) causes a compilation error

Gradle compiles fine with the following build.gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
sourceSets {
debug {
jniLibs.srcDirs = ['src/main/jniLibs-dbg']
res.srcDirs = ['src/main/res-dbg', 'src/main/res-common']
}
release {
jniLibs.srcDirs = ['src/main/jniLibs-rel']
res.srcDirs = ['src/main/res-rel', 'src/main/res-common']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.0'
debugCompile files('libs/debug.jar')
releaseCompile files('libs/nonDebug.jar')
}
But, when I add productFlavors, compilation fails:
productFlavors {
flavor1{
}
flavor2{
}
}
The flavors are empty intentionally. I just want to see whether compilation succeeds. Later I will add resources per flavour.
The console log indicates that the assembleDebug task fails because it can't find the class files which are inside debug.jar
This is the error I see:
What went wrong:
Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Any idea?
Whats your Logcat Throws
Note: Some input files use or override a deprecated API.
At First upgrade your buildToolsVersion & compileSdkVersion .
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
You can change your minSdkVersion 8 level , Use 15 & set targetSdkVersion 23.
Again for
Note: Recompile with -Xlint:deprecation for details. Note: Some input
files use unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details.
You may visit here
Failure on build with Gradle on command line with an android studio project : Xlint error
The problem is
apply plugin: 'com.android.library
The key part is to set publishNonDefault to true in library build.gradle, Then you must define dependencies as suggested by user guide.
publishNonDefault true
productFlavors {
flavor1{}
flavor2{}
}
Also you are applying the flavors to the library so you also need to define on project gradle which flavour library you are going to use in the project
for e.g.
market1Compile project(path: ':lib', configuration: 'flavor1Release')
market2Compile project(path: ':lib', configuration: 'flavor2Release')
For the more detail please check the following link
Multi flavor app based on multi flavor library in Android Gradle
Let me know if you found any issues on that i will help on that also

Cannot resolve the dependencies in gradle build

Recently I have updated the Android Studio and also the SDK.
While rebuilding my app project i m getting following error...
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:appcompat-v7:23.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
file:/C:/android new SDK/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
file:/C:/android new SDK/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
file:/C:/android new SDK/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
file:/C:/android new SDK/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
Required by:
AppOne:app:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.913 secs
...............................................................
My Gradle file config is as follows ..
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 9
targetSdkVersion 23
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:23.0.0'
}
Take android sdk manager and update
Android support Library
Android support Repository
It will fix the problem.
You need to install/Update the Android support Library and Android support Repository first and then rebuild the project.

Categories

Resources