Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.IllegalAccessError:预验证类中的类ref已解析为意外实现_Java_Android - Fatal编程技术网

java.lang.IllegalAccessError:预验证类中的类ref已解析为意外实现

java.lang.IllegalAccessError:预验证类中的类ref已解析为意外实现,java,android,Java,Android,我的英语不好,希望你们能帮助我,谢谢大家 当前的项目是建立在android studio上的,但我遇到了一个问题65536 我尝试使用google的multidex解析,编译时没有任何问题,但在运行时出错 这个错误是错误的 这是build.gradle的主要模块 apply plugin: 'android' dependencies { compile fileTree(include: '*.jar', dir: 'libs') compile project(':myco

我的英语不好,希望你们能帮助我,谢谢大家

当前的项目是建立在android studio上的,但我遇到了一个问题65536

我尝试使用google的multidex解析,编译时没有任何问题,但在运行时出错

这个错误是错误的

这是build.gradle的主要模块

apply plugin: 'android'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile project(':mycommons')
    compile project(':PullToFreshLib')
    compile project(':XMF')
    compile project(':Iclap-Android-Eclipse-Library')
    compile 'com.android.support:multidex:1.0.1'
}

//configurations {
//    all*.exclude group: 'com.android.support', module: 'support-v4'
//}

android {

    compileSdkVersion 19
    buildToolsVersion '21.0.0'

    dexOptions {
        preDexLibraries = false
        jumboMode = true
    }

    defaultConfig {
//        applicationId "com.sht.smartcommunity"
//        minSdkVersion 11
//        targetSdkVersion 22
        multiDexEnabled true
    }

    aaptOptions{
        cruncherEnabled = false
        useNewCruncher = false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

//    afterEvaluate {
//        tasks.matching {
//            it.name.startsWith('dex')
//        }.each { dx ->
//            if (dx.additionalParameters == null) {
//                dx.additionalParameters = []
//            }
//            dx.additionalParameters += '--multi-dex' // enable multidex
//
//            // optional
//            // dx.additionalParameters += "--main-dex-list=$projectDir/<filename>".toString() // enable the main-dex-list
//        }
//    }

}

你在ReqResUtiles.java中有问题,在使用get方法调用web api时有问题…请发布你的完整代码@Z.RuntaoI我已经添加了完整的代码go up@Crazyandroy你必须在上面实现接口line@RameshKumar麻烦你,兄弟,但我不知道如何实施,因为这是ReqResUtiles.java中存在问题的注释类型,所以使用get方法调用web api时存在问题…请发布完整的代码@Z.runtai我已经添加了完整的代码go up@CrazyandRoidRoy你必须在上面实现接口line@RameshKumar麻烦你,兄弟,但我不知道如何实施,因为它是注释的类型
package com.sht.smartcommunity.http;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import org.liushui.mycommons.android.log.McLog;
import org.liushui.mycommons.android.util.McToastUtil;

import android.text.TextUtils;

import com.sht.smartcommunity.AppApplication;
import com.sht.smartcommunity.R;
import com.sht.smartcommunity.annotation.ReqParam;
import com.sht.smartcommunity.annotation.RespText;
import com.sht.smartcommunity.annotation.SecurityType;
import com.sht.smartcommunity.http.request.BaseRequest;
import com.sht.smartcommunity.http.response.FailResponse;
import com.sht.smartcommunity.http.response.IJsonObj;
import com.sht.smartcommunity.http.response.JsonStrResponse;
import com.sht.smartcommunity.security.AppSecurityManager;

public class ReqRespUtils {

    public static String[] makeGetUrl(BaseRequest request) {
        List<KeyValue> params = request.getParams();
        if (params == null) {
            params = new ArrayList<KeyValue>();
        }

        Class<?> cls = request.getClass();
        Field[] fs = cls.getFields();

        for (Field f : fs) {
            int modi = f.getModifiers();
            if (Modifier.isStatic(modi)) {
                continue;
            }
            //This is the wrong line 48
            ReqParam reqParam = f.getAnnotation(ReqParam.class);
            if (reqParam != null && !reqParam.asParam()) {
                continue;
            }
            KeyValue kv = new KeyValue();
            SecurityType type = SecurityType.None;
            if (reqParam == null || TextUtils.isEmpty(reqParam.value())) {
                kv.key = f.getName();
            } else {
                kv.key = reqParam.value();
            }

            if (reqParam != null) {
                type = reqParam.security();
            }
            kv.securityType = type;

            f.setAccessible(true);
            try {
                Object obj = f.get(request);
                if (obj == null) {
                    if (reqParam != null) {
                        if (reqParam.required()) {
                            McLog.e(f.getName()
                                    + " is null,but it is required.");
                            kv.value = "";
                            params.add(kv);
                        } else {
                            // kv.value = "";
                        }
                    } else {
                        kv.value = null; // ?
                        params.add(kv);
                    }
                } else {
                    kv.value = obj.toString();
                    params.add(kv);
                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        StringBuffer enSb = new StringBuffer();
        StringBuffer normalSb = new StringBuffer();
        boolean isFirst = true;
        for (KeyValue kv : params) {
            if (isFirst) {
                isFirst = false;
            } else {
                enSb.append("&");
                normalSb.append("&");
            }

            String v1 = encrpty(request, kv);
            String v2 = TextUtils.isEmpty(kv.value) ? "" : kv.value;

            enSb.append(kv.key + "=" + encode(v1));
            normalSb.append(kv.key + "=" + encode(v2));
        }
        if (TextUtils.isEmpty(request.url)) {
            McLog.w(request.getClass() + "'s url is empty, please check!!!");
        }
        String geturl1 = request.url + "?" + enSb.toString();
        String geturl2 = request.url + "?" + normalSb.toString();
        String[] res = new String[] { geturl1, geturl2 };
        return res;
    }
}
package com.sht.smartcommunity.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReqParam {

    public String value() default "";

    public boolean required() default false;

    public boolean asParam() default true;

    public SecurityType security() default SecurityType.None;
}