简体   繁体   中英

unresolved type error from classes imported from external jar file

I'm creating an android application using fuzzy logic. I have imported the jar library by adding it to the lib folder.

However, the classes that refer to these libraries show an error "couldn't be resolved to a type" .

I tried the solution, classes from android project library not resolved in android project . But it didn't work for me and the clean-refresh-build method too wasn't useful.

The code:

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);


}

ScreenShots:

The imported libraries do not seem to have a problem.

The classes cannot be resolved to a type

Where have you imported the jfuzzylite.jar file? I think you should see the jfuzzylite.jar file within the referenced libraries.

Have you tried building the jfuzzylite.jar using ant on the build.xml file provided with jfuzzylite?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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