我正在使用猎物源代码来开发我自己的防盗应用程序。根据git,我从那里得到了5个文件..但是我正在做一个主人,我认为这是正确的。
当我将它上传到eclipse时,我得到100个错误,其中一个仍然存在 FileConfigReader.java 错误是:
说明: config 无法解析或不是字段
资源:FileConfigReader.java
路径:/ LoginActivity / src / com / prey
地点:25号线
类型:Java问题
错误发生的行:
InputStream is = ctx.getResources()。openRawResource(R.raw.config);
该文件的代码:
/*******************************************************************************
* Created by Carlos Yaconi
* Copyright 2012 Fork Ltd. All rights reserved.
* License: GPLv3
* Full license at "/LICENSE"
******************************************************************************/
package com.prey;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import android.content.Context;
import android.content.res.Resources.NotFoundException;
public class FileConfigReader {
private static FileConfigReader _instance = null;
Properties properties;
private FileConfigReader(Context ctx) {
try {
PreyLogger.d("Loading config properties from file...");
properties = new Properties();
InputStream is = ctx.getResources().openRawResource(R.raw.config);
properties.load(is);
is.close();
PreyLogger.d("Config: "+properties);
} catch (NotFoundException e) {
PreyLogger.e("Config file wasn't found", e);
} catch (IOException e) {
PreyLogger.e("Couldn't read config file", e);
}
}
public static FileConfigReader getInstance(Context ctx){
if (_instance == null)
_instance = new FileConfigReader(ctx);
return _instance;
}
public String getAgreementId(){
return properties.getProperty("agreement-id");
}
public String getGcmId(){
return properties.getProperty("gcm-id");
}
public String getGcmIdPrefix(){
return properties.getProperty("gcm-id-prefix");
}
public String getc2dmAction(){
return properties.getProperty("c2dm-action");
}
public String getc2dmMessageSync(){
return properties.getProperty("c2dm-message-sync");
}
public String getPreyDomain(){
return properties.getProperty("prey-domain");
}
public String getPreySubdomain(){
return properties.getProperty("prey-subdomain");
}
public String getPreyUiSubdomain(){
return properties.getProperty("prey-ui-subdomain");
}
public String getPreyMinorVersion(){
return properties.getProperty("prey-minor-version");
}
public boolean isAskForPassword() {
return Boolean.parseBoolean(properties.getProperty("ask-for-password"));
}
public boolean isLogEnabled() {
return Boolean.parseBoolean(properties.getProperty("log-enabled"));
}
public String getAnalyticsUA() {
return properties.getProperty("analytics-ua");
}
}
任何帮助将不胜感激。 :)
答案 0 :(得分:1)
您是否创建了资源“config”?
此资源必须在系统中可用,与其他资源(布局,字符串等)相同。
查看本指南: http://developer.android.com/guide/topics/resources/providing-resources.html
您的文件“config”应位于res / raw文件夹中。