I seem to be running into an issue where only release builds crash with the error java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit2/Retrofit$Builder; The class is irrelevant because it has not resolved other classes too in the release build. However, this does not appear on Debug builds which makes no sense at all. I have found that when I include these two dependencies:
implementation 'com.google.android.gms:play-services-ads:12.0.0'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.8.5'
the app crashes. However, when I exclude one of them, then the release builds work. Has anyone encountered this before?
The build config looks like this:
compileSdkVersion 26
buildToolsVersion 26.0.1
defaultConfig {
applicationId "xxxx"
minSdkVersion 21
targetSdkVersion 27
versionName project.rootProject.version.toString()
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig xxxx
}
}
Update your gradle
targetSdkVersion 27,
compileSdkVersion 27, and
buildtoolsVersion to 27.0.1 or remove it (leave it as default. gradle will always look for the latest within this version 27)
The above solved my problem too. Although, i don't use multiDexEnabled true as i see no reason why when i have google play service library included.
Try removing multiDexEnabled true and re-build gradle.
Unless your are class extending Application class.Then you can use multiDexEnable true
#Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
MultiDex.install(this);
}
check this question for possible solution
Related
I created an Android app using the android studio (2016) with the following parameters
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.2.1'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.stl.sciocardio.app.androidapp"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Also, I use third party projects inside the project as well. When I change the Android studio 2020 the app is not built or even not detected as an android project. It gives me the following error once I try to rebuild it
Unable to find Gradle tasks to build: [:app, :, :GraphView-master].
Build mode: REBUILD.
Tests: None.
How can I fix the issue?
Try this:
Delete folders [build, .idea, .gradle]
Invalidate Caches / Restart
If it does not get resolved, then repeat the above step by removing
include ':app' from settings.gradle
I'm facing this problem even when I tried switching from
com.android.support:appcompat-v7:28.0.0-alpha 3 to
com.android.support:appcompat-v7:28.0.0-alpha 1.
It works, but after adding some new activities it causes the same problem. I went to Invalidate caches/restart and restart my Android studio but it didn't work...
Please any expert who help me thanks... I'm really in trouble for the last couple of days.
Use the previous gradle version 27, and change your project gradle config to this. The new alpha-one might cause problems with new activities sometimes.
Just clean and rebuild after gradle sync.
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.package.name"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-compat:27.1.1'
implementation 'com.android.support:design:27.1.1'
}
I have a problem is with installing my application on random devices. The app works on my phone (Android 6.0) and on emulator (7.1.1), but it can't be installed on friends' phones with e.g. same Android version or 5.0 probably. Is there any IDE-side reason (IntelliJ IDEA, earlier Android Studio with same error)?
There is fragment of build.gradle in my project. Maybe it'll help somehow...
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.pkgname"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "Pre-release"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
pre_release {
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Greetings!
Just you make debug-version your .apk. Look at - https://techtuts.info/2014/05/build-release-apk-android-studio/
Will you please let us know whether you're trying to use the build apk generated at the time of installing app directly to your know or you are creating a fresh build.
Note: if you want to support all devices as per your build config then you must have you create a clean build and then try to install app within your required devices.Hope it will help.
After I add Firebase to receive Push Notifications to my app, it gives me this error:
I tried to put multiDexEnabled true on defaultConfig
and compile 'com.android.support:multidex:1.0.0' on dependencies, but the problem still persists.
This is my build.gradle
apply plugin: 'com.android.application'
defaultConfig {
applicationId "com.egcd.egypt"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Any help?
Try removing compile compile 'com.google.android.gms:play-services:10.2.0'
from your project dependencies.
You should never depend on com.google.android.gms:play-services because that is a gigantic library that groups together every Google library for android in a single archive.
Instead you should use com.google.android.gms:play-services-[LIBRARY.YOU.NEED]
A few months ago, I decided to take some custom methods and classes that I was using in more than one project and put them in their own project called "FarmSoftLibraries" that all of my projects could reference. This allowed me to make changes or additions once. It has been working very well up until yesterday (8/23/2015) when i started getting an odd error on a new method that Gradle could not find. However Android Studio had no problem finding this method. See: https://stackoverflow.com/questions/32167734/cannot-find-symbol-method-for-custom-static-class-method. However older, non-new methods continued to work.
Today the entire build system stopped working and I'm getting hundreds of Gradle errors saying that packages and methods in FarmSoftLibraries do not exist. Still, Android Studio has no problem locating these.
D:\Scott\Android\Studio\SpellingTutor\app\src\main\java\com\farmsoft\spellingtutor\Learn.java:12: error: package com.farmsoft.farmsoftlibraries.Utils does not exist
import com.farmsoft.farmsoftlibraries.Utils.FarmUtils;
^
D:\Scott\Android\Studio\SpellingTutor\app\src\main\java\com\farmsoft\spellingtutor\Learn.java:14: error: package com.farmsoft.farmsoftlibraries.Utils does not exist
import com.farmsoft.farmsoftlibraries.Utils.Logg;
^
D:\Scott\Android\Studio\SpellingTutor\app\src\main\java\com\farmsoft\spellingtutor\utils\KeyValueDB.java:6: error: package com.farmsoft.farmsoftlibraries.Utils does not exist
import com.farmsoft.farmsoftlibraries.Utils.CsvUtil;
etc. etc. etc...
I want to stress that I've changed NOTHING in the gradle files. I have been upgrading Android Studio on the Canary path - I'm on 1.4 Preview 3 now. When this issue began I was on 1.4 Preview 2. I have no idea if this is related to this version of Studio.
My gradle scripts:
project settings.gradle:
include ':app'
include ':farmsoftlibs'
project(':farmsoftlibs').projectDir = new File('../FarmSoftLibraries/app')
app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.farmsoft.spellingtutor"
minSdkVersion 15
targetSdkVersion 22
versionCode 28
versionName "1.15"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
applicationIdSuffix '.debug'
versionNameSuffix '.debug'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile project(':farmsoftlibs')
}
farmsoftlibs build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/gson-2.3.1.jar')
compile 'com.google.android.gms:play-services-vision:7.8.0'
}
I do want to admit I pretty much am ignorant about gradle - I follow the instructions for how to set it up in Android Studio, but I really don't know what I'm doing and have gotten lost in the Gradle documentation I tried to read. So this is incredibly frustrating and more so knowing that this is probably due to some stupid mistake I've made out of ignorance.
EDIT:
This seems to have something to do with ProGuard - if I change the library's release settings to say minifyEnabled false, then the error goes away... for now. I'd like to know why.