Класс активности не существует - почему? - PullRequest
0 голосов
/ 27 октября 2018

Я не смог найти причину, по которой logcat сообщает, что класс Activity com.abc.marksix.SugarActivity не существует.Манифест, Logcat, app / build.gradle и структура проекта следующие.Не могли бы вы помочь?

Код:

Манифест Android:

<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.

Структура проекта:

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')
}

Ответы [ 2 ]

0 голосов
/ 05 апреля 2019

Со своей стороны, я использовал главное меню Android Studio:

Файлы и повторный импорт Gradle Project Построить и очистить проект Построить и сделать проект Запустить приложение (после выхода из всех виртуальных устройств)

и он работал нормально после тестирования всех решений, найденных в StackOverFlow

Надеюсь, это будет полезно для вас

Обратите внимание, что Re-Import Gradle Project может быть достаточно =), потому что он, кажется, делает все остальное

0 голосов
/ 30 октября 2018

Ваш код работает нормально и все правильно. Вам просто нужно это,

Сначала запустите приложение из IDE и дайте ему установить.
Во-вторых, Попробуйте удалить приложение из настроек устройства, а не из лаунчера или adb.


Надеюсь, что это работает!

...