简体   繁体   English

第一个Android应用程序(32/64位问题?)

[英]First Android App (32/64 bit issue?)

I am trying to build the "hello world" example on Eclipse (tried NetBeans as well). 我正在尝试在Eclipse上构建“ hello world”示例(也尝试过NetBeans)。 The code is very simple: 代码很简单:

package com.example.myfirstapp;


import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

I get 2 "R cannot be resolved to a variable" errors. 我收到2个“ R无法解析为变量”错误。

As this seems to be a known issue, I already tried all the solutions regarding import, clean, restarting Eclipse, checking the manifest, etc 因为这似乎是一个已知问题,所以我已经尝试了有关导入,清理,重新启动Eclipse,检查清单等的所有解决方案。

A few of the answers, however, talk about some issue with missing 32-bit libraries on 64-bit systems (I use 64b Windows 7). 但是,有几个答案是关于64位系统(我使用64b Windows 7)缺少32位库的一些问题。 I also noticed that Eclipse does not flag errors in ANY other folders. 我还注意到Eclipse不会标记任何其他文件夹中的错误。 Also, that my project gen folder is empty. 另外,我的项目gen文件夹为空。

Since the code is very simple, I am pretty sure the problem is elsewhere. 由于代码非常简单,因此我可以肯定问题出在其他地方。 Unfortunately, I do not know enough about Java, Eclipse or Netbeans to fix it. 不幸的是,我对Java,Eclipse或Netbeans的了解不足以解决它。

I would appreciate any help. 我将不胜感激任何帮助。

You are missing the java import needed to resolve to the activity_main.xml, so add 您缺少解析为activity_main.xml所需的Java导入,因此添加

import com.example.myfirstapp.R;
(this should be whatever your app package is your androidmanifest and then ".R") (这应该是您的应用程序包是您的androidmanifest,然后是“ .R”)

under your package line ( package com.example.myfirstapp; ) 在您的包装行下( package com.example.myfirstapp;

You IDE should stop complaining 您的IDE应该停止抱怨

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

相关问题 Android应用中的纯Java:32位还是64位? - Pure java in Android app : 32 or 64 bit? android SDK 32位和64位兼容性 - android SDK 32 bit and 64 bit compatibility 64位android,32位应用程序,32位本机库 - 64 bit android, 32 bit application with 32 bit native library 将 mat 从 java 传递到 c++ jni android arm64-v8a 32/64 位的问题 - issue passing mat from java to c++ jni android arm64-v8a 32/64 bit 更新的64位Xamarin Android应用程序被旧的32位版本覆盖 - Updated 64-Bit Xamarin Android App gets overridden by old 32-Bit version Android Studio 将应用程序与 -lGLESv3 正确链接到 64 位臂,但不是 32 位臂 - Android Studio properly links app with -lGLESv3 for 64 bit arm, but not 32 bit arm 如果我具有32位本机库,那么Android应用仍是64位吗? - Is an Android app still 64bit if i have a 32bit native libary? 为什么32位Android应用程序可以在64位设备上运行? - Why 32 bit Android app can run on 64-bit devices? 如何在Android棒棒糖中以编程方式知道应用程序的进程是32位还是64位? - How to know a process of an app is 32-bit or 64-bit programmatically in Android lollipop? 在运行时获取android位版本(32位或64位) - Get android bit version (32 bit or 64 bit) at runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM