pearmak
pearmak

Reputation: 5027

Activity class does not exist - why?

I could not find the reason why the logcat reports that the Activity class com.abc.marksix.SugarActivity does not exist. The Manifest, Logcat, app/build.gradle and project structure are as follows. Could you please help?

Code:

Android Manifest:

<application
    android:allowBackup="true"
    android:name="SugarOrmTestApplication"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <meta-data
        android:name="com.google.android.gms.ads.com.abc.marksix"
        android:value="ca-app-pub-xxx/xxx"
     />

    <activity
        android:name="com.abc.marksix.SugarActivity"
        android:screenOrientation="portrait"
        android:exported="true"
        android:label="@string/app_name" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Logcat:

10/28 01:01:47: Launching app
$ adb push C:\Users\xxx\outputs\apk\debug\app-debug.apk /data/local/tmp/com.abc.marksix
$ adb shell pm install -t -r "/data/local/tmp/com.abc.marksix"
Success
APK installed in 2 s 777 ms
$ adb shell am start -n "com.abc.marksix/com.abc.marksix.SugarActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.abc.marksix/com.abc.marksix.SugarActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.abc.marksix/.SugarActivity }
Error type 3
Error: Activity class {com.abc.marksix/com.abc.marksix.SugarActivity} does not exist.

Project structure:

enter image description here

app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.abc.marksix"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:support-v4:28.1.1'
    implementation 'com.android.support:appcompat-v7:28.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'

    implementation 'com.github.satyan:sugar:1.5'
    implementation 'com.parse:parse-android:1.13.0'
    implementation 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'com.adlocus:library:3.5.7@aar'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation files('src/main/java/com/abc/libs/jeval.jar')
    implementation files('src/main/java/com/abc/libs/jscience.jar')
}

Upvotes: 0

Views: 885

Answers (2)

kanaton
kanaton

Reputation: 11

On my side, i did using the Android Studio Top Menu :

Files and Re-Import Gradle Project Build and Clean Project Build and Make Project Run App (after exiting all Virtual Devices)

and it worked fine after tested all solutions found in StackOverFlow

Hope it will be helpfull for you

Note that the Re-Import Gradle Project can be enough =) because it seems to do by itself the rest

Upvotes: 1

Zwal Pyae Kyaw
Zwal Pyae Kyaw

Reputation: 140

Your code works fine and everything is correct. You just need to do is,

First, run your application from IDE and let it install.
Second, Try uninstalling the application from the device settings, not from launcher or adb.


Hope it works!

Upvotes: 0

Related Questions