0

I have an Android 4.x app with Holo style. Now I want add support for Material style and I'd like have Material style both on Android 5 and Android 4.x (I have read this is possible with AppCompat v21). I have read this post about "migration" from Holo to Material: http://android-developers.blogspot.sg/2014/10/appcompat-v21-material-design-for-pre.html

So I have change my old "build.grandle" file from this:

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion '19.1.0'

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 19
    versionCode 18
    versionName "1.3.1"
}
buildTypes {
    release {
        runProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:4.4.52'
compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
}

to this:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion '20.0.0'

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 19
    versionName "2.0.0"
}
buildTypes {
    release {
        runProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

repositories {
mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
compile 'com.anjlab.android.iab.v3:library:1.0.+@aar'
}

I have change JDK6 to JDK7 (because SDK21 need it), select API21 as "compile sdk version" and create a new XML file "values/themes.xml":

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- Set AppCompat’s actionBarStyle -->


    <!-- Set AppCompat’s color theming attrs -->
    <item name="colorPrimary">#8bc34a</item>
    <item name="colorPrimaryDark">#259b24</item>

<!-- The rest of your attributes -->
</style>
</resources>

Now when I try to run my app on my device (with Android 4.4, at this moment I don't have a device with Android 5), Android Studio before try install it, then ask me to remove the old version (but there is not a old version. I have remove it and delete all folder). When I confirm I get a error:

Uploading file
local path: C:\MYAPP\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.myname.myapp
Installing com.martinzone.topotafmobile
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myname.myapp"
pkg: /data/local/tmp/com.myname.myapp
Failure [INSTALL_FAILED_DEXOPT]

I have also tried to "clear" my project but in this case I get this error:

Uploading file
local path: C:\MYAPP\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.myname.myapp
Installing com.myname.myapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myname.myapp"
pkg: /data/local/tmp/com.myname.myapp
Failure [INSTALL_FAILED_UID_CHANGED]

Any idea? How can I solve it? How can I add Material Style support working on Android 4 and Android 5?

zapl
  • 63,179
  • 10
  • 123
  • 154
Martin
  • 1,065
  • 1
  • 17
  • 36
  • http://stackoverflow.com/questions/5153515/how-to-solve-install-failed-dexopt-this-error – aga Nov 23 '14 at 09:05
  • @aga just read without success. Thanks in any case. – Martin Nov 23 '14 at 09:14
  • Your problem is in fact not the material design part. By changing the project to target version 21 you've changed something (like using java 7?) that breaks the installation. PS: How did clearing the project change the app id to "com.myname.myapp" (or did you try to blank out the name and forgot it once)? Did you change it in gradle? – zapl Nov 23 '14 at 09:27
  • @zapl I have update Android Studio (I think it update also gradle) so I compiled my app without change and all worked. Then I have try to upgrade my project to SDK21 and Material Style but I cannot install it. "com.myname.myapp" is a "dummy" name. On my project is there the real name. – Martin Nov 23 '14 at 10:26
  • FAILED_DEXOPT means that the device failed to use the apk, you'll have to check logcat to figure out why (logcat does not appear filtered for your app, you'll need it unfiltered to see). UID_CHANGED means that you have uninstalled the app and reinstalled but something from the old app survived and and blocks a clean install. In that case try uninstalling from the device app settings and maybe rebooting. And cleaning the project would be http://stackoverflow.com/questions/16636848/equivalent-of-clean-build-in-android-studio - that should be done anyways if there are strange build failures. – zapl Nov 23 '14 at 16:11

0 Answers0