简体   繁体   English

AndroidAnnotations未找到活动

[英]Activity not found with AndroidAnnotations

Hi i've added the AndroidAnnotations and configured it; 嗨,我添加了AndroidAnnotations并对其进行了配置; it generates the activity with the underscore _ as suffix, but when I try to lunch the app, it gives this error 它使用下划线_作为后缀生成活动,但是当我尝试在应用程序中午餐时,它会出现此错误

   05-26 04:17:23.524: E/AndroidRuntime(5096): java.lang.RuntimeException: 
   Unable to instantiate activity
   ComponentInfo{android_app.candgo/android_app.candgo.HelloAndroidActivity_}:  
   java.lang.ClassNotFoundException: Didn't find class
   "android_app.candgo.HelloAndroidActivity_"    
   on path: /data/app/android_app.candgo-1.apk

Any suggestion about why it doesn't work 关于它为什么不起作用的任何建议

PD: I've ADT v22 PD: I've the HelloAndroidActivity_ registered at manifest PD:我的ADT v22 PD:我在清单上注册了HelloAndroidActivity_

This is my manifest.xml (sorry for the delay) 这是我的manifest.xml(抱歉延迟)

  <uses-sdk android:minSdkVersion="8"
            android:targetSdkVersion="16" />

  <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name="MainActivity_">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>
</manifest>

You need to add the ".apt_generated", or whichever folder AA outputs to, to your source directories listing. 您需要将“.apt_generated”或AA输出的文件夹添加到源目录列表中。 In Android Studio, you can find this in Project Settings -> Modules -> module_in_question -> Sources 在Android Studio中,您可以在项目设置 - >模块 - > module_in_question - > Sources中找到它

you need to register the activity class(AndroidAnnotations) in your manifest.xml,like: <activity android:name = "com.your.packageName" android:screenOrientation="portrait" android:configChanges = "orientation"/> 你需要在manifest.xml中注册活动类(AndroidAnnotations),如: <activity android:name = "com.your.packageName" android:screenOrientation="portrait" android:configChanges = "orientation"/>
then you can use it. 然后你可以使用它。

Check your manifest file for a entry of the activity. 检查清单文件以获取活动的条目。 Check the name. 检查名称。

If you updated ADT to rev 22. you can try this java.lang.ClassNotFoundException after changing nothing in the project but upgrading eclipse android sdk . 如果您将ADT更新为rev 22.您可以在更改项目中的任何内容但升级eclipse android sdk之后尝试此java.lang.ClassNotFoundException

Check the package name in manifest 检查清单中的包名称

    <manifest package="com.example.mypackaganame" //check the name

Check under application tag for the activity entry 在应用程序标记下检查活动条目

    <activity
        android:name="com.example.mypackaganame.MainActivity"
        // this is the main activity
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Say you have second Activity. 假设您有第二个活动。 This how you declare for implicit intents 这是你如何声明隐式意图

     <activity
        android:name="com.example.mypackaganame.SecondActivity"
        // this is the Second activity
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.mypackaganame.SecondActivity" />

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

Foe explicit intents 敌人明确意图

      <activity
        android:name=".SecondActivity"
        // this is the Second activity
        android:label="@string/app_name" >
    </activity>           

If you are using Eclipse follow these steps : 如果您使用的是Eclipse,请执行以下步骤:

Step 1. Go to Java Compiler and make sure that Compiler compliance level is set to 1.6, otherwise the processor won't be activated 步骤1.转到Java Compiler并确保将Compiler compliance level设置为1.6,否则将不会激活处理器

Step 2. Go to Java Compiler > Annotation Processing and choose Enable annotation processing 步骤2.转到Java Compiler > Annotation Processing并选择Enable annotation processing

step 3. Go to Java Compiler > Annotation Processing > Factory Path and add the processor JAR : androidannotations-XXXjar. 步骤3.转到Java Compiler > Annotation Processing > Factory Path并添加处理器JAR: androidannotations-XXXjar。

step 4 Confirm the workspace rebuild 步骤4确认工作区重建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AndroidAnnotations的继承活动 - Inheritance activity with AndroidAnnotations AndroidAnnotations Nothing Generated,Empty Activity - AndroidAnnotations Nothing Generated, Empty Activity AndroidAnnotations + SherlockFragmentActivity-找不到片段类 - AndroidAnnotations + SherlockFragmentActivity - fragment class not found AndroidAnnotations:如何处理“活动未在清单中注册” - AndroidAnnotations: how to handle “activity is not registered in the manifest” 从另一个应用程序启动活动? (使用AndroidAnnotations) - Launching Activity from another App? (with AndroidAnnotations) 如何在支持AndroidAnnotations的适配器中传递Application而不是Activity上下文? - How to pass Application instead of Activity context in an AndroidAnnotations-powered adapter? AndroidAnnotations + Instant App - 生成的<applicationId> .R 类找不到 - AndroidAnnotations + Instant App - The generated <applicationId>.R class cannot be found 如何使AndroidAnnotations生成的类接受WeakReference <Activity> 而不是其构造函数中的Activity - How to make AndroidAnnotations-generated class accept a WeakReference<Activity> instead of Activity in its constructor AndroidAnnotations和Dagger - AndroidAnnotations and Dagger AndroidAnnotations和Dagger 2 - AndroidAnnotations and Dagger 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM