NoClassDefFoundError: javax.xml.bind.DatatypeConverter - java

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/

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.

Trying to decrease my APK size by removing an unused dependency in gradle

I'm trying to remove a library named ly.img.android:photo-editor-sdk version 1.1.0 that was used earlier in my app, but not used anymore, it wasn't giving any errors when compiled. It compiles fine(lint checking disabled), but when I try to run Vuforia camera(completely independet), it runs on one phone(samsung note edge) but not on another(Samsung S8).
This one library increases the APK size by 12Mb, so I'm looking to remove this one, I couldn't understand why it causes issues.
My app has a single gradle file though, it's been like that since the previous developer who dealt with the app.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.0'
/*classpath 'com.google.gms:google-services:3.1.0'*/
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.ar.sceneform:plugin:1.6.0'
}
}
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "http://jitpack.io" }
maven {
url "https://maven.google.com" // specifically this worked
}
google()
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
android {
signingConfigs {
config {
//config data
}
}
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
disable 'MissingTranslation'
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.app.id
vectorDrawables.useSupportLibrary = true
renderscriptTargetApi 23
minSdkVersion 19
targetSdkVersion 28
renderscriptSupportModeEnabled true
multiDexEnabled true
}
buildTypes {
release {
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
4
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...
androidTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
It can be caused by your resources which are larger from regular resources. In addition, you can go through this link:https://developer.android.com/studio/build/shrink-code which will help you to minimize the size of your apk.
had u enabled minify in app.gradle file
I found one blog to reduce the apk size in android. i found it is useful.you can try
reduce apk size in android
Whenever we install a new library in our Gradle then the library package comes in the app and thus our app size increases.
So there must be a new library which you have installed
which is making the size of app increasing.
There are mostly only two ways which increases our app size significantly
1 Adding resource file image or audio etc
2 Installing a new library package

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')
}
}

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']
}
}
}

Android Studio - Gradle: Execution failed for task ':Foo:dexDebug' - but why?

I receive this error :
Gradle: Execution failed for task ':Foo:dexDebug'.
And since 2day ! I have try a lot of solution... But nothing work fine ! Really ! Need Help !
I work with android Studio. (IntelliJ IDEA)
For this following three directory
FooProject [RootProject]
|-gradle
|-libraries
|-facebook [library1]
|-libs
|-android-support-v4.jar
|-res
|-*.(drawable...)
|-src
|-*.java
|-build.gradle
|-AnroidManifest.xml
|-facebook.iml
|-foosdk [library2]
|-res
|-*.(drawable...)
|-src
|-*.java
|-libs
|-YouTubeAndroidPlayerApi.jar
|-build.gradle
|-AnroidManifest.xml
|-foosdk.iml
|-Foo [project for execution]
|-libs
|-commons-io-1.3.2.jar
|-commons-lang3-3.1.jar
|-jackson-core-asl-1.9.11.jar
|-jackson-databind-2.1.4.jar
|-jackson-mapper-asl-1.9.11.jar
|-robospice-1.4.1-SNAPSHOT.jar
|-robospice-cache-1.4.1-SNAPSHOT.jar
|-robospice-spring-android-1.4.1-SNAPSHOT.jar
|-spring-android-core-1.0.1.RELEASE.jar
|-spring-android-rest-template-1.0.1.RELEASE.jar
|-YouTubeAndroidPlayerApi.jar
|-src
|-main
|-java
|-*.java
|-res
|-*.(drawable...)
|-build.gradle
|-AnroidManifest.xml
|-Foo.iml
|-gradlew
|-gradlew.bat
|-local.properties
|-settings.gradle
|-RootProject.iml
I have for my settings.gradle
include ':libraries:facebook', :libraries:foosdk', ':foo'
For the files "build.gradle" :
For libraries/facebook/build.gradle
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
For libraries/foosdk/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
For Foo/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile project(':libraries:foosdk')
compile project(':libraries:facebook')
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src']
res.srcDirs = ['src/main/res']
}
}
}
Is your Foo project in /Foo or /foo folder (note the upper case)? You may need to correct the include 'foo' to 'Foo'?
If that doesn't work, please paste the info or debug output of your Gradle build. If you're running AndroidStudio and don't have any output, go to the root of your project and run gradlew.bat assembleDebug --info (on Wins) or ./gradlew assembleDebug --info (on Linux/Mac) or --debug and paste the output here so we can see what went wrong exactly.

Categories

Resources