简体   繁体   English

Android示例-加速度计和APIDemos无法构建

[英]Android samples - Accelerometer and APIDemos do not build

I am new to Android development. 我是Android开发的新手。 I have succesfully installed eclipse with Android Developer Tool plugin and many of the samples work fine. 我已经使用Android Developer Tool插件成功安装了eclipse,并且许多示例都能正常工作。

But Android samples - Accelerometer and APIDemos do not build . 但是Android示例Accelerometer and APIDemos do not build I see many build errors notifying to fix the errors in code. 我看到许多构建错误通知要修复代码中的错误。 I dont think Google has released APIDemo sample with build errors. 我认为Google尚未发布带有构建错误的APIDemo示例。

Thanks in advance, please advice how to fix these errors, or if any configuration/setting is required. 在此先感谢您,建议如何解决这些错误,或者是否需要任何配置/设置。

I have set the Java compiler compliance level to 1.6. 我已将Java编译器的遵从性级别设置为1.6。

Error information(for acceralometer sample): 错误信息(对于加速度计样品):

The project contains error(s) in application. 该项目包含应用程序中的错误。 Please fix them before running 请在运行之前对其进行修复

Error details:

    The method onAccuracyChanged(Sensor, int) of type AccelerometerPlayActivity.SimulationView must override a superclass method    
    AccelerometerPlayActivity.java  /AccelerometerPlay/src/com/example/android/accelerometerplay    line 456    
    Java Problem
    Call requires API level 8 (current min is 5): 
    android.view.Display#getRotation    AccelerometerPlayActivity.java  /AccelerometerPlay/src/com/example/android/accelerometerplay    
    line 389    Android Lint Problem

Regards, Jai 此致Jai

Look for the line androidminSdkVersion ="5" in your android.manifest file 在android.manifest文件中查找androidminSdkVersion ="5"

and change its value from 5 to 8 or anything more than 8 并将其值从5 to 8更改5 to 8或大于8

在此处输入图片说明

Alternative is Go to project properties by right clicking on you project, thereafter look for Android in properties. 另一种方法是通过右键单击 project进入project properties ,然后在属性中查找Android You have to select the build target here equivalent to the api for which it the sample project is build for 您必须在此处选择与示例项目要为其构建equivalent to the apibuild target

Refer Image 参考图片 在此处输入图片说明

Say if you are using the sample from folder android-12 then you have to check the same option(ie API Level 12 ) here in properties 假设您使用的是android-12文件夹中的示例,则必须在此处在属性中检查相同的选项(即API Level 12

A possible reason can be a slow PC, which does not build in time. 可能的原因可能是PC速度慢,无法及时构建。 Then errors occur due to absence of R.java 然后由于缺少R.java而发生错误

In that case (errors are with something like R.id.stuff ), build the project and wait. 在这种情况下( R.id.stuff类的R.id.stuff ),构建项目并等待。

I found the fix myself! 我自己找到了解决方法!

Earlier I tried with Andriod version 4.0. 之前,我尝试使用Andriod 4.0版。 Now I just tried ApiDemos sample with Android version 4.1.2. 现在,我尝试使用Android 4.1.2版的ApiDemos示例。 It worked fine. 工作正常。 I also deployed the apk in my mobile. 我也在自己的手机中部署了apk。 It just works fine. 一切正常。

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

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