2

I was developing on my real device Xiaomi Mi 4c, no problems. Then suddenly (I guess after a system update) I ran into this error, when I try to run:

Uploading file to: /data/local/tmp/be.sebsob.red
Installing be.sebsob.red
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/be.sebsob.red"
Aborted 


Launching application: be.sebsob.red/be.sebsob.red.FullscreenActivity.
DEVICE SHELL COMMAND: am start  -n "be.sebsob.red/be.sebsob.red.FullscreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=be.sebsob.red/.FullscreenActivity }
Error type 3
Error: Activity class {be.sebsob.red/be.sebsob.red.FullscreenActivity} does not exist.

(This is a new android studio default fullscreen app, without any changes)

Things I tried but did not solved the problem:

  • Cleaned/Rebuild the project
  • Re-imported the project
  • Deleted the Build directory
  • Deleted the ~/.idea and ~/.gradle directories
  • Deleted .iml files
  • Changed activity naming in Manifest.xml from .FullscreenActivity to full path
  • Restarted my phone / computer / Android Studio
  • Restarted Android studio with Invalidate Caches / Restart...
  • Restarted adb via adb kill-server and adb start-server commands
  • Killed abd process via Task Manager and restarted
  • Re-enabled developer options on my phone
  • Revoke USB debugging authorizations on my phone

BUT When I run this application on my other device (Xiaomi Mi2S) it works fine.

AND When I copy the .apk manually on my phone (where it fails to run from Android Studio) it installs and runs fine. So I guess it has to be a problem specific when running from Android Studio to my phone? Could It be a read/write access permission error? Any idea's?

AndroidManifest.xml (default, did not change after Android Studio new project setup)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="be.sebsob.red">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".FullscreenActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/FullscreenTheme">
            <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'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "be.sebsob.red"
        minSdkVersion 16
        targetSdkVersion 21
        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.2.1'
    compile 'com.android.support:support-v4:23.2.1'
}

Thanks

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
SebSob
  • 552
  • 7
  • 22
  • Have you deleted the app on the phone via adb, then install a fresh version? – Morrison Chang Apr 04 '16 at 00:36
  • it seems there is a bug with your adb. try to restart it via adb kill-server and adb start-server commands respectively. And Morrison's answer also must work. – ugur Apr 04 '16 at 01:02
  • @MorrisonChang I have deleted the app on the phone without adb. But the new default simple project I made to test was never on my phone before... – SebSob Apr 04 '16 at 10:34
  • @UğurB when i run **adb kill-server** it says: _* server not running *_ when I then run **adb start-server** it says: _* daemon not running. starting it now on port 5037 * * daemon started successfully *_ but when I then run the project I still get the same initianal error – SebSob Apr 04 '16 at 10:37
  • I tried deleting the app with abd **adb shell am start -a android.intent.action.DELETE -d package:be.sebsob.red** but then on my phone i get a message: "app not found in the list of installed apps" – SebSob Apr 04 '16 at 10:42
  • This may help you http://stackoverflow.com/questions/7071271/activity-class-does-not-exist – mubeen Apr 04 '16 at 10:52
  • The problem is with run configuration in android studio – mubeen Apr 04 '16 at 10:54
  • @mubeen thank you, but my run configuration are like they state, [have a look](https://i.gyazo.com/171cf02d0a22cc60fb130bf1be2fbf57.png) – SebSob Apr 04 '16 at 11:04
  • is instant run on in your studio settings. disable it – peeyush pathak Apr 04 '16 at 11:58
  • @peeyushpathak Instant run is not activated – SebSob Apr 04 '16 at 12:11
  • make sure another adb process not running in the task manager. if running kill it. then try to start adb again. – ugur Apr 04 '16 at 12:52
  • @UğurB I also tried that, did not fixed my issue, I ended up re-installing an older ROM version (pff), and that fixed it, thanks anyway – SebSob Apr 04 '16 at 14:10

2 Answers2

2

Ok, so after a long research I found out it had something to do with the adb not working properly on my phone. I don't really know why... But for more information check this answer: https://stackoverflow.com/a/32103016/5297218

For me personally re-installing another (older) ROM version was the only thing that fixed my issue.

Community
  • 1
  • 1
SebSob
  • 552
  • 7
  • 22
  • I have the same problem...What version are you using now?? If you find an other solution, please plublish it :) – RoberV Jun 16 '16 at 08:22
  • @RoberV sorry for the late answer, but I have now MIUI V7.2.4.0 stable on my Xiaomi Mi 4c, and it's working fine. – SebSob Sep 20 '16 at 09:41
1

I tried everything and nothing was working for me!! Was very disappointed!! Running on Samsung S8 (Android V. 8.0.0 API 26). Just one thing worked and was:

  1. build the APK (Build -> Build APK)
  2. drag and drop the .apk file inside the smartphone Download folder using normal Android File Transfer
  3. press and install the .apk (it will ask to change the setting for install from an unknown source)
  4. after install the app you will be able to Run your Debug from Android Studio.

I hope this can help somebody because took me a while to figure this out. The very very weird thing was that on Asus and on Pixel2 all of this wasn't a problem. I've been deleted and reinstall the app multiple tipe, only on the Samsung S8 with Oreo it was a problem, so probably samsung store somewhere the package name and if deleted then u cannot reinstall (The delete way that I used was through the Apps Manager).

Alexiscanny
  • 581
  • 7
  • 15