从外部jar文件导入的类中未解决的类型错误

时间:2014-10-09 09:05:45

标签: java android eclipse fuzzy-logic

我正在使用模糊逻辑创建一个Android应用程序。我通过将jar库添加到lib文件夹来导入jar库。

但是,引用这些库的类显示错误“无法解析为类型”

我尝试了解决方案classes from android project library not resolved in android project。但它对我不起作用,clean-refresh-build方法也没用。

代码:

import java.sql.Savepoint;

import com.fuzzylite.*;
import com.fuzzylite.defuzzifier.*;
import com.fuzzylite.factory.*;
import com.fuzzylite.hedge.*;
import com.fuzzylite.imex.*;
import com.fuzzylite.norm.*;
import com.fuzzylite.norm.s.*;
import com.fuzzylite.norm.t.*;
import com.fuzzylite.rule.*;
import com.fuzzylite.term.*;
import com.fuzzylite.variable.*;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.SeekBar;
import android.widget.TextView;

private void fuzzy(){
    Engine engine = new Engine();
    engine.setName("Mamdani-Tip-Calculator");

    InputVariable inputVariable1 = new InputVariable();
    inputVariable1.setEnabled(true);
    inputVariable1.setName("FoodQuality");
    inputVariable1.setRange(1.000, 10.000);
    inputVariable1.addTerm(new Trapezoid("Bad", 0.000, 1.000, 3.000, 7.000));
    inputVariable1.addTerm(new Trapezoid("Good", 3.000, 7.000, 10.000, 11.000));
    engine.addInputVariable(inputVariable1);

    InputVariable inputVariable2 = new InputVariable();
    inputVariable2.setEnabled(true);
    inputVariable2.setName("Service");
    inputVariable2.setRange(1.000, 10.000);
    inputVariable2.addTerm(new Trapezoid("Bad", 0.000, 1.000, 3.000, 7.000));
    inputVariable2.addTerm(new Trapezoid("Good", 3.000, 7.000, 10.000, 11.000));
    engine.addInputVariable(inputVariable2);

    OutputVariable outputVariable = new OutputVariable();
    outputVariable.setEnabled(true);
    outputVariable.setName("Tip");
    outputVariable.setRange(0.000, 30.000);
    outputVariable.fuzzyOutput().setAccumulation(new AlgebraicSum());
    outputVariable.setDefuzzifier(new Centroid(200));
    outputVariable.setDefaultValue(Double.NaN);
    outputVariable.setLockValidOutput(false);
    outputVariable.setLockOutputRange(false);
    outputVariable.addTerm(new Gaussian("AboutTenPercent", 10.000, 2.000));
    outputVariable.addTerm(new Gaussian("AboutFifteenPercent", 15.000, 2.000));
    outputVariable.addTerm(new Gaussian("AboutTwentyPercent", 20.000, 2.000));
    engine.addOutputVariable(outputVariable);

    RuleBlock ruleBlock = new RuleBlock();
    ruleBlock.setEnabled(true);
    ruleBlock.setName("");
    ruleBlock.setConjunction(new AlgebraicProduct());
    ruleBlock.setDisjunction(new Maximum());
    ruleBlock.setActivation(new Minimum());
    ruleBlock.addRule(Rule.parse("if FoodQuality is Bad and Service is Bad then Tip is AboutTenPercent", engine));
    ruleBlock.addRule(Rule.parse("if FoodQuality is Bad and Service is Good then Tip is AboutFifteenPercent", engine));
    ruleBlock.addRule(Rule.parse("if FoodQuality is Good and Service is Bad then Tip is AboutFifteenPercent", engine));
    ruleBlock.addRule(Rule.parse("if FoodQuality is Good and Service is Good then Tip is AboutTwentyPercent", engine));
    engine.addRuleBlock(ruleBlock);


}

截图:

The imported libraries do not seem to have a problem.

The classes cannot be resolved to a type

1 个答案:

答案 0 :(得分:0)

你在哪里导入了jfuzzylite.jar文件?我想你应该在引用的库中看到jfuzzylite.jar文件。

您是否尝试使用jfuzzylite提供的build.xml文件中的ant构建jfuzzylite.jar?