Failed to import jsoup library in android studio? - android

I was trying to integrate j soup library in android studio. I am getting error.
StackTrace:
Gradle: A problem occurred configuring root project 'JsoupProject'.
Failed to notify project evaluation listener.
Main Manifest missing from C:\Users\Asthme\Androidstudio\JsoupProject\src\main\AndroidManifest.xml
settings .gradle:
include ':Jsoup'
include ':libraries:jsoup-1.7.2.jar'
Build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: 'jsoup-1.7.2.jar')
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
Library build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}

dependencies {
...
implementation 'org.jsoup:jsoup:1.11.3'
}
(check the latest version number here: https://jsoup.org/download)

Don't include the Jsoup library from your settings.gradle, that's only for module. Just put it in the dependencies statement from any module that needs it. I see you've done it in your build.gradle file in your question, so you should be fine there.

My solution was: Copy for /app/libs the jsoup-1.10.3.jar, after import in the MainActivity.java "import org.jsoup.Jsoup;" and it working. With the code compile fileTree(dir: 'libs', include: ['*.jar']) in the buil.gradle(app) it work. jsoup in the /app/libs build.gradle(app)
Note: I am using Android Studio 2.2.1

Related

Android Support Library - Failed to Resolve [duplicate]

This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
(26 answers)
Closed 5 years ago.
I am trying to add the following support libraries to my buid.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 26
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 11
targetSdkVersion 26
}
signingConfigs {
release {
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:support-v7:26.0.0'
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:cardview-v7:26.0.0'
compile 'com.melnykov:floatingactionbutton:1.1.0'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:1.0.5'
//Apptentive
compile 'com.apptentive:apptentive-android:2.1.3#aar'
//compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.0.0'
}
I am receiving errors stating that each library "Failed to Resolve" followed by each line of code from above. I was hoping to remain current with the latest support libraries for regular support, appcompat, and cardview.
To use support libraries starting from version 26.0.0 you need to add Google's Maven repository to your project's build.gradle file as described here.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
What is your buildToolsVersion and compileSdkVersion?
android {
buildToolsVersion "26.0.1"
}
Maybe try updating that in AndroidManifest.xml? Sometimes they arent compatible and you will have to modify the versions accordingly.
This link might help :Setting up Gradle for api 26 (Android)

Android Studio Gradle DSL method not found: 'mavencentral()'

I am trying to use facebook SDK in my android apps, and I am starting to add maven central repository to my build.gardle. Although, I've found 2 build.gardle which belong to project and app. Here they are;
Android Studio: 1.5.1
Gradle Version: 2.8
Android Plugin Version: 1.5.0
Build.gardle (Project)
buildscript {
repositories {
jcenter()
mavencentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
}
allprojects {
repositories {
jcenter()
mavencentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build.gardle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 15
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.2.0'
compile 'com.android.support:design:23.2.0'
}
Yet I get this following error during build;
Gradle DSL method not found: mavencentral()
I have tried;
Checking both gardle files
Removing android compile dependencies that's actually should be there
Checking android packagingOptions.exclude
Checking if there's android method in the gardle
And, I haven't tried to update my gardle or android studio, but I am just wondering whether it's really needed or I am doing something wrong with my build.gardle.
Any suggestion is appreciated. Thank you.
The Facebook SDK page is clear. Add into your project/build.gradle
repositories {
mavenCentral() //note the uppercase C
}
and into your project/app/build.gradle
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
}

Gradle DSL method not found: 'buildToolsVersion()'

I am new in Android-Studio
In that I have imported facebook and one other third party sdk
but I am getting following error
Error:(16, 0) Gradle DSL method not found: 'buildToolsVersion()'
Possible causes:The project 'EmojiShare' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file, The build file may be missing a Gradle plugin.
Apply Gradle plugin
my build.gradle file's code is below
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
in app/build.gradle the code is
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "emoji.drcsystems.com.emojishare"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':EmojiconApp')
}

Android studio 1.1.0 cannot setup Robolectric

I have used Robolectric before Android 1.1.0 but I cannot use it any more after I updated it. I Googled it and tried some solutions but none of them worked.
Here is my current settings:
project.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my_package_name"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'android-unit-test'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:21.0.3'
testCompile 'org.easytesting:fest:1.0.16'
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'com.squareup:fest-android:1.0.8'
}
When I try to build the project it gives me the error like below:
Error:(22) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'android-unit-test']
> No such property: bootClasspath for class: com.android.build.gradle.AppPlugin
Of course, I have android-unit-test plugin installed and removed and reinstalled it again but no luck.
Your answer would be appreciated.
Bad news: since Android Plugin 1.1.0 the plugin com.github.jcandksolutions.gradle:android-unit-test:2.1.1 is depricated. Also see https://github.com/JCAndKSolutions/android-unit-test#deprecation-notice
Good news: You don't need anymore a plugin for robolectric. Just remove apply plugin: 'android-unit-test' and all should work like before.
Here an examples project setup https://github.com/nenick/AndroidStudioAndRobolectric

Build script error, unsupported Gradle DSL method found: 'useOldManifestMerger()'!

My build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
useOldManifestMerger false
}
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Without line useOldManifestMerger false it builds ok.
gradle version: 1.10.
gradle android plugin: don't know where to look.
I think it is trying to use pre 0.10 of gradle android plugin. How can I reinstall it?

Categories

Resources