Baffling java.lang.NoClassDefFoundError - android

I am using org.apache.http.entity.mime.MultipartEntityBuilder to upload images to the server, When I tested in version 7 devices, its works fine but in devices 4.x it throughs error like java.lang.NoClassDefFoundError at runtime. I am not sure where those classes went missing at runtime for 4.x devices.I am using Android Studio 2.3.3.I hope I have messed up Gradle hence the same works fine in 4.x devices when I use the same in a different application.
Build Gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.xx.xx.xx"
minSdkVersion 16
targetSdkVersion 23
versionCode 32
versionName "4.0.2"
multiDexEnabled true
}
lintOptions{
disable 'MissingTranslation'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.google.firebase:firebase-crash:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.1'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
}
apply plugin: 'com.google.gms.google-services'
Gradle wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

Related

Android Studio - No Resource found that matches the name

I am facing an issue in Android studio
I have tried to update the recent build-tools version to 27.0.1 and SDK version to 28 but it throws the exception
Update:
I have mentioned the app level build.gradle file content below,
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '27.0.1'
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "XXXX.XXXX.XXXX"
minSdkVersion 17
targetSdkVersion 25
versionCode 27
versionName "1.0.19"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.google.android.gms:play-services-gcm:11.8.0'
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:design:+'
compile 'com.liferay.mobile:liferay-screens:2.1.1'
compile 'com.liferay.mobile:liferay-material-viewset:2.1.1'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.volley:volley:1.0.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:exifinterface:+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.woxthebox:draglistview:1.5.1'
compile 'com.github.lzyzsd:circleprogress:+'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'me.gujun.android.taggroup:library:1.4#aar'
compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "http://dl.bintray.com/nhpatt/liferay-mobile" }
google()
}
}
apply plugin: 'com.google.gms.google-services'
Please anyone help to find out the solution.
It seems like a strange issue in Android Studio. Found a Workaround from this post.
Thanks to Veener who has posted the answer that actually solved the issue.
Just check whether the auto import libraries is working. Whether the studio is importing te required libraries in your maiƱ activity

Update plugin error

I'm new to android, so please bear with me if my question is stupid.
I have an android project built in older version of gradle. The app works fine when modifying code in existing activities, but whenever I create a new activity, I get the following error:
Error:(77, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
Upgrade plugin to version 3.0.1 and sync project
Show in File
Show in Project Structure dialog
This is the content of app level gradle file:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias ''
keyPassword ''
storeFile file('')
storePassword ''
}
}
compileSdkVersion 27
buildToolsVersion "23.0.2"
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 22
multiDexEnabled true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
jcenter()
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
incremental true
}
productFlavors {
}
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
//Fast and simple data storage library for Android
// compile project(':squarecamera')
// compile 'com.github.boxme:squarecamera:1.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.6'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'io.paperdb:paperdb:0.9'
compile 'com.fabiendevos:nanotasks:1.1.0'
compile 'com.flipboard:bottomsheet-core:1.5.0'
compile 'com.flipboard:bottomsheet-commons:1.5.0'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.okhttp:okhttp:1.6.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta2'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile project(':squarecamera')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
This is my project level gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
And my android studio version is 3.0.1.
When I update the plugin, I get a lot of compatibility issues.
Please help me resolve this. Thanks in advance!

Build APK error?

I tried to build apk it comes out this. What should I do? Please help!!
I don't where is the problem. The project is fine when I build the project, but it come error when I build apk.
Error:Execution failed for
task':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class
Here is the gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId 'com.androidbelieve.SeeDate'
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'it.neokree:MaterialNavigationDrawer:1.3.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.firebase:firebase-client-android:2.5.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebaseui:firebase-ui:0.6.0'
}
apply plugin: 'com.google.gms.google-services'
gradle project
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Did you tried Build/Clean Project in Android Studio Menu
Which dependency does the app:transformClassesWithJarMergingForDebug come from? Maybe you should modify that dependency's version number to be consistent with the major sdk version.

Android error when adding plugin com.google.gms.google-services

I am working with Firebase in my Android project. When I add
apply plugin: 'com.google.gms.google-services'
in gradle, it gives me an error. logcat says:
Error:Execution failed for task ':app:mergeDebugResources'.
> [string/google_api_key] E:\android\Workspace\FireGuard\app\src\main\res\values\strings.xml [string/google_api_key] E:\android\Workspace\FireGuard\app\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
I searched a lot, but no luck. How to remove this error? Please help.
below is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.pc.fireguard"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.volley:volley:1.0.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.android.support:support-v13:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.google.android.gms:play-services:9.6.1'
compile project(':date4j')
compile project(':simple-crop-image-lib')
compile 'com.squareup.picasso:picasso:2.3.2'
compile project(':httpclient-4.3.4')
compile project(':httpmime-4.3.4')
compile project(':httpcore-4.3.2')
compile 'com.paypal.sdk:paypal-android-sdk:2.15.1'
}
apply plugin: 'com.google.gms.google-services'
Strings.xml in your app is having same name as of values.xml of google services library!
Since this answer has helped you in sorting out the issue, I am posting the same comment as an answer.

Style errors with API level 23

As soon as I update my build.grade file to API level 23, I get errors that I cannot locate, and cannot fix them. However, these same errors do not show up with 22 or 21. The error that shows up is:
Attribute "titleTextColor" has already been defined, and for some reason, it highlights the colors.xml file. There are no instances of titleTextColor in my entire project. When I do a project wide (cmd + shift + f) search, the only instances of titleTextColor show up in generated build files. What's going on here, and how can I fix this?
[Edit] build.grade file
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'play'
repositories {
//ViewPagerIndicator AAR packaged
maven {
url 'http://dl.bintray.com/populov/maven'
}
jcenter()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
publishingConfigs {
}
signingConfigs {
basicRelease {
}
advancedRelease {
}
debug {
storeFile file('publish/debug.keystore')
}
}
productFlavors {
basic {
applicationId "com.basic"
versionCode 1
versionName "1.0.0"
}
advanced {
applicationId "com.advanced"
versionCode 2
versionName "1.0.1"
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'LICENSE.txt'
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
}
}
lintOptions {
abortOnError true
htmlReport true
checkAllWarnings true
warningsAsErrors true
}
configurations {
all*.exclude group: 'com.google.android', module: 'support-v4'
all*.exclude group: 'com.google.android', module: 'support-v13'
}
dependencies {
compile 'com.android.support:support-v13:23.0.+'
compile 'com.android.support:appcompat-v7:23.0.+'
compile 'commons-httpclient:commons-httpclient:3.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'joda-time:joda-time:2.3'
compile 'org.ocpsoft.prettytime:prettytime:3.2.1.Final'
compile 'com.facebook.android:facebook-android-sdk:3.23.0'
//https://github.com/weddingparty/AndroidFloatLabel
compile ':float-label:1.2.1.0#aar'
//Forked from https://github.com/inmite/android-styled-dialogs
compile 'eu.inmite.android.lib:android-styled-dialogs:1.2.0'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.makeramen:roundedimageview:1.2.1'
compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
debugCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile('com.squareup.okhttp:okhttp-urlconnection:2.3.0') {
exclude(group: 'com.squareup.okhttp', module: 'okhttp')
}
compile 'com.squareup.okio:okio:1.3.0'
compile 'io.reactivex:rxandroid:0.24.0'
compile 'info.metadude.android:typed-preferences:2.0.0'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-io:commons-io:2.4'
compile 'com.crittercism:crittercism-android-ndk-agent:5.0.6'
compile 'com.jakewharton:butterknife:6.1.0'
compile('com.segment.analytics.android:analytics-core:3.0.2#aar') {
transitive = true
}
compile 'pl.charmas.android:android-reactive-location:0.5#aar'
compile 'com.github.amlcurran.showcaseview:showcaseview:5.1.1#aar'
compile files('libs/appsflyer-2.3.1.16.jar')
debugCompile 'com.jakewharton.madge:madge:1.1.1'
debugCompile 'com.jakewharton.scalpel:scalpel:1.1.1'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.0') {
exclude group: 'javax.inject'
}
compile files('libs/comscore.jar')
}
From the error it looks like in one of your dependencies "titleTextColor" attribute could already be defined.
For example, this popular square library has an open ticket:
https://github.com/square/android-times-square/issues/226
So remove the culprit library or in-case if you need the library, you will need to revert back to API 22.
Hope this helps.

Categories

Resources