简体   繁体   中英

How to add new activity to existing project in Android Studio - “Project not ready”

What needs to be done to add a new activity to existing project that works and compiles but has "Project not ready" in the menu. Please see the picture.

Other than that all works, so I don't know what IDE means by "Project not ready"

项目没有准备菜单样本

This is a little bit over a year but i thought i would provide an answer for anyone (novice like me) who may encounter the same problem. I had the exact same problem as depicted and denoted. It was fixed by

  • Cleaning the project (Build --> Clean Project)
  • Sync with Gradle ( Tools --> Android --> Sync project with Gradle files)

(Not an exact answer) Observation:

I don't know exactly what happened, but it works now, all I could notice is that gradle had some error from unclean build likely I must have had some code changes resulting in invisible compilation errors. After good build menus available again.

Please post your "observation" if you don't know exact answer.

Thanks

If you want to add a Activity to an android application, you have to Extend Activity from one of your classes like this:

public class SecondActivity extends Activity

And add that activity to your manifest.

       <activity
            android:name=".ActivitySecondClass"
            android:label="@string/app_name2" >

        </activity>

You have to give the project time to build first. Wait a minute or two before jumping in.

I had the same issue. I fixed it by clearing the cache. (File > Invalidate caches & Restart).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM