error while building the apk in android - android

This is the my build.gradle and when I build the apk by clicking on the build apk this error shown.I have seen the some of the queries before but not able to figure out the problem solution
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.ranjeet.location"
minSdkVersion 14
targetSdkVersion 25
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.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.google.android.gms:play-services-maps:10.2.6'
}

You have too many methods. There can only be 65536 methods for dex.
So, enable multidex as following:
android {
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}

You have too many methods. There can only be 65536 methods for dex.
So, enable multidex as following:
android {
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
And paste this code as well,
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}

com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
The underlying problem is imposed by the current set of Dalvik instructions. Specifically, any of the invoke-* methods. These expect a 16-bit argument, representing the target method's reference index. Being limited to 16-bits, valid values are between 0 and 65536. This means, that if you end up calling more than 65,536 defined methods, you are going to exceed this limit.
Solutions:
MultiDex allows you to use multiple DEX files contained within one APK. With a few steps, your classes will split automatically into several DEX files (classes.dex, classes2.dex, classes3.dex, etc) in case you reach the method index limit.
Get more infomation : https://www.contentful.com/blog/2014/10/30/android-and-the-dex-64k-methods-limit/

If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your app-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
}
...
}
However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:
Modify the app-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Create an Application class like this:
public class MyApplication extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Add this application class in Manifest.
You can also check this link:
https://developer.android.com/studio/build/multidex.html

Related

Error:Cannot fit requested classes in a single dex file.Try supplying a main-dex list. # methods: 72477 > 65536

I want to add fused location services but it shows me some error.
Help me.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.example.adil.bloodbankapplication"
minSdkVersion 15
targetSdkVersion 26
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')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
compile 'com.github.joielechong:countrycodepicker:2.1.5'
compile 'com.jaredrummler:material-spinner:1.2.4'
compile 'hanks.xyz:htextview-library:0.1.5'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.google.android.gms:play-services:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
None of the answers they gave you was exhaustive.
The problem lies in the Multidex.
You must add the library in the app gradle :
implementation 'com.android.support:multidex:1.0.3'
After, add in the defaultConfig of the app gradle :
multiDexEnabled true
Your Application must be of the Multidex type..
You must write it in the manifest :
android:name=".MyApplication"
"MyApplication" must be either the Multidex class, or it must extend it.
I fixed my problem with the solution below:
In Gradle build file, add dependency:
implementation 'com.android.support:multidex:1.0.3'
And then in the "defaultConfig" section, add:
multiDexEnabled true
modify your app's or module's build.gradle
android {
defaultConfig {
...
minSdkVersion 21 <----- *here
targetSdkVersion 26
multiDexEnabled true <------ *here
}
...
}
According to official documentation
Multidex support for Android 5.0 and higher
Android 5.0 (API level 21)
and higher uses a runtime called ART which natively supports loading
multiple DEX files from APK files. ART performs pre-compilation at app
install time which scans for classesN.dex files and compiles them into
a single .oat file for execution by the Android device. Therefore, if
your minSdkVersion is 21 or higher, you do not need the multidex
support library.
For more information on the Android 5.0 runtime, read ART and Dalvik.
https://developer.android.com/studio/build/multidex
What are dex files: Android app (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app.
Reason for this exception: The DEX specification limits the total number of methods that can be referenced within a single DEX file to 65,536 (64K reference limit) —including Android framework methods, library methods, and methods in your own code.
Step 01. Add the following dependency as follows
For Non-Androidx Users,
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true //ADD THIS LINE
}
For Androidx Users,
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true //ADD THIS LINE
}
Step 02:
After adding those Sync projects and before you run the project make sure to Build a project before the run. otherwise, you will get an exception.
You can follow this.
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can add the multidex support library to your project:
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
}
...
}
when you are using dependencies so your methods increased!
google has a solution for that. that called Multidex!
NOTE: be sure that min SDK is over 14.
in your build.gradle :
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
FOR androidX USE :
def multidex_version = "2.0.1"
implementation 'androidx.multidex:multidex:$multidex_version'
For more information please go to the orginal link :
https://developer.android.com/studio/build/multidex
Hi problem is here remove it
compile 'com.google.android.gms:play-services:11.8.0'
why?
Note: Don't use the combined play-services target. It brings in dozens of libraries, bloating your application. Instead, specify only the specific Google Play services APIs your app uses.
And use what you need.https://developers.google.com/android/guides/setup
Like for location service
com.google.android.gms:play-services-location:11.8.0
For Cloud Messaging
com.google.android.gms:play-services-gcm:11.8.0
I used below solution in my Flutter project:
Open yourproject/app/build.gradle and add the following lines:
android {
...
defaultConfig {
...
minSdkVersion 21
multiDexEnabled true
}
}
then
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
If you have migrated to AndroidX, you will want this instead:
dependencies {
...
implementation 'androidx.multidex:multidex:2.0.1'
}
This solution worked for me. Thank you for asking this question.
If you are building DEBUG APK, just add:
debug {
multiDexEnabled true
}
inside buildTypes
and if you are building RELEASE APK, add
multiDexEnabled true in release block as-
release {
...
multiDexEnabled true
...
}
For flutter projects you can also solve this issue
open your \android\app\build.gradle
you sould have the following:
android {
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 28
}
}
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in the defaultConfig. Like this
android {
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
}
if your minSdkVersion is set to 20 or lower add multiDexEnabled true to the defaultConfig
And define the implementation
dependencies {
implementation 'com.android.support:multidex:1.0.3'// or 2.0.1
}
At the end you should have:
android {
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true // added this
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
For more information read this:
https://developer.android.com/studio/build/multidex
I solved my same problem like this way, you need to follow 2 simple step. I'm AndroidX user so for me, first I implement this dependencies in build.gradle file in my project in dependencies section.
implementation 'androidx.multidex:multidex:2.0.1'
dependencies {
//for multidex
implementation 'androidx.multidex:multidex:2.0.1'
}
after add this dependencies in your build.gradle file then sync your project again
Now add in the "defaultConfig" section:
multiDexEnabled true
defaultConfig {
applicationId "com.papel.helper"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Now Rebuild your project again and Run :)
Just do the following:
build.gradle
(module:app)
android {
....
defaultConfig {
multiDexEnabled true // enable mun
}
}
And add below dependency in your build.gradle app level file
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
I found this solution for my project
I just set the minimum SDK version to 21 and that solves my problem
android {
defaultConfig {
...
minSdkVersion 21 //set the minimum sdk version 21
targetSdkVersion 29
}
...
}
if your minSdkVersion is 21 or higher multidex is enabled by default, and you do not need the multidex support library.
To read more about multidex https://developer.android.com/studio/build/multidex.html
In Gradle build file, add dependency:
implementation 'com.android.support:multidex:1.0.2'
or
implementation 'com.android.support:multidex:1.0.3'
or
implementation 'com.android.support:multidex:2.0.0'
And then in the "defaultConfig" section, add:
multiDexEnabled true
Under targetSdkVersion
minSdkVersion 17
targetSdkVersion 27
multiDexEnabled true
Now if you encounter this error
Error:Failed to resolve: multidex-instrumentation Open File
You need to change your gradle to 3.0.1
classpath 'com.android.tools.build:gradle:3.0.1'
And put the following code in the file gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
Finally
add class Applition in project And introduce it to the AndroidManifest
Which is extends from MultiDexApplication
public class App extends MultiDexApplication {
#Override
public void onCreate( ) {
super.onCreate( );
}
}
Run the project first to create an error, then clean the project
Finally, Re-launch the project and enjoy it
Just add this code in your app's or module's build.gradle
android {
defaultConfig {
...
multiDexEnabled true <------ * here
}
...
}
multiDexEnabled true
Please try adding this in your app defaultConfig {}.This help me to solve the problem
This will do the work either for Kotlin or Java project.
Step 1 - Locate build.gradle(Module:app) under the Gradle Scripts
Step 2 - add multiDexEnabled true see below:
compileSdkVersion 29
defaultConfig {
applicationId "com.example.appname"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true //addded
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Step 3 - add the multidex dependency
dependencies {
implementation 'com.android.support:multidex:2.0.0' //added
}
Finally, sync your project.. Enjoy!
If you are using minifyEnabled with Proguard, you likely won't need to enable multi-dex. I agree with MG Developer that you should try to avoid multi-dex if possible. My solution was to enable multi-dex only for debug builds. minifyEnabled solves the problem for release builds
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
// getting error: Cannot fit requested classes in a single dex file. # methods: 65537 > 65536
// https://developer.android.com/studio/build/multidex
// minifyEnabled true (used with release) will fix this by getting rid of unused method calls, but this will hide debugging info on crash
multiDexEnabled true
}
}
You have too many methods count.
Android dex file has a limit of 65536 methods you are allowed to have.
For starters, if you don't need all of google play services API and just the location, replace
compile 'com.google.android.gms:play-services:11.8.0'
with
compile 'com.google.android.gms:play-services-location:11.8.0'
You can refer to this page for ways to avoid it or if needed to allow more:
https://developer.android.com/studio/build/multidex.html
I have no idea why, maybe it is because I develop in Kotlin but to fix this error
I finally have to create a class that extends MultiDexApplication like this:
class MyApplication : MultiDexApplication() {
}
and in my Manifest.xml I have to set
<application
...
android:name=".MyApplication">
to not confuse anyone, I also do:
multiDexEnabled true
implementation 'com.android.support:multidex:1.0.3'
for androidx, this also works for me:
implementation 'androidx.multidex:multidex:2.0.0'
...
<application android:name="android.support.multidex.MultiDexApplication">
does not work for me
add your file android/app/build.gradle
defaultConfig {
applicationId "com.ubicacion"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true // ✔
missingDimensionStrategy 'react-native-camera', 'general'
}
Goto build.gradle of app folder,
set minSdkVersion to 21
Save and Run your app, it should run without the dex error now
All I had to do was set the Minimum SDK Version to 21 in File > Project Structure > App > Flavors
I have encountered this error twice and the solution for this is; Check you app gradle file to see your target SDk, if it is 20 or higher, just add one line to your defaultconfig { multiDexEnabled true }
Else if your targetSDK is less than 20, add the line to your defaultConfig and also add a dependency
implementation 'com.android.support:multidex:1.0.3'.
Check this link for more.
https://developer.android.com/studio/build/multidex#mdex-gradle
Using multidex support should be the last resort. By default gradle build will collect a ton of transitive dependencies for your APK. As recommended in Google Developers Docs, first attempt to remove unnecessary dependencies from your project.
Using command line navigate to Android Projects Root.
You can get the compile dependency tree as follows.
gradlew app:dependencies --configuration debugCompileClasspath
You can get full list of dependency tree
gradlew app:dependencies
Then remove the unnecessary or transitive dependencies from your app build.gradle. As an example if your app uses dependency called 'com.google.api-client' you can exclude the libraries/modules you do not need.
implementation ('com.google.api-client:google-api-client-android:1.28.0'){
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.google.guava'
exclude group: 'com.fasterxml.jackson.core'
}
Then in Android Studio Select Build > Analyze APK...
Select the release/debug APK file to see the contents. This will give you the methods and references count as follows.
In build:app
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.proyecto.marketdillo"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-firestore:17.1.5'
implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.dev.khamsat"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
The error is caused by the number of class dependencies you have in your app Gradle file. If the classes exceed 72,400, you might want to use multidex as a solution to better handle file indexing. Findout more from here: https://developer.android.com/studio/build/multidex
After suffering for two hours found the solution.
File path: android/build.gradle
Worked for me
defaultConfig {
applicationId "com.something"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true --> This works for me
}
If your minSdkVersion is set to 21 or higher, multidex is enabled by default and you do not need the multidex support library. - Reference : https://developer.android.com/studio/build/multidex#mdex-gradle
I know I am late for the answer, but, I am sure that this problem is caused by only a single dependency mostly, 'com.google.android.gms:play-services'. Please read the full answer for better understanding of problem, and solution.
In my case, I was using 'com.google.android.gms:play-services-location:21.0.1' which is the latest version of it, by the time I am writing this answer. It is having wayy too many method count.
My only motive to use it was, for fetching location from user's device. Google recommends using play-services-location only for fetching location, so I did not want to replace this dependency for getting my work done.
So, after numerous google searches, I found,
you can downgrade the version
to some previous stable version, to get your job done. And for my case, the best suited version for me came out to be 17.1.0. So I recommend you to use this specific version only, if your usecase to use play-services-location is exactly like mine.
Do these changes
implementation 'com.google.android.gms:play-services-location:21.0.1'
to
implementation 'com.google.android.gms:play-services-location:17.1.0'
Nonetheless, there is always option to enable multidexing in your code, but, that is the most inefficient way to solve this problem IMO.
If you can find the root cause of which dependency is maxing out your dex file size by large
method count, then I guess you should tweak, or replace that
dependency.

Build Apk Error - Duplicate entry : android/support/v4/database/DatabaseUtilsCompat.class?

My Gradle is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.belajarku.gamelari"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
}
dexOptions {
// Prevent OutOfMemory with MultiDex during the build phase
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
dependencies {
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1'){exclude module: 'support-v4'}
}
But when I build apk the project say me :
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
android/support/v4/database/DatabaseUtilsCompat.class
Please help me for fix it.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class
You are adding twice the same class with different versions.
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/support-v4-19.0.1.jar')
Using com.google.android.gms:play-services:+ you are adding all packages of play services libraries which have a dependency with the support-v4.
You should update your support dependencies to the same version of compileSdkVersion. Your compileSdkVersion is 25, hence your support library should also be 25.
Don't use the whole package of Google Play service, choose what you need read from Set Up Google Play Services. For example, if you want to use google ads, add only com.google.android.gms:play-services-ads:11.0.4. You need to change your dependencies like this:
dependencies {
...
// only use google ads from google service.
compile 'com.google.android.gms:play-services-ads:11.0.4'
compile 'com.android.support:support-v4:25.3.1'
...
}
Then you can disable your multidex by setting multiDexEnabled false or commenting it and removing compile ('com.android.support:multidex:1.0.1') from your dependencies.

Didn't find class "android.support.v4.content.ContextCompat" even after adding all the libraries

When I change my targetSDK to greater than 22, the compiler does not allow to use permissions directly. The permissions have to be provided by user for which I have to use below code :
if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSSIONS_REQUEST_FINE_LOCATION);
}
But I keep getting the below error
Didn't find class "android.support.v4.content.ContextCompat"
I have added all the required files for ContextCompat and ActivityCompat but I keep getting this error every time. Here is my build.gradle
[EDIT] Adding the whole gradle file
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
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')
compile 'com.android.support:appcompat-v7:25.2.0'
compile files('libs/classes.jar')
compile 'com.android.support:support-v4:25.2.0'
}
//task to delete the old jar
task deleteOldJar(type: Delete) {
delete '/Users/kushagragupta/Desktop/Kushagra/STURFEE/Sturfee.Unity.Mobile.IMUGPSTest/Assets/AndroidPlugin.jar'
}
//task to export contents as jar
task exportJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('/Users/kushagragupta/Desktop/Kushagra/STURFEE/Sturfee.Unity.Mobile.IMUGPSTest/Assets/')
include('classes.jar')
///Rename the jar
rename('classes.jar', 'AndroidPlugin.jar')
}
exportJar.dependsOn(deleteOldJar, build)
I could literally see these libraries in Android Studio
I've been stuck on this since last 2 days and have no idea what else can be done to fix this.
What I found in regards to support-v4-25.2.0 is that the .aar that is shipped with the Android SDK looks more or less empty, only 2KB in size. Looking further I saw that all the .aar files back to 24.1.1 are only 2KB in size.
I could solve it using version 24.1.1.

Multidex transformClassesWithMultidexlistForDebug Failed

I am developing Android library. When My Client(Application developer) applied my Jar file, it is shown error message.
Build is normal working, But When I run(playButton) App in Android Studio, it is occurred.
The error message shown like below :
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't read [/Users/VSSCP_KYOSEON/Documents/Work/Android/A/B/app/build/intermediates/transforms/jarMerging/debug/jars/1/1f/combined.jar] (Can't process class [com/a/b/VSFunctionActivity.class] (Unknown verification type [88] in stack map frame))
This is my Application Gradle Code :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "com.a.b"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile project(':ChartLib')
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/vs_sat_sdk.jar')
}
My Jar file is vs_sat_sdk.jar. It is applied to proguard.
I already applied Android Multidex guide. https://developer.android.com/tools/building/multidex.html But I failed to execute.
I have normal operation situation.
1. I apply proguard in My jar file. and When minSdkVersion is over 21, it is normal operation. But When minSdkVersion is under 21, it is shown failed.
2. If My jar file doesn't applied proguard, regardless of minSdkVersion, it is normal operation.
please let me know about your solution.
Regards.
Maybe the jar file has been processed by a tool that does not correctly update the StackMapFrame attribute.
Actually, StackMapFrame attributes are not needed for Android development, so you could instruct ProGuard to not create it and it might solve your issue. Add the following to your configuration when applying ProGuard to your library:
-dontpreverify

