I have been working on an Android application for several months, and didn't realize until today that it was targeting the level 25 for "Compile SDK Version." I want my app to be usable on versions of Android starting at API level 22 (Android 5.1). I went into my gradle settings and set a couple things...
compileSdkVersion 22
targetSdkVersion 22
I also changed the versions of the libraries it compiles with..
compile project(':snakeyaml-1.14-android')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:support-vector-drawable:22.2.1'
I get the following error...
"Failed to resolve: com.android.support:support-vector-drawable:22.2.1"
What should I do?
Related
When I try to compile I get this error
"Failed to resolve: com.google.android.gms:play-services:fp9.0.0" in Android Studio. I am trying to include the play services in my project. This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "Application name"
minSdkVersion 21
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services:fp9.0.0'
}
The only thing I have changed in this file is this line:
compile 'com.google.android.gms:play-services:fp9.0.0'
I have installed Google Play Services and it's version number is 30.
I had the same issue yesterday. In the messages section when running a gradle sync or build, I got a message with an option to update something from the M2 repo. Clicking the link downloaded the latest version and fixed the issue.
You could also try compile 'com.google.android.gms:play-services:9.0.0'
If you are only using maps, consider only downloading maps using compile 'com.google.android.gms:play-services-maps:9.0.0' as it can save you hitting the 65K method dex limit later in development.
Try to add and change this in your Project Level Gradle.
Update classpath com.google.gms:google-services:2.1.0 to classpath com.google.gms:google-services:3.0.0
And
Also try to change compile Dependencies as below.
compile 'com.google.android.gms:play-services:9.0.0'
Or for map you can only use this.
compile 'com.google.android.gms:play-services-maps:9.0.0'
I have an issue with gradle when importing this mongoDB jar driver in android studio. I am getting this error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2
When i import the mongo-java-driver-2.13.0-rc0.jar driver i have no issue with this. I do not know if this is relevant but first i imported this driver and then any other mongoDB driver is having this error except from this one that i added first. Here is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
repositories {
mavenCentral()
jcenter()
}
defaultConfig {
applicationId "com.example.irakl_000.maps"
minSdkVersion 19
targetSdkVersion 23
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:23.1.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:percent:23.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.isseiaoki:simplecropview:1.0.13'
compile files('libs/mongo-java-driver-3.2.0-SNAPSHOT.jar')
Any answers to similar questions in stackoverflow did not help, so any help is much appreciated!
EDIT: I created a new project and there are no errors, so obviously something is wrong with the project and not with the grandle file or jar
EDIT:
When i run gradle compileDebug --stacktrace i get the following
* Exception is:
org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in root project 'Maps'. Candidates are: 'compileDebugAidl', 'compileDebugAndroidTestAidl', 'compileDebu
gAndroidTestJavaWithJavac', 'compileDebugAndroidTestNdk', 'compileDebugAndroidTestRenderscript', 'compileDebugAndroidTestSources', 'compileDebugJavaWithJavac', 'compileDebugNdk', 'c
ompileDebugRenderscript', 'compileDebugSources', 'compileDebugUnitTestJavaWithJavac', 'compileDebugUnitTestSources'.
at ...
You may have a problem with the limit of 65k methods allowd on an android studio project. Google announced a solution to this problem. You can find more information here. I had a similar problem and this was the solution for me so you could give a try.
UPDATE
I should mention that this could seriously reduce your gradle build time so you should use it only if there is no other way. The best think you can do is to reduce the libraries you use to the ones you need.
You can also refer to this answer to reduce your google-play-services to the ones you actually need.
It looks like you're depending on a single jar twice between these two dependencies:
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/mongo-java-driver-3.2.0-SNAPSHOT.jar')
The first line is declaring a dependency on everything in the libs directory. The second line is then adding another dependency on a specific jar in the libs folder, which was already covered in the first line. You're effectively telling gradle to use that jar twice, which could cause problems. You're probably also getting a message from gradle to run the build again with different command line flags to see more detailed errors, so do that as well.
Consider removing one or the other. If you have other jars in the libs folder, you'll probably want to remove the second line.
With the following gradle script, I was wondering how to change the minSdkVersion from 7 to 3 (just so my app could run on more devices) without getting the error at the bottom of this post:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "dpark.cellular_automata"
minSdkVersion 3
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
... And then I would get the following error:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 3 cannot be smaller than version 7 declared in library [com.android.support:appcompat-v7:23.0.1] C:\Users\Dave\AndroidStudioProjects\Cellular_Automata\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.1\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
... That said, is it even possible to lower my minimum SDK to 3 (version 1.5, Cupcake) if I wanted to publish my app with Google Play? And also, in case you're wondering, I also downloaded the Android Support Library in the SDK manager as follows, and yet it still doesn't work:
Thanks!
That error is telling you that one of your libraries (in this case, AppCompat) only supports back to SDK version 7. Since that library cannot support anything lower than 7 and you use that library, you can't support anything lower than 7.
Your options are either:
Remove AppCompat
Support a minimum of API level 7. Note that SDK version 8 currently has less than 0.1% of the market share globally, and all versions less than 8 have a combined total of 1%. It probably isn't worth your time.
That said, is it even possible to lower my minimum SDK to 3 (version 1.5, Cupcake) if I wanted to publish my app with Google Play?
Absolutely. You could upload an Android app supporting API level 1 if you really wanted to.
And also, in case you're wondering, I also downloaded the Android Support Library in the SDK manager as follows, and yet it still doesn't work:
The support library v4 only supports back to API level 4, so I'm not sure how that would help with supporting API level 3.
I am trying to make runtime permissions backward compatible with older devices but using the support library i cant find checkSelfPermission() static call in ContextCompat class, but its documented here
Here is my project gradle settings:
defaultConfig {
applicationId "org.myprogram.cool"
minSdkVersion 16
targetSdkVersion 23
versionCode 39
versionName "3.0"
}
and here is the dependencies:
compile 'com.google.android.gms:play-services:+'
compile 'com.squareup:otto:1.3.5'
compile 'com.android.support:appcompat-v7:22.1.1'
any idea what i am missing ?
checkSelfPermission() didn't get introduced into the native Context until API 23. So you will need to use at least version 23.0.0 of the support library.
You should change this
compile 'com.android.support:appcompat-v7:22.1.1'
to this
compile 'com.android.support:appcompat-v7:23.0.1'
If you have migrated from eclipse adding the below line wont work
compile 'com.android.support:appcompat-v7:23.0.1'
While migrating, it adds appcompatv4 as an external dependent library.
Make sure you have deleted the appcompatv4 library from the libs folder and then it should start working
Make sure class exampleActivity class is extending from AppCompatActivity.
Make sure that your minSdkVersion is 23 in the build.gradle file.
Sync your gradle after making this change.
That should work.
I'm trying to install aws on android studio with [add library dependency]
on [project structure->app->dependencies->+]
now i choose:
com.amazonaws:aws-java-sdk:1.9.8
Then I'm trying to start my android application but this error appears:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
Now I'm trying this solution:
android {
defaultConfig {
...
multiDexEnabled = true
}
}
(on this site:
Unable to execute dex: method ID not in [0, 0xffff]: 65536)
But then this error appears:
same fail but this time this line appears too:
Deprecated dynamic property: "multiDexEnabled" on
"ProductFlavorDsl_Decorated{name=main, minSdkVersion=ApiVersionImpl{mApiLevel=14, mCodename='null'}, targetSdkVersion=ApiVersionImpl{mApiLevel=20, mCodename='null'}, renderscriptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, versionCode=1, versionName=1.0, applicationId=com.example.matthias.booksearch, testApplicationId=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null}", value: "true".
I think the problem is something with gradle, because of Build Failure...
My dependencies of gradle.build are:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.amazonaws:aws-java-sdk:1.9.8'
}
If someone use the aws-framework and it works, please write me back how you get started with it.
In your build.gradle file add multiDexEnabled true to defaultConfig and compile 'com.android.support:multidex:1.0.0' to your dependencies.
defaultConfig {
...
multiDexEnabled true
}
dependencies {
...
compile 'com.android.support:multidex:1.0.0'
}
Also, make sure you are using the latest stable version of Android Studio 1.0.1 from the Stable Channel.
https://developer.android.com/tools/building/multidex.html
multiDexEnabled support was added in v0.14.0 of the Android Gradle plugin, according to the release notes:
http://tools.android.com/tech-docs/new-build-system
It's not supported in 0.12.2, which is what you're running.
Please update to using the latest version of the plugin. You may need to update Android Studio to the latest version as well.
I have updated my gradle to 1.0.0 now I can configure multiDexEnable=true,
this solves the Dex error, but now I am trying to add 2 librarys:
aws-android-sdk-2.1.5-sdb.debug ,
aws-android-sdk-2.1.5-sdb and com.amazonaws:aws-java-sdk-core:1.9.9
(last One as maven dependencies)
and trying to run my Application with some simpleDB code, but now this error appears:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
`> java.util.zip.ZipException: duplicate entry:
com/amazonaws/services/simpledb/AmazonSimpleDB.class
Some Solutions?