【问题标题】:Android Annotations - default activity not foundAndroid 注释 - 未找到默认活动
【发布时间】:2015-02-23 05:33:31
【问题描述】:

我在 Android Studio 中使用 android 注释,并且在运行时(成功构建后)不断收到错误消息,即找不到默认活动。它来来去去,有时只需要重新启动 Android Studio,有时需要清理并重建,有时它就不会消失(我不知道如何始终如一地重现它)。

我知道事情有些错误,但是如何始终如一地重现此错误,以及每次出现时删除它的可靠步骤

    <activity
        android:name="com.example.somghosh.earthmiles.views.MainActivity_"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    </activity>

build.girdle

buildscript {
    repositories {
        mavenCentral()

    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'

    }
}


apply plugin: 'com.android.application'
apply plugin: 'android-apt'

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots/"
    }
}


android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.example.somghosh.earthmiles"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
}

apt {
    arguments {
        androidManifestFile variant.processResources.manifestFile
        resourcePackageName "com.example.somghosh.earthmiles"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    apt "org.androidannotations:androidannotations:3.2"
    compile 'org.androidannotations:androidannotations-api:3.2'
    //Core
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'
    //Optional for built-in cards
    compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.0.1'
    //Optional for RecyclerView
    compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.0.1'
    //Optional for staggered grid view
    compile 'com.github.gabrielemariotti.cards:cardslib-extra-staggeredgrid:2.0.1'
    //Optional for drag and drop
    compile 'com.github.gabrielemariotti.cards:cardslib-extra-dragdrop:2.0.1'
    compile 'in.srain.cube:ultra-ptr:1.0.5'
    compile 'it.neokree:MaterialTabs:0.10'
    compile 'com.android.support:support-annotations:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.squareup.retrofit:retrofit:1.8.0'
    compile 'com.google.code.gson:gson:2.3.1'
    //    compile 'com.google.code.gson:gson:1.7.2'
    //    compile 'org.parceler:parceler:0.2.15'
    // new for fix
    compile 'org.parceler:parceler-api:0.2.16-SNAPSHOT'
    provided 'org.parceler:parceler:0.2.16-SNAPSHOT'
    compile 'com.squareup.okhttp:okhttp:2.1.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.github.siyamed:android-shape-imageview:0.9.2'
    compile 'com.squareup.picasso:picasso:2.4.0'
    provided 'org.projectlombok:lombok:1.14.8'
    apt "org.projectlombok:lombok:1.14.8"
    compile 'com.github.talenguyen:prettysharedpreferences:1.0.2'
    compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
        // exclusion is not neccessary, but generally a good idea.
        exclude group: 'com.google.android', module: 'support-v4'
    }
    compile 'com.afollestad:material-dialogs:0.4.7'
//    compile 'commons-beanutils:commons-beanutils-core:1.8.3'
}

【问题讨论】:

  • 我也面临同样的问题。你解决了吗?
  • 你能解决吗,遇到类似的问题。

标签: android android-activity android-studio android-manifest android-annotations


【解决方案1】:

这似乎是 Android Studio 的一个错误,我也有。它似乎忘记了AA生成的构建目录,因此无法解析其中生成的类。

最快的解决方案是打开构建变体(视图 -> 工具窗口 -> 构建变体,如果它还没有在 UI 上),将模块(应用)的构建变体从调试更改为发布然后返回调试。 Android Studio 将获取更改并再次解决丢失的类。

编辑:有一个更好的解决方案,请查看我的其他答案。

【讨论】:

    【解决方案2】:

    只需将 apt 插件从 1.2 更改为 1.3 或更高版本即可解决问题!

    classpath "com.neenbedankt.gradle.plugins:android-apt:1.4"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多