dependency implementation "org.apache.http.impl.client:client-DefaultHttpClient:4.2.5" cannot be found on android studio gradle - android

I added the dependency org.apache.http.impl.client:client-DefaultHttpClient:4.2.6 on build.gradle for my android studio project. (Just for context, I am trying to use HttpClient to access help access data in php files). However, when I try to apply this dependency, I get an output message saying that my execution failed for the following reason:
8: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find org.apache.http.impl.client:client-DefaultHttpClient:4.2.5.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/apache/http/impl/client/client-DefaultHttpClient/4.2.5/client-DefaultHttpClient-4.2.5.pom
- https://repo.maven.apache.org/maven2/org/apache/http/impl/client/client-DefaultHttpClient/4.2.5/client-DefaultHttpClient-4.2.5.pom
Required by:
project :app
The implementation is being searched for online, but I am not sure why this is the case, since I have a .jar file
located in the cache subfolder of a .gradle folder. Does anyone know what could be causing this problem?
Build.Gradle code for reference:
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'org.apache.http.impl.client:client-DefaultHttpClient:4.2.5'
//implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.2.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

add this to your app level build.gradle:
android {
useLibrary 'org.apache.http.legacy'
}

Related

Could not resolve all files for configuration ':app:debugRuntimeClasspath' in latest version of Android studio 2022

I was trying to use my 1-year-old source code in the latest version of Android studio. I'm encountering a lot of issues. I've not been able to find any reasonable solution till now. I would really appreciate it if anybody could help me out.
Gradle code below:
plugins {
id 'com.android.application'
}
android {
namespace 'gwyn.myapp'
compileSdk 32
defaultConfig {
applicationId "gwyn.myapp"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.hbb20:ccp:2.2.3'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.hani-momanii:SuperNova-Emoji:1.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.multidex:multidex:2.0.0'
}
Project: gwyn.app
plugins
{
id 'com.android.application' version '7.3.0-beta05' apply false
id 'com.android.library' version '7.3.0-beta05' apply false
}
Error I'm receiving
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: org.gradle.internal.execution.fingerprint.InputFingerprinter$InputFileFingerprintingException: Cannot fingerprint input file property 'externalLibNativeLibs': Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.hbb20:ccp:2.2.3.
Thank you,

Android Studio org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException:

I want to integrate the country code picker by hbb20. I put the dependency and build, it's fine but whenever I try to run the app then I got this error:
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
My build.gradle app level codes:
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.teamphoenix.amarflat"
minSdk 22
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "com.github.skydoves:powerspinner:1.1.9"
implementation 'com.hbb20:ccp:2.4.7'
}
I have had the same problem using mik3y's usb-to-serial.
I wrongly used:
com.github.mik3y:usb-serial-for-android:Tag
and changing it to :
com.github.mik3y:usb-serial-for-android:3.4.3
solved the problem.
I recommend you review all your dependencies, probably one of them does not point correctly to its repository, I hope I can help you.
By the way, surely the (```) at the end of the code was just an editing error, right?
I have same issue.
My issue solved when
**
Gradle Toggle offline mode off
**
.
Just click Toggle offline mode and set mode off.

Failed to resolve:... Affected module: app

I keep getting the error "Failed to resolve: :unspecified: Affected Modules: app" whenever I sync my gradle. This error is not descriptive and hence hard to figure out what's the exact cause for this.
App build.gradle:
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.firstapp.attendance_system"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'org.naishadhparmar.zcustomcalendar:zcustomcalendar:1.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am using Android Studio 2021 on Windows 10 PC

Android Gradle Error: Could not download library-1.8.aar (com.nbsp:library:1.8)

Out of nowhere I got this error:
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not download library-1.8.aar (com.nbsp:library:1.8)
Show Details
Affected Modules: app
This is my app gradle file:
android {
compileSdkVersion 30
defaultConfig {
applicationId "..."
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
implementation 'com.nbsp:library:1.8'
implementation 'com.android.volley:volley:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
It worked fine yesterday but today when I opened Android Studio, I got this error.
I've searched, but not find a solution. I don't know why it's showing me this, also Show Details link doesn't work.
This seems to work for me: I replaced
implementation 'com.nbsp:library:1.8'
with
implementation 'com.nbsp:materialfilepicker:1.9.1'
The library:1.8 was used by MaterialFilePicker but when I went to their github I saw that they change it with materialfilepicker:1.9.1
And I also had to add the following compileOption in the gradle file:
android {
.....................
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
And also Build->Clean project and then Rebuild project

Android common jar file in android

I have an app and two library modules - moduleA, moduleB.
Both of these modules are using a common jar file "xyz.jar" which is being placed in their respective libs folder.
When i am trying to build this project in Android studio i am getting following error -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have already enabled multi dex by adding following lines in build files-
multiDexEnabled true
api 'com.android.support:multidex:1.0.2'
Could anyone please help? Almost whole day have been gone without any solution.
build.gradle for ModuleA
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/bbdevice-android-3.4.1.jar')
}
build.gradle for ModuleB
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/bbdevice-android-3.4.7.jar')
implementation files('libs/bbdeviceotaapi-android-1.5.2.jar')
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "visa.testapplication"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':moduleA')
implementation project(':moduleB')
}
App Level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties file
#Tue Oct 16 14:44:59 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Build Error Received
:app:mergeDebugAssets
:app:transformClassesWithDexBuilderForDebug
AGPBI: {"kind":"error","text":"Program type already present: com.bbpos.bb03z.c","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\0.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\1.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\2.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\3.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\4.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\5.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\6.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\7.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\8.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\9.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\10.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\11.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\12.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\13.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\14.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\15.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\16.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\17.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\18.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\19.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\20.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\21.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\22.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\23.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\24.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\25.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\26.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\27.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\28.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\29.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\30.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\31.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\32.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\33.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\34.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\35.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\36.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\37.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\38.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\39.jar, C:\work\TestApplication\app\build\intermediates\transforms\dexBuilder\debug\40.jar
* 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
BUILD FAILED in 56s
In Android Studio, Change the View from Android to Project and inside your app >> libs paste your .jar files
Then right click on your .jar file and select Add As Library
It will sync your project and added as gradle dependency

Categories

Resources