I'm trying to export my apk but I'm receiving one build error below:
I've added compile 'com.android.support:multidex:1.0.1' in my build.gradle dependencies, enabled multidex in my defaultConfig and also added android:name="android.support.multidex.MultiDexApplication"> within my Android Manifest file but am still receiving the error.
===============================
My build.gradle can be found here:
http://pastie.org/10902207
================================
What is going on? Can anyone give me some insight as to why I am receiving this?
I imagine the issue you are having is because you do not have a minSDK defined in your Build.gradle. The library you are trying to uses minSDKVersion 4.
If you don't specify your minSDKVersion your project is going to automatically default to version 1. Try adding something like the below to your build.gradle file.
android{
compiledSdkVersion 23 //marshmallow
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 11 //honeycomb
targetSdkVersion 23
}
}
Related
My app is not supporting Android 4.x and 5.x anymore, only Android 6.0 and higher. For that reason, in my app/build.gradle I changed minSdkVersion 16 to minSdkVersion 23. After doing that, I have started to get this error when I try to run the app:
error: package android.support.multidex does not exist
error: cannot find symbol variable MultiDex
In one of my .java files, I see the errors in the following lines:
import android.support.multidex.MultiDex;
MultiDex.install(this);
Should I simply not use MultiDex because Android 6.0 and higher do not need that anymore? This is considering that my app will not support Android 5.x and lower anymore. Thank you.
The solution to this problem is to add the following in Dependencies in build.gradle (:app):
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
https://developer.android.com/studio/build/multidex
I needed to change
import android.support.multidex.MultiDex
to
import androidx.multidex.MultiDex
to reference the "newer" MultiDex's location (version 1.0.3 in my case).
Try setting multiDexEnabled true in build.gradle(app)
Recently I've been getting this problem.
As far as I know, there is no 26.X.X versions of these support libraries, what does Gradle wants from me?
After reviewing a previous question, you may want to be sure that your compileSdkVersion matches across the board, if you want to build in 25 but you are in 23.
This support library should not use a different version Error in build.gradle
You can confirm versions by >> Create new project in Android studio >> Press Ctrl+Shift+Alt+S >> Proceed to 'Project' section >> You can see actual gradle version and android pluging version. Copy that to your project.
The problem lies in your Compile version in build.gradle file.
It seems, your compile version is 26.
Please change your compile version to 25 and sync gradle.
compileSdkVersion 25
buildToolsVersion "25.0.3"
Please set your Compile Version to 25
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.user.xxxxx"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
My app gives NoClassDefFoundError for versions of sdk 19 or below.
I had in my gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.idg.mail"
minSdkVersion 14
targetSdkVersion 23
multiDexEnabled = true
}
Now i tried to change it to
compileSdkVersion 19
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.idg.gatcamail"
minSdkVersion 19
targetSdkVersion 19
multiDexEnabled = true
}
i changed in app-> module settings - android - sdk as well.
With these changes i built the project but still it gives same error on my android 4.4 and it runs on higher versions.
The class is a class defined in the code where i handle network operations.
How can i do the debugging of this issue
I'm almost sure that it is multidex issue. If it's running properly on sdk 21 - it's multidex issue.
Here is official info: Multidex
If you're using custom implementation of Application class, it has to extend MultiDexApplication class. Also there is gradle flag required. If you're not using custom Application class, just add entry provided in your manifest - it's described in documentation.
Edit: Almost forgot - you've to add dependency, multidex is provided with this library: compile 'com.android.support:multidex:1.0.1'
Masters,
Recently I am trying to build android project with gradle, and since there one API(#JavascriptInterface annotation) I need to use is only up to api level 17, so I changed my targetAPILevel to 19 in project properties. And it works well when I build the project from Eclipse(Right click on project and Run Android Application).
But when I tried to build the project by gradlew in terminal, it seems it never use target level 19 to build the project. Here is part of the build.gradle file as follow:
android {
// target = 'android-19'
compileSdkVersion 19
buildToolsVersion '19.0.1'
}
Can anyone help me what I did wrong in here, please? Thank you very much.
TargetSdkVersion and compileSdkVersion are different parameters.
In eclipse, you set the target in your Manifest, and set the api used to compile with right click -> properties -> Android Manu.
In your build.gradle you should use something like this:
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}
I am not sure what's the issue. I googled and though it was about matching the sdk versions. They are the same as follows:
build.gradle
android {
compileSdkVersion 17
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 4
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':slidingMenu')
compile project(':slidingMenu')
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
compile files('libs/Parse-1.4.0.jar')
}
Manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gurbani.ujagar"
android:hardwareAccelerated="true"
android:installLocation="preferExternal"
android:versionCode="26"
android:versionName="7.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
You will be ended up with this error, If your libraries/modules uses different minSdkVersion or targetSdkVersion inside your project.
To find , In which module actual conflicts are happening you can see your Gradle Console output.
Best practice is to have minSdkVersion 8 at least because most of the libraries like play services etc using this.
Please do the following change and sync Project with gradle
Try to Use minsdkVesion 8 in all your build.gradle files as well as AndroidManifest.xml files ans sync.
If it doesn't solves the problem go through your gradle console to and make required changes as per the error shown.
Note : While compilation, your minSdkVersion and targetSdkVersion in AndroidManifest.xml will be overridden by what you have mention in your build.gradle files.
I think slidingMenu library minSdkVersion is greater than yours (minSdkVersion 4). So manifests cant be merged. You cant use library that requires min version 11 (e.g.) in app that works on api version 4.