To run dex in process, the Gradle daemon needs a larger heap. It currently has 910 MB

Actually the main error is "java.exe finished with non-zero exit value 1". First i tell you every problem which i faced after installing studio:
Three days ago, i just installed android studio & I created new project.
1) First it throw the error "Plugin is too old, please update to more recent version", after searching on google i changed
classpath : com.android.tools.build:gradle:2.0.0-alpha2
to
classpath : com.android.tools.build:gradle:2.0.0-alpha8
Current Error solved.
2) After that it was asking for gradle 2.10, i updated this one also & set the path.
Current Error solved.
3) When i ran my application i got one more error "app-debug-unaligned.apk, specified for property 'input file' does not exist".
I searched on internet, i got one solution on stackoverflow. So as answer on stackoverflow i go to "Build" & i selected build apk.
Current error solved.
4) But after that again i got one error
"To run dex in process, the Gradle daemon needs a larger heap. It currently has 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 1G.
java.exe finished with non-zero exit value 1".
I have been searching on stackoverflow for last three days, i applied each and every answer one by one but i'm not able to solve the error. Please save my life, i am really tired of this problem. I show you image what error is coming exactly
My build.gradle file
apply `plugin: com.android.application`
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "java.danish.org.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
I updated everything SDK platforms & SDk Tools.
Please tell me what i am doing wrong here.
Issue
In gradle plugin version 2.0.0-alpha7 and -alpha8 Dex runs inside gradle build process as opposed to a separate process.
Option a)
Change gradle plugin version to 2.0.0-alpha9 where in-process Dex is disabled by default.
classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
Option b)
Disable in-process dex in your app module build.gradle:
android {
// ...
dexOptions {
dexInProcess = false
}
}
Option c)
Increase memory available to gradle process.
Create or update gradle.properties file in your project root directory:
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m
And update your app module build.gradle file:
dexOptions {
preDexLibraries true
javaMaxHeapSize "3g"
incremental true
dexInProcess = true
}
These values are experimental and work for my setup. I use 3 GB for dex and 4 GB for gradle (3 + 1 GB).
Note
If you have any issues update to alpha9 anyway.
I found the solution.
Changes
1)
dexOptions {
javaMaxHeapSize "4g"
}
2)
lintOptions {
checkReleaseBuilds false
abortOnError false
}
This is my new build.gradle and everything is working fine now.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc4"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.aquasoft.guesp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:design:23.4.0'
compile 'com.stripe:stripe-android:+'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.android.support:cardview-v7:23.3.+'
}
try this gradle params
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
}

Categories

Resources