简体   繁体   中英

APK File works in android emulator but won't install on my device

I'm new to Android Studio (downloaded it yesterday on my Windows 7 machine) and just finished creating an app using Kotlin. It works properly on the Android Emulator, but when I build a signed APK file and try installing it on my Samsung S7 (Android 8.0.0) phone it shows the mysterious error "App not installed".

I noticed there's a red X mark near MainActivity in the top bar, maybe it has something to do with the problem? It doesn't prevent me from building...

红 X 截图

Previous builds of the same app installed properly. The only thing I changed before it started breaking is the location of the AVD folder (using this ) from the C drive to the D drive, since I ran out of memory there. I deleted all virtual devices, created the environment variable then created the virtual devices again.

Things I already tried without any luck:

  • The top 5 solutions here
  • Deleting debug.keystore
  • Cleaning and rebuilding the project
  • Changing the build variant to "Release"

EDIT: I created a new project and copied my scripts to there, and it now works properly. Not really a solution since this took a lot of time, but it solved the problem.

You should have to create new sample project and check it will be working or not

If you have install apk before in your device you can not install it again

For fix that

1) You can uninstall app from device and reinstall from apk.

2) You can change versionCode in build.gradle(app)

defaultConfig {
    applicationId your_package_name   
    versionCode 2 //try to increase every time
    versionName "1.0.0" //no need to change but better change it
    //other codes
}
  1. Select the MainActivity(with X mark)
  2. A dropdown will appear
  3. Select your application Module (By Default it is app )
  4. Run the Project (It should install the apk and run on your device)

Hope it helps!!

Try it by delete .iml file from your project directory and rebuild project

Have you restart your system after updating location of AVD ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM