app crashed wiht classes.dex permission denied error - android

My app is crashed with following error,
E/dex2oat: Failed to create oat file:/data/dalvik-cache/arm/data#app#com.stvgame.xiaoy.remote-1#split_lib_dependencies_apk.apk#classes.dex: Permission denied
And our app use mutipule dex, does they have relation?

I had a similar problem and my solution was disable the Instant Run, if you're using Android Studio...

I had got a similar error when i used multi dex for the first time,
This guide helped a lot,
My error was i forgot to add this in the application class:
public class MyApplication extends SomeOtherApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
in your build gradle, make sure you have included the following lines:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Even then multi dex has limitations with progaurd, read the guide to find out if that is causing this issue.

Related

DexOverflowException after adding com.google.firebase:firebase-firestore:11.4.2

I have a problem after adding compile "com.google.firebase:firebase-firestore:11.4.2" to my build.
As soon as I add that, it also adds com.google.common among other things to my dex file, which is around 27k extra references, thus bursting through the 64k dex limit.
Does anyone know why that is or am I doing something wrong?
Try adding these lines to your build.gradle
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
This will enable multidex mode, which will allow you to exceed the 64k limit. (Read more here)
API below 21
If you're using an API level below 21, then you also need to add the support library
gradle.build:
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
android.manafest
<?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>
If you use a custom Application class, try using one the of the following
Solution 1
simply override the MultiDexApplication class
public class MyApplication extends MultiDexApplication { ... }
Solution 2
override attachBaseContext and install MultiDex using the install(Application) function
public class MyApplication extends SomeOtherApplication {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
You're not doing anything wrong: the Android API for Cloud Firestore is just big. We'll be working on reducing SDK size on the road to GA.
Meanwhile, you need to enable multidex to build if your application is nontrivial.
We actually use very little of com.google.common, so you may be able to say under the 64k method limit by proguarding your application too.
Updating to 11.6.0 fixes this issue

Android project working for everyone but me. [duplicate]

I am trying to integrate Google sign in, in my app, I added these libraries:
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
Also add this to project build gradle:
classpath 'com.google.gms:google-services:1.4.0-beta3'
Also add plugin to app build gradle:
apply plugin: 'com.google.gms.google-services'
then add required permissions
but when I try to run my app, received this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0\bin\java.exe'' finished with non-zero exit value 2
Try adding multiDexEnabled true to your app build.gradle file.
defaultConfig {
multiDexEnabled true
}
EDIT:
Try Steve's answer first. In case it happens frequently or first step didn't help multiDexEnabled might help. For those who love to dig deeper here is couple similar issues (with more answers):
:app:dexDebug ExecException finished with non-zero exit value 2
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException
Another thing to watch for, is that you don't use
compile 'com.google.android.gms:play-services:8.3.0'
That will import ALL the play services, and it'll only take little more than a hello world to exceed the 65535 method limit of a single dex APK.
Always specify only the services you need, for instance:
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
I just had to Clean my project and then it built successfully afterwards.
This error began appearing for me when I added some new methods to my project. I knew that I was nowhere near the 65k method limit and did not want to enable multiDex support for my project if I could help it.
I resolved it by increasing the memory available to the :app:transformClassesForDexForDebug task. I did this by specifying javaMaxHeapSize in gradle.build.
gradle.build
android {
...
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
}
I tried this after having had no success with other common solutions to this problem:
Running a project clean
Manually deleting the /app/build and /build directories from my project
Invalidating Gradle Cache and restarting Android Studio
Error
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
'/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java''
finished with non-zero exit value 1
Note: increasing the memory available to the DEX task can cause performance problems on systems with lower memory - link.
I also faced similar issue in Android Studio 1.5.1 and gradle 1.5.0.
I just have to remove unwanted libraries from dependencies which may be automatically added in my app's build.gradle file.
One was : compile 'com.google.android.gms:play-services:8.4.0'.
So for best practices try to only include specific play services library like for ads include only
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
Although
defaultConfig {
multiDexEnabled true
}
this will also solve the issue, but provides with a lot of Notes in gradle console, making it confusing to find the other real issues during build
you can see the documentation of Android
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
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>
I'm using AS 1.5.1 and encountered the same problem. But just cleaning the project just wont do, so I tried something.
clean project
restart AS
Sync Project
This worked with me, so I hope this helps.
At my case change buildToolsVersion from "24" to "23.0.2", solve the problem.
In my case the Exception occurred because all google play service extensions are not with same version as follows
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
It worked when I changed this to
compile 'com.google.android.gms:play-services-plus:9.8.0'
compile 'com.google.android.gms:play-services-appinvite:9.8.0'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
I resolved it with the next:
I configured
multidex
In build.gradle you need to add the next one.
android {
...
defaultConfig {
...
// Enabling multidex support.
multiDexEnabled true
...
}
dexOptions {
incremental true
maxProcessCount 4 // this is the default value
javaMaxHeapSize "2g"
}
...
}
dependencies {
...
compile 'com.android.support:multidex:1.0.1'
...
}
Add the next one in local.properties
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
After that into Application class you need to add the Multidex too.
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
//mas codigo
}
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Don't forget add the line code into Manifest.xml
<application
...
android:name=".MyApplication"
...
/>
That's it with this was enough for resolve the bug:
Execution failed for task ':app:transformClassesWithDexForDebug.
Check very well into build.gradle with javaMaxHeapSize "2g" and the local.properties org.gradle.jvmargs=-Xmx2048m are of 2 gigabyte.
I had same problem when i rolled back to old version via git, and that version had previous .jar library of one 3rd party api, and for some reason turned out that both jar of the same sdk, just different versions were in /libs folder.
First Delete intermediates files
YOUR APP FOLDER\app\build\intermediates
OR
Clean your project and then rebuild.
Thent add
multiDexEnabled true
i.e.
defaultConfig {
multiDexEnabled true
}
It's work for me
I solved this issue by change to use latest buildToolsVersion
android {
//...
buildToolsVersion '26.0.2' // change from '23.0.2'
//...
}
A helpful answer if all above didn't work for you.
Go to your app gradle file,
Check all the dependency versions are mentioned with proper version code rather than any relative value like (com.example.demo:+)
Previous - implementation 'com.google.api-client:google-api-client-android:+'
After - implementation 'com.google.api-client:google-api-client-android:1.30.0'
If you are using the latest gradle version ie classpath 'com.android.tools.build:gradle:1.5.0' and classpath 'com.google.gms:google-services:1.4.0-beta3', then try updating the latest support respository from the SDK manager and rebuild the entire project.
If you need add this reference for cordova plugin add next line in your plugin.xml file.
<framework src="com.android.support:support-v4:+" />
If the different dependencies have a same jar also cause this build error.
For example:
compile('com.a.b:library1');
compile('com.c.d:library2');
If "library1" and "library2" has a same jar named xxx.jar, this will make such an error.
It happened to me because of Eclipse memory leak. I had to restart my computer.
I changed a couple of pngs and the build number in the gradle and now I get this. No amount of cleaning and restarting helped. Disabling Instant Run fixed it for me. YMMV
I had the same option and as soon as I turned off Instant run, it worked fine on my API16 device, but on the API24 device it worked fine with Instant run.
Hope this helps someone having the same issue
Simply go to Build - Edit Build Types - Properties Tab - Build Type Version and downgrade it to ver 23.0.1. Click ok.
This works for android studio 1.5.
It worked for me.
the write answer is in gradle put
defaultConfig {
multiDexEnabled true
}
then application name in manifest
android:name="android.support.multidex.MultiDexApplication"
wish this answer is hellpful to some one
this code solved problem
defaultConfig {
multiDexEnabled true
}
For easiest way to implement google sign in visit: google sign in android
Also try
dexOptions {
javaMaxHeapSize "4g"
}
Also keep same version number for different services.
I solved this issue by adding:
In build.gradle:
defaultConfig {
multiDexEnabled true
}
in local.properties ,
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
mention dependency:
compile 'com.android.support:multidex:1.0.1'
Clean and Rebuild.
Incase 'Instant Run' is enable, then just disable it.

Implement two(2) name spaces under Application in the Manifest file

I want to implement 2 name spaces under Application in android Manifest file to implement the firebase offline capabilities but it rejects taking 2 name spaces in the manifest file, see:
I tried to extend multiDexApplication in the MiLibrary Class, see:
public class MiLibrary extends Application {
#Override
public void onCreate() {
super.onCreate();
if (!FirebaseApp.getApps(this).isEmpty()) {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
}
Picasso.Builder builder = new Picasso.Builder(this);
builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
Picasso built = builder.build();
built.setIndicatorsEnabled(false);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
}
but it gives me an error, see the stackTrace:
I've also tried searching here on stack-overflow and on Google but there are results or answers related to this, does anyone know how I can achieve this?
First of all in application tag you can define only single attribute for:-
android:name=".YourApplication"
Secondly, add the following dependency for okHttpClient:-
compile 'com.squareup.okhttp3:okhttp:3.2.0'
Your app's gradle file should look like this:-
defaultConfig {
...
minSdkVersion 14
targetSdkVersion //Yours
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}
Extend your application with MultiDexApplication class:-
public class MiLibrary extends MultiDexApplication { ... }
In your Manifest add name of your application as follows:-
<application
android:name=".MiLibrary"
...>

Gradle project sync failed for android support multidex library

I am trying to add Multidex library to my project. I added following as dependency in my 'app/build.gradle' -
complie 'com.android.support:multidex:1.0.1'
when i try to sync i can see following error
Error:Could not find method complie() for arguments [com.android.support:multidex:1.0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
i have Android Support Repository installed.
Can someone help me? Thanks in Advance.
add multiDexEnabled = true in your build.gradle
android {
defaultConfig {
...
multiDexEnabled = true
}
}
dependencies {
...
compile 'com.android.support:multidex:1.0.0'
...
}
add this to manifest file
android:name="android.support.multidex.MultiDexApplication"
and your Activity class
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Just make sure that you are editing the correct build.gradle file. You will get this error when editing android/build.gradle instead of android/app/build.gradle.

SugarORM + Multidex

I downloaded the SugarORM source to use it as a library module (so I could override the aplication's "attachBaseContext" method.
I have already seen the question SugarORM and multidex, Problem is that I can't figure out how to reference the MultiDex library into my new SugarORM library module.
Can someone help me figuring this out?
Error page screenshot
Create a class java file
public class MultiDex extends SugarApp {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
android.support.multidex.MultiDex.install(this);
}
#Override
public void onCreate() {
super.onCreate();
SugarContext.init(this);
}
#Override
public void onTerminate() {
SugarContext.terminate();
super.onTerminate();
}
}
In Manifest, call the java class file.
<application
.......
android:name=".MultiDex"
......>
Check the version of sugar library
and make sure you complie the latest version of sugar library . Using version like 1.3 will throw some errors with multidex.
add this in your gradle
compile 'com.github.satyan:sugar:1.5'
If possible, extend the MultiDexApplication yourself:
public class MyApplication extends MultiDexApplication
Also, ensure you have followed all steps required to configure MultiDex.
Particularly build.gradle:
android {
defaultConfig {
...
multiDexEnabled = true
}
And AndroidManifest.xml:
<application
android:name="android.support.multidex.MultiDexApplication"
.. >
..
</application>

Categories

Resources