1

I wrote an app and install it on my phone via usb debug mode, all work smooth, but when I generate a signed apk and install it on my phone, two issues occurs:

  1. install fail and log "same package installed". So I deleted the "via-usb apps" and reinstall: problem fixed. BUT! the package name should be same as the via-usb apps and should be able to install "updates" rather than install fail?

  2. after install the apk and launch the app, it crashed somewhere where it didn't crash with the app installed "via-usb", and not only one bugs but many!

Can anyone tell me what should I do? I was using Eclipse before and this Android Studio project is created from others which require me to implement, thus I start to use Android Studio. And of course I create a new key for myself.

[update]

I have just set the release key as debug key, then the generate apk(debug) work smooth just like the usb one, but i found that the apk(release) can install but still occurs the previous one, is there any different between debug and release apk beside the key?

first error log:

06-05 10:15:08.700 28362-28362/? E/WindowManager﹕ Activity com.ababab.ui.activity.LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42901978 G.E..... R.....ID 0,0-1026,288} that was originally added here

Kennett
  • 467
  • 2
  • 7
  • 17

2 Answers2

0

Problem 1) : the package name is the same. The signature is different (app installed via usb from Android Studio is probably the debug version signed with your debug key).

Uninstalling the debug version before installing the release version is the way to solve the problem.

Problem 2) : post your logcat with first errors.

Is there any differences between debug and release apk beside the signature ?

It depends of the buildTypes section in your build.gradle. But by default, the debug build is debuggable and the release is not. Another common difference is that proguard runs only to build the release build (but it really depends on your build.gradle, without it we can only make suggestions)

ben75
  • 29,217
  • 10
  • 88
  • 134
  • I have just set the release key as debug key, then the generate apk(debug) work smooth just like the usb one, but i found that the apk(release) can install but still occurs the previous one, is there any different between debug and release apk beside the key? – Kennett Jun 05 '15 at 03:17
0
  1. The debug build is automatically signed for you more info. When you try and install the release signed APK it has the same app ID but a different signing key. Android will not allow you to upgrade an app to an APK with with a different key as a security measure.

  2. Post the errors from logcat/console.

UPDATE

have just set the release key as debug key

I am not sure why that is not working.

If you want to be able to easily install both version I would recommend using a different application id for the debug build.

debug {
  applicationIdSuffix ".debug"
  ...
}

This will allow you to install both version side by side (a few extra steps will be required if you defined content providers)

now both version will have the same name in your launcher. This can be fixed defining build specific strings.

// app/src/main/res/values/strings.xml
<string name="app_name">MyApp</string>


// app/src/debug/res/values/strings.xml 
<string name="app_name">MyApp.DEBUG</string>

And finally using that value in your AndroidManifest to set the launcher name.

<application
  android:label="@string/app_name"
  ....

UPDATE 2 I recently discovered there is a better way of defining the app name for different build versions. Instead of having seperate string.xml files you define the app_name string in your gradle file.

release {
   resValue "string", "app_name", "MyApp"
}

debug {
  applicationIdSuffix ".debug"
  resValue "string", "app_name", "MyApp.Debug"
}
Community
  • 1
  • 1
cyroxis
  • 3,661
  • 22
  • 37
  • I have just set the release key as debug key, then the generate apk(debug) work smooth just like the usb one, but i found that the apk(release) can install but still occurs the previous one, is there any different between debug and release apk beside the key? – Kennett Jun 05 '15 at 03:17