简体   繁体   English

Intelij Idea Android应用程序开发编译时间检查

[英]Intelij Idea Android Application Development Compile Time Check

I am very new to Android/Java Development. 我对Android / Java开发非常陌生。 I have an application that should run on API Level 10 and above. 我有一个应在API级别10以上的应用程序。

this is my AndroidManifest.xml 这是我的AndroidManifest.xml

 <uses-sdk android:minSdkVersion="10"
  android:targetSdkVersion="17"/>

and this is my application structure in InteliJ Idea IDE. 这是我在InteliJ Idea IDE中的应用程序结构。

在此处输入图片说明

According to android documents PopupMenu added in API Level 11 but when I use PopupMenu in any activity, application compile successfully! 根据在API级别11中添加的Android文档PopupMenu ,但是当我在任何活动中使用PopupMenu时,应用程序都会成功编译! i think IDE should inform me in some way like compile time error or warning. 我认为IDE应该以某种方式(例如编译时错误或警告)通知我。

I configured application or IDE incorrectly? 我配置的应用程序或IDE错误? or I should check every component that used in application manually, to ensure about minimum SDK compatibility? 还是应该手动检查应用程序中使用的每个组件,以确保最低的SDK兼容性?

thanks. 谢谢。

UPDATE 更新

This is snapshot of my code, there is no warning in code editor. 这是我的代码的快照,代码编辑器中没有警告。

在此处输入图片说明

IntelliJ does show a warning to indicate that you are using Classes which are not supported by your minimum SDK level, in your case at the lines of code where you use the PopupMenu, but it will still compile. IntelliJ确实会显示警告,表明您正在使用最低SDK级别不支持的类(在您的情况下,在使用PopupMenu的代码行中,但仍会编译)。 When you try to run the application on a API Level 10 device it will crash as soon as you use the PopupMenu inside your App. 当您尝试在API Level 10设备上运行该应用程序时,一旦您在应用程序内使用PopupMenu,它将崩溃。

EDIT: 编辑:

Maybe you Module SDK is not set correctly, try this: 也许您未正确设置Module SDK,请尝试以下操作:

1) Go to Modules in Project Structre 1)转到项目结构中的模块
2) Select your Android App Module 2)选择您的Android应用模块
3) In the Dependencies Tab select the correct SDK for your App. 3)在“依赖关系”选项卡中,为您的应用选择正确的SDK。

In your case you should select "Android 2.3.3 Google API's" which corresponds to API level 10. 在您的情况下,您应该选择与API级别10相对应的“ Android 2.3.3 Google API”。

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

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