How to include android.support in build.gradle using Eclipse - java

I work with Android 4.4.2 (API 19) and Eclipse. I use the following build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
compile 'com.android.support:support-v7:19.0.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "25.0.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
I have the java class
package com.example.ejemplo2;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
I get the error in the Eclipse editor
android.support cannot resolve
How do I have include android.support in build.gradle?. I can't fix this error in Eclipse.

Please use Android Studio... for your own sake.
For what it is worth:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
compile 'com.android.support:support-v7:19.0.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
should be
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOT HERE
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v7:19.0.0' // HERE
}
The reason is you where adding the support lib as a dependency of the build script not a dependency of your java class path

Related

java.lang.NoSuchMethodError: No static method zza(Landroid/content/Context;)V in class Lcom/google/android/gms/common/zzc; its super classes

I'm trying to use firebase-core library in my Android project but it keeps giving me this NoSuchMethodError in my released apk. However, it works fine in emulator. The exception message is this:
java.lang.NoSuchMethodError: No static method zza(Landroid/content/Context;)V in class Lcom/google/android/gms/common/zzc; or its super classes (declaration of 'com.google.android.gms.common.zzc' appears in /data/app/com.xxxx.xxxx/base.apk): com.google.android.gms.measurement.internal.zzfx.zzs(Unknown Source)
I added firebase-core:16.0.7 using Android studio's firebase assistant. And my gradle file is as follow:
buildscript {
repositories {
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://maven.google.com"
}
}
}
/**
* This line applies the com.android.application plugin. Note that you should
* only apply the com.android.application plugin. Applying the Java plugin as
* well will result in a build error.
*/
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
/**
* This dependencies block includes any dependencies for the project itself. The
* following line includes all the JAR files in the libs directory.
*/
dependencies {
compile 'com.google.firebase:firebase-core:16.0.7'
compile project(':Shared')
compile 'com.google.guava:guava:16.0.1'
compile 'joda-time:joda-time:2.10.1'
compile 'com.android.support:appcompat-v7:28.0.0'
compile files('libs/js.jar')
compile files('libs/gps-stripped.jar')
compile files('libs/antlr-runtime-3.2.jar')
compile files('libs/jackson-all-1.9.11.jar')
compile files('libs/logback-android-1.1.1-6.jar')
compile files('libs/slf4j-api-1.7.21.jar')
compile 'com.github.jsqlparser:jsqlparser:0.9.6'
compile files('libs/Android-Languages.jar')
androidTestCompile 'junit:junit:4.12'
}
/**
* The android{} block configures all of the parameters for the Android build.
* You must provide values for at least the build tools version and the
* compilation target.
*/
android {
compileSdkVersion 28
buildToolsVersion "26.0.3"
buildTypes {
release {
minifyEnabled false
lintOptions {
disable 'MissingTranslation'
abortOnError false
}
}
debug {
minifyEnabled false
lintOptions {
disable 'MissingTranslation'
abortOnError false
}
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
//instrumentTest.setRoot('tests')
/**
* Move the build types to build-types/<type>
* For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
* This moves them out of them default location under src/<type>/... which would
* conflict with src/ being used by the main source set.
* Adding new build types or product flavors should be accompanied
* by a similar customization.
*/
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
packagingOptions {
pickFirst 'META-INF/license.txt'
pickFirst 'META-INF/LICENSE'
}
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
multiDexEnabled true
}
productFlavors {
}
}
Any clue on how to resolve this? Thanks.

Error:(87, 8) error: cannot find symbol method addOnPageChangeListener(<anonymous SimpleOnPageChangeListener>)

My project worked perfectly ( no trouble with the view pager ) until I added 2 new libraries ... things started to get bad, now it returns " cannot find symbol method addOnPageChangeListener" and even if I remove the method from my code it returns "non-zero values 2". I did understand that maybe it comes from duplicated app-support v4 but none of my libraries or projects compile an android app-support v4
/Users/Hassan/Desktop/And/ListBuddies-master/example/src/main/java/com/jpardogo/android/listbuddies/PageV.java
Error:(87, 8) error: cannot find symbol method addOnPageChangeListener()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Error:Execution failed for task ':example:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
MainProject grable
apply plugin: 'android'
apply plugin: 'com.parse'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.parse.com/repo'
}
}
dependencies {
classpath 'com.parse.tools:gradle:1.+'
}
}
android {
compileSdkVersion 23
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.parse.starter"
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
lintOptions {
abortOnError Boolean.parseBoolean(project.ABORT_ON_ERROR)
}
signingConfigs { release }
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
dependencies
{
compile fileTree(dir: 'libs', include: '*.jar')
// compile 'libraries.android_support'
compile 'com.squareup.picasso:picasso:2.3.3'
compile 'com.daimajia.slider:library:1.1.5#aar'
// compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.1.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.etsy.android.grid:library:1.0.5'
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'com.parse:parse-android:1.10.3'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.github.jorgecastilloprz:fillableloaders:1.02#aar'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1#aar'
compile 'com.github.tibolte:elasticdownload:1.0.+'
compile 'com.github.jorgecastilloprz:fabprogresscircle:1.01#aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile project(':library')
compile project(':facebook')
// compile project(':ListViewAnimations-core')
//compile project(':progress')
compile project(':SwipeTouchListenerTestActivity')
// compile project(':ListViewAnimations-core')
}
File propFile = file('signing.properties');
if (propFile.exists()) {
def Properties props = new Properties()
props.load(new FileInputStream(propFile))
if (props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
android.buildTypes.release.signingConfig = null
}
} else {
android.buildTypes.release.signingConfig = null
}
FirstLibrary Gradle
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':ListViewAnimations-core')
// compile 'com.android.support:support-v4:23.1.0'
}
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
2nd Library Gradle
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// compile 'com.android.support:support-v4:23.1.0'
}
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

NoClassDefFoundError: javax.xml.bind.DatatypeConverter

I am using Amazon's Java SDK in my Android app to communicate with SimpleDB. I added the sdk to the gradle file, and it runs until calls DatatypeConverter.printBase64Binary and I get the following error:
java.lang.NoClassDefFoundError: javax.xml.bind.DatatypeConverter
at com.amazonaws.util.Base64.encodeAsString(Base64.java:36)
at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:69)
Shouldn't the javax library be included automatically, or at least in the aws build?
Here's my gradle file in case this helps:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
// Support Libraries
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.android.support:support-v4:22.0.0'
compile 'commons-codec:commons-codec:1.5'
compile 'com.amazonaws:aws-java-sdk:1.9.24'
compile 'com.facebook.android:facebook-android-sdk:3.23.1'
compile 'com.github.markushi:android-ui:1.2'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.afollestad:material-dialogs:0.6.4.5'
compile 'com.android.support:multidex:1.0.0'
compile project(':libraries:MaterialNavigationDrawerModule')
compile('com.crashlytics.sdk.android:crashlytics:2.2.2#aar') {
transitive = true;
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
targetSdkVersion 21
minSdkVersion 14
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions{
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
unfortunately the package javax.xml.bind.* are not available on android so you cannot use the amazon java sdk.
but for android you could use the aws mobile SDK, please visit http://aws.amazon.com/mobile/sdk/

issue using gradle in an android project

I almost know nothing form Android, I created a project and then I wanted to use some plugin based on Gradle, so I added some build.gradle file. I added there
apply plugin: 'android'
dependencies {
mavenCentral()
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 18
buildToolsVersion '18'
defaultConfig {
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
The doc says import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout; to private PullToRefreshLayout mPullToRefreshLayout; But, this package can not be resolved. Someone can help ?
Change this:
dependencies {
mavenCentral()
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
To this:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}

issue with actionbarpull's gradle file

I have some build.gradle file this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
android {
compileSdkVersion 18
buildToolsVersion '18'
defaultConfig {
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
that throws this error :
A problem occurred configuring root project 'NewsFeeder'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':_DebugCompile'.
> Could not find any version that matches com.github.chrisbanes.actionbarpulltorefresh:library:+.
Required by:
:NewsFeeder:unspecified
But, this reference to chrisbanes's actionbarpulltorefresh seems to be correct : https://github.com/chrisbanes/ActionBar-PullToRefresh/wiki/QuickStart-Stock. How can it be since in this project is available in [maven central repo][1] ?
For information, I set in some local.propertiesfile sdk.dir=/home/adt-bundle-mac-x86_64-20130522/sdk, which is the same that what echo $ANDROID_SDK returns
You need to tell gradle where it can look to find the dependency. If you want gradle to use the mavenCentral repository then add this to your build.gradle file:
repositories {
mavenCentral()
}
The buildscript repositories is just for the build script dependencies, not project dependencies. You want to add the repositories entry at the outer most, or project, level.
Your build.gradle would look like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
android {
compileSdkVersion 18
buildToolsVersion '18'
defaultConfig {
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}

Categories

Resources