I've recently had to enable multidex in my android studio project, this is built with imported module. It's doing well in the main project, but showing multidex problem in the project built with imported(from the main project) module. I have followed this documentation to enable multidex. As the application tag is not overridden , so i've followed the method related. Now i'm getting this error:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [E:\something\SalesDemo >Updated\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't >read [E:\something\SalesDemo >Updated\app\build\intermediates\classes\debug(;;;;;;**.class)] (Can't read [com] >(Can't read [smth] (Can't read [infolinkplus] (Can't read
[some.class] (Duplicate zip entry
[com/abc/def/some.class]))))))
Here's my build.gradle:
apply plugin: 'com.android.application'
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
// buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.abc.def.somethingotherthing"
multiDexEnabled true
minSdkVersion 16
//noinspection OldTargetApi
targetSdkVersion 22
versionCode 16
versionName "0.0.16"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation 'com.android.support:multidex:1.0.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.3'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile project(':infolinkplus')
}
And the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.abc.def.somethingotherthing">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
...
//ACTIVITIES AND META-TAGS
...
</application>
</manifest>
After changes, i ran clean build and rebuilt but no result.
How can i overcome this problem? Thanks in advance.
You have to change your Manifest to provide MultiDex:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
or if you have custom Application class, you have to extend it with MultiDexApplication
public class MyApplication extends MultiDexApplication { ... }
Duplicate zip entry
[com/abc/def/some.class]
In your project you must be having a class with name some.class rename it to some thing else
Try this code...
i hope you done this things..
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
make class for application level..
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
android:name="MyApplication" > // here define that class name that extends by MultiDexApplication
Related
The error says that "Error:Execution failed for task ':app:processDebugManifest'. > "
I have tried many solutions on this website but still, the problem is not solved. Please help me
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="project.myapp">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 28
defaultConfig {
applicationId "project.myapp"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
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 fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
// implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.firebaseui:firebase-ui-firestore:3.0.0'
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
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'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(Project:myapp)
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
On Merged Manifest says that
Merging Errors: Error: tools:replace specified at line:5 for attribute
android:appComponentFactory, but no new value specified app main
manifest (this file), line 4 Error: Validation failed, exiting app
main manifest (this file)
For me, the solution was to just migrate to AndroidX.
On Android Studio, go to:
Refactor > Migrate to AndroidX
clean the project.
I.m delete this
tools:ignore="GoogleAppIndexingWarning",
tools:replace="android:appComponentFactory"
and fix this problem.good luck :)
Just remove the below line:
tools:replace="android:appComponentFactory"
And recompile and finally it works for me!
you should try this:
1:Remove tools:replace="android:appComponentFactory"
2:Provide new value for android:appComponentFactory" attribute
from:
Manifest merger failed, error on compiling
it worked for me!
solve my problem
Refactor > Migrate to AndroidX
In my case an error in Manifest file brought about this error at the time of generating apk although app was building flawlessly.
It was want of explicit 'exported' attribute in activity elements in Manifest file. after that apk too generated successfully .
I trying to user multiple module android project to work on my application and when I try to build the project. the project build fails with Manifest merge failures. I need help to resolve this issue.
I already tried changing the dependencies in Gradle files and tried rearranging them, searched other solutions in this and here as well, but none of them helped
my AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.atomnest.chitfund">
<application
xmlns:tools="http://schemas.android.com/tools"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory" />
</manifest>
since the project is not build successfully I'm not able to add any activity to the project
and my build.gradle File
apply plugin: 'com.android.application'
buildscript {
ext {
support_version = '1.0.2'
}
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.atomnest.chitfund"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation "androidx.appcompat:appcompat:$support_version"
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.firebase:geofire-android:2.1.1'
implementation project(':utility')
implementation project(':library')
}
I am expecting to get the project build successfully and be able to launch the app in the emulator. pls help
here is the logcat image
If you are using androidx then you have to use all libraries compatible with androidx so you can use this code:-
In gradle.build (app) add this
compileSdkVersion 28
defaultConfig {
......
minSdkVersion 21
targetSdkVersion 28
......
}
And there are some implementations required to use androidx :-
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
And add these given two lines(below) to gradle.properties:-
android.useAndroidX=true
android.enableJetifier=true
Solution 1:
Suggestion: add 'tools:replace="android:appComponentFactory"' to
element at AndroidManifest.xml to override.
If you added the tools:replace="android:appComponentFactory" and still got trouble by fixing it, create a new project, copy-paste the codes and the same dependencies in there. After that, it should be fixed i hope.
If it didn't solve the issue, try adding these two:
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
In AndroidManifest.xml > <application tag of course.
Solution 2:
Add below two lines in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
You can also follow below link:
https://developer.android.com/jetpack/androidx/migrate
Do let me know if you get any problem.
Actually I had the same issue.In my case it was butterknife. I changed the dependency into 8.8.1 and it works fine for me.
I have an app that has as minSdkVersion API 16, When I added new jar files activation, additionnal, mail, itextpdf for sending pdf file throw email. Its throwing exception below for previously added module library:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.viewpagerindicator.TabPageIndicator" on path: DexPathList[[zip file "/data/app/com.inbridge.avakaash-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.inbridge.avakaash-1, /vendor/lib, /system/lib]]
If I remove these new jar files then its working fine...
this is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.inbridge.avakaash"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile project(':payUMoneysdk')
compile files('libs/httpclient-win-4.4.1.jar')
compile files('libs/httpmime-4.2.3.jar')
compile files('libs/gcm.jar')
compile 'com.android.support:appcompat-v7:23.0.0-alpha2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
compile files('libs/itextpdf-5.5.9.jar')
compile 'com.android.support:multidex:1.0.1'
}
This is my settings.gradle
include ':library'
include ':payUMoneysdk'
include ':avakaash'
Please any one help me to resolve this error...
The problem is that multiDexEnabled true in not enough when you're targeting devices older than 5.0 Lollipop. If you want to support KitKat and older then in addition to this flag, you also have to deploy the secondary dexes make your main Application class, as explained in the official docs.
There are multiple ways to do this:
You can make your your Application class extend from MultiDexApplication
public class MyApplication extends MultiDexApplication {
You can add the following lines to your Application class:
public void onCreate(Bundle arguments) {
MultiDex.install(getTargetContext());
super.onCreate(arguments);
}
If you don't use a custom Application class, you can enable it via the AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
...
android:name="android.support.multidex.MultiDexApplication">
</application>
</manifest>
This error came after when I added compile 'org.apache.httpcomponents:httpmime:4.2.3'. Can't find solution I also tried multiple dex file true in default config section. I also tried creating another app for testing which was running successfully.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
This is my build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.qualwebs.assistme"
minSdkVersion 19
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'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
}
The Android plugin for Gradle available in Android SDK Build Tools
21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android
Support Repository to the latest version using the SDK Manager before
attempting to configure your app for multidex.
Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:
Change your Gradle build configuration to enable multidex
Modify your manifest to reference the MultiDexApplication class
Modify your app Gradle build file configuration to include the support library and enable multidex output .
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 23
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
In your manifest add the MultiDexApplication class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited
You can use
compile 'org.apache.httpcomponents:httpmime:4.5.1'
Read
https://developer.android.com/intl/es/tools/building/multidex.html
You have problem of multidex file so please add below dependency to your app Gradle file.
compile 'com.android.support:multidex:1.0.1'
Also add this line:
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
Also add below in Manifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited :
Try the following:
Change setting
Ctrl + Alt + S -> Compiler -> Gradle
InVM Options field write:
-Xmx2048m -XX:MaxPermSize=512m
Add in gradle
dexOptions { javaMaxHeapSize "2g" }
Thanks..!!
This issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android. This problem can be solved either by cleaning the project, and removing some unused libraries and methods from dependencies in build.gradle, OR by adding multidex support.
So, If you have to keep libraries and methods, then you can enable multi dex support by declaring it in the gradle config.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
so im trying to build an app using GCM. i've opened 2 modules for this. a backend (GCM messaging with appengine and a regular module - the names are "app" (regular module" and "backend").
i'm recieving this problem and i can't figure the solotion for it.
when the app is starting i get the following error:
10-04 18:24:16.391 18920-18920/com.example.daniel.testing6 E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:289)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.daniel.testing6.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
My project name is Testing6 and its 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:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
my app module gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.daniel.testing6"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true // i added it because i got different problem
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}
and my backend module:
// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
compile 'com.google.appengine:appengine-endpoints:1.9.18'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:4.0b3'
compile 'com.ganyo:gcm-server:1.0.2'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
public class MainActivity extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
doew anyone knows how to fix it???
Problem Solved!
Ok so i did the following:
manifast:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.daniel.testing6" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
<application
android:name="com.example.daniel.testing6.Application"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="#string/title_activity_main2"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
</application>
</manifest>
ok so to get rid of the error i went to the gradle of my module app:
so it will look like that:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.daniel.testing6"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':backend', configuration: 'android-endpoints')
//
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:22.2.1'
}
next i created an Application as follows:
package com.example.daniel.testing6;
import android.content.Context;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
/**
* Created by Daniel on 05-Oct-15.
*/
public class Application extends MultiDexApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
and a main activity normally:
package com.example.daniel.testing6;
import android.content.Context;
import android.content.Intent;
import android.os.PersistableBundle;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startActivity(new Intent(this, Main2Activity.class));
}
}
the manifast calls the Application that uploading all its data and then moves to the activity once the data is with in our reach :)
You also have to:
Include `compile 'com.android.support:multidex:1.0.0'` in your dependencies
See https://developer.android.com/tools/building/multidex.html for more details.
Also have your Application class extend MultiDexApplication instead of just Application. Alternatively, you can call MultiDex.install() in attachBaseContext() of your application
Installing/updating Android Support Library and Android Support Repository in SDK manager will fix such errors