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
Related
Hello guys this is the error which I faced while I was running the app. I am fresher to android so I cant get the results.I already gone through some tech websites it suggested to change versions (compile SDK version and Build tools version ) yet I cant solve this. Can any one help me to solve this ?.
Error Message :
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Android Build.gradle file.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
apply plugin: 'com.android.application'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
repositories {
maven {
url 'https://maven.google.com'
}
maven { url 'https://maven.fabric.io/public' }
}
defaultConfig {
applicationId "com.smartgladiator.link"
minSdkVersion 21
targetSdkVersion 25
// Enabling multidex support.
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
versionCode 2
// versionName "1.0.37.1"
versionName "1.0.38"
}
dexOptions {
jumboMode true
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
zipAlignEnabled true
debuggable false
lintOptions {
disable 'MissingTranslation'
disable 'ResourceType'
}
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:customtabs:25.4.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:support-v13:25.4.0'
//compile 'com.android.support:multidex:1.0.1'
//to make supported components
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'org.glassfish.tyrus.tests.servlet:tyrus-tests-servlet-autobahn-server:1.12'
compile 'org.glassfish.tyrus.tests:tyrus-tests-servlet-autobahn-server:1.0-b13'
compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile 'com.baoyz.actionsheet:library:1.1.7'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile project(':speech')
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
}
Make sure android sdk localtion is set correctly
ANDROID_HOME = home/user/android_sdk/ "this is correct location"
ANDROID_HOME = home/user/android_sdk/tools "wrong path"
or
downgrade your gradle version
Just installed Android Studio for the first time on this new machine and was trying to import a project that used to work without any errors a year ago on another machine.
Had to fix plenty of errors by just downloading and installing updates (recommendations).
The one error that's left is in the title.
This is my build.gradle source:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
repositories {
mavenCentral()
}
defaultConfig {
applicationId "com.test.testaa"
vectorDrawables.useSupportLibrary = true
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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.facebook.android:facebook-android-sdk:4.+'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
testCompile 'junit:junit:4.12'
}
This occurred after I upgraded my android studio. I've attempted all similar answers on stack overflow, and a few other obscure forums, but I'm not getting anywhere with this error and I've been at it for 6 hours. I've monkeyed around with the sdk tools manager as well, but I'm not getting anywhere. Oh, and that maven thing is new, tried it from a similar answer.
Here is my gradle file:
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.loredylore.lorebuilder"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:26.0.0-alpha1'
compile 'com.android.support:support-vector-drawable:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.google.firebase:firebase-storage:11.0.2'
compile 'com.android.support:support-annotations:26.0.0-alpha1'
//new
testCompile 'junit:junit:4.12'
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
use version 25.0.3, you may have to recast some views to text views when if you have to migrate backward from version 26 android to 25.
I've started getting java.lang.NoClassDefFoundError: for random class and that class changes on my every teammates machine and it's only happening for 5.x devices, we tested on 6.0 and 7.0 but everything is working fine there.
This started happening after adding 'com.android.support.constraint:constraint-layout:1.0.2'
We decide to start using constraint layout in app and since then we're getting this error
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' }
}
def minSdk = hasProperty ('minSdk') ? minSdk : 19
//for debug builds add username to version as suffix
def username = readVersion()
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
dataBinding {
enabled = true
}
lintOptions {
abortOnError false
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
defaultConfig {
applicationId "xxx.xxxx.xxxxxx"
minSdkVersion minSdk
targetSdkVersion 25
maxSdkVersion 25
versionCode 27
versionName "0.0.00"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a", "x86","armeabi"
}
packagingOptions {
exclude "lib/arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
}
debug {
minifyEnabled false
debuggable true
versionNameSuffix "${username}"
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
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'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:support-v13:25.2.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-plus:10.2.0'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
compile 'com.squareup.picasso:picasso:2.5.2'
//image picker
compile 'com.soundcloud.android:android-crop:1.0.1#aar'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.mobsandgeeks:android-saripaar:2.0.2'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.google.code.gson:gson:2.7'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
//expandable textview
compile 'com.ms-square:expandableTextView:0.1.4'
//favourite button
compile 'com.github.ivbaranov:materialfavoritebutton:0.1.2'
compile 'org.osmdroid:osmdroid-mapsforge:5.5:release#aar'
compile 'org.mapsforge:mapsforge-map-android:0.6.1'
// compile 'org.mapsforge:mapsforge-map:0.6.1' //not in use
compile 'com.pubnub:pubnub:4.2.0'
compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
compile 'com.zopim.android:sdk:1.3.2.1'
compile 'com.zendesk:sdk:1.7.3.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.zopim.android:sdk:1.3.2.1'
compile 'com.zendesk:sdk:1.7.3.1'
// Android SDK
compile 'com.facebook.android:facebook-android-sdk:4.+'
/*// Audience Network SDK. Only versions 4.6.0 and above are available
compile 'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
compile 'com.facebook.android:account-kit-sdk:4.+'*/
// compile 'net.ypresto.androidtranscoder:android-transcoder:0.2.0'
// compile 'com.github.arimorty:floatingsearchview:1.1.2'
compile 'com.flurry.android:analytics:6.4.2'
//Webview dependancy
compile 'com.thefinestartist:finestwebview:1.2.7'
//autofit textview
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
//compile 'com.facebook.android:facebook-android-sdk:3.21.1'
//video compression
compile project(':ffmpeg4android_lib')
compile files('libs/SCTNotifier.jar')
compile "com.mixpanel.android:mixpanel-android:5.+"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.maps.android:android-maps-utils:0.5+'
}
String readVersion() {
def version = "whoami".execute().text.trim()
version = version.replace("\\", ".")
version = version.replace(" ", ".")
return "_reboot_" + version
}
Update:
I've removed constraint layout from xml's and removed this line:
compile 'com.android.support.constraint:constraint-layout:1.0.2'
And now app is working fine.
Four reasons are generate NoClassDefFoundError in android:
1) The class is not available in Java Classpath.
2) You might be running your program using jar command and class was not defined in manifest file's ClassPath attribute.
3) Any start-up script is overriding Classpath environment variable.
4) Because NoClassDefFoundError is a subclass of java.lang.LinkageError it can also come if one of it dependency like native library may not available.
Before build apk clean your project.
Android studio build issue Google sign in and Firebase latest version 10.2.4
google sign in was working fine until I have put firebase jar in gradle and its throwing "Error:(149, 28) The type com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable cannot be found in source files, imported jack libs or the classpath"
below is app level build
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "viksit.com.viksit.pro.viksitpro"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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'
}
android {
useLibrary 'org.apache.http.legacy'
}
compile project(':linkedin-sdk')
compile(group: 'org.simpleframework', name: 'simple-xml', version: '2.7.1') {
exclude group: 'xpp3', module: 'xpp3'
}
compile('com.udojava:EvalEx:1.0') {
exclude group: 'junit', module: 'junit'
}
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support:appcompat-v7:25.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:facebook-android-sdk:4.18.0'
compile 'com.afollestad.material-dialogs:commons:0.9.4.2'
compile 'com.google.firebase:firebase-database:10.2.4'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-auth:10.2.4'
compile 'com.google.android.gms:play-services-auth:10.2.4'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.android.support:support-v4:25.0.2'
compile 'com.felipecsl:gifimageview:2.1.0'
compile 'me.itangqi.waveloadingview:library:0.3.5'
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'com.android.support:design:25.3.0'
compile 'com.github.vipulasri:timelineview:1.0.5'
compile 'com.jaredrummler:material-spinner:1.1.0'
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
compile 'com.truizlop.sectionedrecyclerview:library:1.2.0'
compile 'com.github.castorflex.verticalviewpager:library:19.0.1'
compile 'link.fls:swipestack:0.3.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
testCompile 'junit:junit:4.12'
}
below is project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Looks like you skipped this step
apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file
https://developers.google.com/android/guides/google-services-plugin
Sidenote: You have Glide and Picasso, two-way gif drawable libraries, and two shaped imageview libraries. Each pair do the same thing. Clean out your dependencies to reduce your app size and chances of errors
I had a similiar problem with firebase yesterday and this worked for me:
Just add this to gradle file and rebuild it:
android {
....
dexOptions {
// Prevent OutOfMemory with MultiDex during the build phase
javaMaxHeapSize "4g"
}
}