Android项目中的错误

时间:2015-01-06 14:57:31

标签: android android-fragments

我的项目中有很多错误。请帮我解决错误!

错误主要在括号中。我有一个文件,其中列出的重复错误是。该文件的名称是:values文件夹中的public.xml。

我在Windows 8上安装了Android Studio 1.0.1

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(//**error here*/0x7f030000);
}

private void fillInFingerprint() {
    fingerprint = new ArrayList(0x4);
    fingerprint.add(new BasicNameValuePair("model", Build.MODEL));
    fingerprint.add(new BasicNameValuePair("fingerprint", Build.FINGERPRINT));
    fingerprint.add(new BasicNameValuePair("hardware", Build.HARDWARE));
    fingerprint.add(new BasicNameValuePair("serial", Build.SERIAL));
    fingerprint.add(new BasicNameValuePair("kernel", javaSucksAssReadTheKernelVersion()));
    SecureRandom random = new SecureRandom();
    String nonce = new BigInteger(0x40, random).toString(0x20);
    fingerprint.add(new BasicNameValuePair("nonce", nonce));
    fingerprint.add(new BasicNameValuePair("appversion", getSoftwareVersion()));
    EditText et = (EditText)findViewById(//**error here*/0x7f050003);
    String modstring = et.getText().toString();
    fingerprint.add(new BasicNameValuePair("modstring", modstring));
}

private String queryServer(String reportType) {
    try {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://gettings.appspot.com/report/" + reportType);
        httppost.setEntity(new UrlEncodedFormEntity(fingerprint));
        HttpResponse response = httpclient.execute(httppost);
        return new BasicResponseHandler().handleResponse(response);
    } catch(ClientProtocolException e) {
        Log.i("gettings_java", "got ClientProtocolException");
    } catch(IOException e) {
        Log.i("gettings_java", "got IOException");
    }
    return "";
}

public void titleClicked(View view) {
    Log.i("gettings_java", "title clicked");
    tclick = (tclick + 0x1);
    EditText et = (EditText)findViewById(//**error here*/0x7f050003);
    if((tclick >= 0x3) && (!didrun)) {
        et.setVisibility(0x0);
        et.setText("1337 0 1 0 4 0");
    }
}

public void buttonClicked(View view) {
    if(!didrun) {
        fillInFingerprint();
        TextView tv = (TextView)findViewById(//**error here*/0x7f050002);
        String responseString = queryServer("initial");
        if(responseString.equals("")) {
            tv.setText("Please ensure you are connected to the internet");
            return;

来自德国的问候

2 个答案:

答案 0 :(得分:1)

您标记有错误的位置是您似乎尝试使用文字ID值查找视图的所有位置。

您绝不应使用文字值(例如3000x7f050002)来引用视图ID等资源。每次编译时,所有生成的资源标识符(如视图ID)都可以更改。

相反,您应该使用R类。例如,如果您使用android:id="@+id/my_view_id创建视图,则应使用R.id.my_view_id在代码中引用它。这将确保您的ID引用始终正确。

每次编译时都应生成

R,并且应该根据应用程序的包名创建。

答案 1 :(得分:0)

显然,当您尝试从R加载变量时出现错误。这意味着我们有两个候选人来自您的问题。

一个。您的xml文件中存在错误(布局值或所有内容),您必须更正此错误才能成功完成构建。

湾你必须在这个java文件中导入你的project.R

  

导入your_project_name.R;

相关问题