Java 带有DexForDeBug错误的TransformClasses

Java 带有DexForDeBug错误的TransformClasses,java,android,python,android-studio-2.3,jython-2.7,Java,Android,Python,Android Studio 2.3,Jython 2.7,我正在使用android studio 2.3.2开发一个应用程序,我也使用了Jython,因为我的应用程序中需要一个Python类。 我已经安装了Jython 2.7.0并将其添加到path 我试图通过检查其他问题来解决我的问题,如: 这是我的代码: 接口SA package com.aso.mdasa.mdasa; interface SA { Set resultCorpus(String DataBase, String polarity, String fea

我正在使用android studio 2.3.2开发一个应用程序,我也使用了Jython,因为我的应用程序中需要一个Python类。 我已经安装了
Jython 2.7.0
并将其添加到
path

我试图通过检查其他问题来解决我的问题,如:

这是我的代码:

接口SA

package com.aso.mdasa.mdasa;
interface SA {
    Set resultCorpus(String DataBase, String polarity, String feature);
    int resultSearch(String tweet);
}
情绪分析.java

class SentimentAnalysis {

    private final Class interfaceType;
    private final PyObject klass;

    // Constructor obtains a reference to the importer, module, and the class name
    private SentimentAnalysis(PySystemState state, Class interfaceType, String moduleName, String className) {
        this.interfaceType = interfaceType;
        PyObject importer = state.getBuiltins().__getitem__(Py.newString("__import__"));
        PyObject module = importer.__call__(Py.newString(moduleName));
        klass = module.__getattr__(className);
        System.err.println("module=" + module + ",class=" + klass);
    }

    // This constructor passes through to the other constructor
    public SentimentAnalysis(Class interfaceType, String moduleName, String className) {
        this(new PySystemState(), interfaceType, moduleName, className);
    }

    // All of the followng methods return
    // a coerced Jython object based upon the pieces of information
    // that were passed into the SentimentAnalysis. The differences are
    // between them are the number of arguments that can be passed
    // in as arguents to the object.

    public Object createObject() {
        return klass.__call__().__tojava__(interfaceType);
    }


    public Object createObject(Object arg1) {
        return klass.__call__(Py.java2py(arg1)).__tojava__(interfaceType);
    }

    Object createObject(Object arg1, Object arg2) {
        return klass.__call__(Py.java2py(arg1), Py.java2py(arg2)).__tojava__(interfaceType);
    }

    public Object createObject(Object arg1, Object arg2, Object arg3)
    {
        return klass.__call__(Py.java2py(arg1), Py.java2py(arg2),
                Py.java2py(arg3)).__tojava__(interfaceType);
    }

    private Object createObject(Object args[], String keywords[]) {
        PyObject convertedArgs[] = new PyObject[args.length];
        for (int i = 0; i < args.length; i++) {
            convertedArgs[i] = Py.java2py(args[i]);
        }

        return klass.__call__(convertedArgs, keywords).__tojava__(interfaceType);
    }

    public Object createObject(Object... args) {
        return createObject(args, Py.NoKeywords);
    }

}
课程结果搜索

public class ResultSearch extends FragmentActivity{

    private String search;
    private ImageView img ;
    public static final int[] photos = {
            R.drawable.v_bad,
            R.drawable.bad,
            R.drawable.good,
            R.drawable.v_good } ;

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

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

    public void onStart(){
        super.onStart();
        search = getIntent().getStringExtra("text");
        img = (ImageView) findViewById(R.id.img);
        sentimentAnalysis();
    }

    public void sentimentAnalysis() {

        SentimentAnalysis sentimentA = new SentimentAnalysis(
                SA.class, "SAPython", "SentimentAnalysis");

        SA sa = (SA) sentimentA.createObject();

        double result = sa.resultSearch(search);

        if (result < -0.5)
            img.setBackground(getResources().getDrawable(photos[0]));
        if (result >= -0.5 && result < 0)
            img.setBackground(getResources().getDrawable(photos[1]));
        if (result >= 0 && result < 0.5)
            img.setBackground(getResources().getDrawable(photos[2]));
        if (result >= 0.5)
            img.setBackground(getResources().getDrawable(photos[3]));
    }
}
这是我的gradle.properties:

public class ResultSearch extends FragmentActivity{

    private String search;
    private ImageView img ;
    public static final int[] photos = {
            R.drawable.v_bad,
            R.drawable.bad,
            R.drawable.good,
            R.drawable.v_good } ;

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

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

    public void onStart(){
        super.onStart();
        search = getIntent().getStringExtra("text");
        img = (ImageView) findViewById(R.id.img);
        sentimentAnalysis();
    }

    public void sentimentAnalysis() {

        SentimentAnalysis sentimentA = new SentimentAnalysis(
                SA.class, "SAPython", "SentimentAnalysis");

        SA sa = (SA) sentimentA.createObject();

        double result = sa.resultSearch(search);

        if (result < -0.5)
            img.setBackground(getResources().getDrawable(photos[0]));
        if (result >= -0.5 && result < 0)
            img.setBackground(getResources().getDrawable(photos[1]));
        if (result >= 0 && result < 0.5)
            img.setBackground(getResources().getDrawable(photos[2]));
        if (result >= 0.5)
            img.setBackground(getResources().getDrawable(photos[3]));
    }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    dexOptions {
        incremental true
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "com.aso.mdasa.mdasa"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // Enabling multidex support.
        multiDexEnabled true
        compileOptions.encoding = 'UTF8'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:multidex:1.0.1'
    testCompile 'junit:junit:4.12'
    compile files('libs/jython-standalone-2.7.0.jar')
}
ject-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4608M -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true