I had to reinstall my system and today I get this error in Android Studio when I try to sync with gradle:
Warning: Unable to find optional library: org.apache.http.legacy
My project gradle is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
And my module gradle:
apply plugin: 'android'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
}
buildTypes {
release {
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
}
From the google docs:
To continue using the Apache HTTP APIs, you must first declare the
following compile-time dependency in your build.gradle file:
android {
useLibrary 'org.apache.http.legacy'
}
I tried the suggestions mention in this thread but they don't work. Same result with android studio 1.5 and 2 preview.
How can I fix this?
Edit: Things I've tried so far:
Change gradle classpath versions to 1.3.0, 1.3.1, 1.5.0.
Change the compileSdkVersion and targetSdkVersion to 22. Also the buildToolsVersion from 23.0.1, 23.0.0, 22.0.1.
Top level build.gradle - /build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
Module specific build.gradle - /app/build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
...
}
Add org.apache.http.legacy.jar which is in Android/Sdk/platforms/android-23/optional folder to app/libs directory and sync your project
After a lot of working this solutions work for me
.
** Studio\Android\sdk\platforms** here delete your android-23 and from sdk manager update api 23 again.**
.
it will solve your issue.
In my case, it didn't work because I was missing optional.json in <sdk-path>\platforms\android-23\optional\, directory with the following content:
[
{
"name": "org.apache.http.legacy",
"jar": "org.apache.http.legacy.jar",
"manifest": false
}
]
Creating a new JSON file with with above content solved the problem for me.
You need to add org.apache.http.legacy.jar jar file in your Android Stuido project's app/libs folder.
Jar Location - `<SDK LOCATION>\android-sdk\platforms\android-23\optional`
To do this, just right click on your project and select Show in Explorer then go to ...\app\libs and paste above jar file and Sync your Project with Gradle File
Module:app
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "<ur_app_id>"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Update your project gradle file to use gradle version 1.3.1.
classpath 'com.android.tools.build:gradle:1.3.1'
Also try adding codehause repo.
repositories {
mavenCentral()
maven{
url 'http://repository.codehaus.org'
}
}
In my case the problem was actually occurring because I didn't have the correct SDK installed on that computer. Navigating to .../Android/Sdk/platforms/android-23 I could see that folder was empty. Adding SDK 23 via the SDK manager fixed the problem and allowed me to compile.
You should manually check that you have the same version of the SDK installed that is specified under compileSdkVersion in your build.gradle file.
To save time 2 solutions are best and works for me.
Solution 1 :
open your android sdk manager and reinstall API 23 (remove and install again).
Solution 2 :
Download this file which contain optional.json file
extract and move optional.json to :
C:\Users\\AppData\Local\Android\sdk\platforms\android-23\optional
if above solution is not work then try this way
I experienced this problem recently, and it is caused by the path length restriction I think it´s 256 characters maximum.
Relocate your Project and the build will succeed.
Copy "sdk\platforms\android-23\optional\org.apache.http.legacy.jar" to your app module libs directory, then add as library;
If you enable the proguard, please edit "proguard-rules.pro" to keep related classes or exception will occurred.
Related
I'm trying to get into developing using android studio, so I recently tried to run a simple login-activity app on it. Basically, what I did was just run the setup for a new android studio project, and selected loginactivity as my default screen. I configured the emulator and hit sync gradle, but it gave me the following response:
image
I downloaded the repository that was required and tried to sync the gradle again, but it again asked exactly the same thing! Please help!
my gradle file for the app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.fyp.fingerpay"
minSdkVersion 23
targetSdkVersion 27
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.google.android.gms:play-services:10.2.6'
compile 'com.android.support:appcompat-v7:27.+'
}
I think you have forgot to add maven repository in your app gradle file.
Try by doing these steps.
Open the build.gradle file for your application.
Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example:
allprojects {repositories {jcenter()maven {url "https://maven.google.com"}}}
Avoid using + in your dependencies as it android studio will try to update dependencies every 24 hours.
Also replace compile by implementation for low APK size.
This question already has an answer here:
When using compile 'com.google.android.support:wearable:2.0.4' I get the error below, but I am not using 26.0.0
(1 answer)
Closed 5 years ago.
I'm developing a music application for both mobile & wear. I've completed building the base of the application on mobile, and now I want to start the wearable (2.0) part. I tried following the tutorial on the Android Developer site, but even following the base directions gives me a Gradle sync error. I tried adjusting the compileSdkVersion and targetSdkVersion both to 24, which I use for my mobile gradle scrip. It didn't make a difference however.
This is the instruction mentioned:
In the build.gradle file for the Wear module:
>> In the android section, confirm that the compileSdkVersion is set to 25.
>> In the android section, confirm that the targetSdkVersion is set to 25.
Update the dependencies section as follows (requires the latest version of the Google Repository):
compile 'com.android.support:wear:26.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
.
Clicking on "install repository and sync project" has no effect.
This is the build.gradle file for the Wear module.
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "be.ehb.dt.finalwork_lievenluyckx_v001"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:wear:24.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
}
I'm really new to Android, and I don't really understand what is going wrong here. Any help is appreciated, even if it isn't a direct solution to the issue!
Edited: After trial-error,solution finally was found:
In build.gradle file -> allprojects, within repositories,code below should be added...
1) For the Android Gradle plugin revision 2.3.3 with Gradle 3.3 (Android Studio 2.3.3)
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
2) For the Android Gradle plugin revision 3.0.0 with Gradle 4.1(Android Studio 3.0.0)
allprojects {
repositories {
jcenter()
google()
}
}
For more here: When using compile 'com.google.android.support:wearable:2.0.4' I get the error below, but I am not using 26.0.0
Change your gradle to:
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "be.ehb.dt.finalwork_lievenluyckx_v001"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:wear:26.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
}
I am trying to add to my build.gradle file in Android Studio the following dependency:
https://android-arsenal.com/details/1/1883
I followed the intstructions found in package tab of this page, but when I tried to build the project I got the following message:
Error:(32, 13) Failed to resolve:
com.github.DASAR:Minim-Android:a73b596916
Anyone can help me?
I also tried to download the project code and import it in Android Studio as a module, but it wasn't recognized as a library from the wizard.
Thank you all in advance.
You can download relative API in your AS SDK Manager, then add it in build.gradle. After that, check out the compileSdkVersion, targetSdkVersion are same with appcompat. My build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.example.android"
minSdkVersion 9
targetSdkVersion 19
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:19.0.0'
}
my sdk is 19
Best option is to fork the project and add a Gradle build file. Then use JitPack to build the fork.
Note that the project has dependencies in a libs/ folder so these would need to be converted to dependencies in Gradle.
I updated android studio from version 1.0 to 1.2.1 and when I started my first application the this appears.
Error:Execution failed for task ':app:compileDebugAidl'.
aidl is missing
I have made sure that all sdk are up to date. This is my gradle build code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
defaultConfig {
applicationId "com.example.william.myapplication"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
compileSdkVersion 21
}
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:22.2.0'
}
It seems that AndroidStudio-1.3-Preview is using an unexpected version of the gradle plugin. (at least when you create a fresh new project)
Similarly, if you open an existing project using:
an older version of the plugin. (<1.3.0-beta1)
latest build tools (23.0.0-rc1)
compileSDK 22
---> you will probably have this strange error : "aidl is missing" (even in projects not using aidl !)
Solution:
Be sure to use the latest android-gradle-plugin (in the root build.gradle) :
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
under buildscript-->dependencies.
Example :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and the latest build tools (in module build.gradle):
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
... }
BE AWARE that with this config you are using the latest build tools -not released yet- and the preview of Android-M ---> things can be unstable
I had the same error. I changed the build tools version in the gradle script to my actual sdk build tool version found in sdk manager and that did the trick.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
...
now that i've decided to use Android Annotations with Android Studio i wanted to implement it through Gradle. After some thoughtful research i've found out that there are older and newer ways of implementing Android Annotations through Gradle depending on which version android studio, gradle or android annotations have. i came to this useful tutorial -> http://www.jayway.com/2014/02/21/androidannotations-setup-in-android-studio/ , and tried to implement this , at first, with the new 'android-L' as target SDK like
targetSDKversion "android-L" + compileSdkVersion 20 + buildToolsVersion "20.0.0"
until i tried it with
targetSDKversion 20 + compileSdkVersion 20 + buildToolsVersion "20.0.0"
and also
targetSDKversion 19 + compileSdkVersion 19 + buildToolsVersion "19.1.0".
Everytime i was getting 2 warnings that my java classes dont seem to get precompiled. even though it seems that it pre-creates the build/generated/source/apt directory. but without my pre-processed class from my MainActivity -> MainActivity_
I always do get following Warnings:
Note: Resolve log file to D:\AndroidProjects\GradleTest\app\build\generated\source\apt\androidannotations.log
Note: Initialize AndroidAnnotations 3.0.1 with options >{androidManifestFile=D:\AndroidProjects\GradleTest\app\build\intermediates\manifests\debug\AndroidManifest.xml, resourcePackageName=at.gradle.defuex.gradletest}
warning: Unclosed files for the types '[dummy1407928544078]'; these types will not undergo annotation processing
warning: The following options were not recognized by any processor: '[androidManifestFile, resourcePackageName]'
My build.gradle file looks like this:
buildscript{
repositories{
mavenCentral()
}
dependencies{
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.3'
}
}
repositories{
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "at.gradle.defuex.gradletest"
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
signingConfigs{
releaseConfig{
storeFile file("gradlekeystore.jks");
storePassword ("*************");
keyAlias "keyAlias";
keyPassword "*************";
}
}
buildTypes {
release {
runProguard false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
}
debug {
debuggable true
applicationIdSuffix ".debug"
}
}
}
apt {
arguments {
androidManifestFile variant.processResources.manifestFile
resourcePackageName "at.gradle.defuex.gradletest"
}
}
dependencies {
apt "org.androidannotations:androidannotations:3.0+"
compile "org.androidannotations:androidannotations-api:3.0+"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Im using following Versions:
Android Studio version 0.8.2
Gradle version 0.12.2
android-apt version 1.3
android annotations version 3.0.1 (as seen in the build.gradle file)
If there should be a solution to this problem please tell me, because im confused now.
If there should be a better annotations framework or a way of using cool annotations, please tell me that too.
And if it should not be a common way anymore to use annotations for android projects anyway, please pleeeeease tell me that too.
,but i would prefer a solution to my problem :)
Cheers!
Try to run gradlew clean build from project root.
Then try to make project (button with a green arrow with 0 and 1) before running on a device. Should be fine.