我如何解决这个问题"没有这样的方法错误:没有静态方法"

时间:2018-01-14 23:17:55

标签: java android android-asynctask

嗨,我有这个错误,我不知道如何解决它:

01-14 20:29:40.081 2584-2584/com.climb.eip.climb E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.climb.eip.climb, PID: 2584
    java.lang.NoSuchMethodError: No static method getScreenWidthDp(Landroid/content/res/Resources;)I in class Landroid/support/v4/content/res/ConfigurationHelper; or its super classes (declaration of 'android.support.v4.content.res.ConfigurationHelper' appears in /data/app/com.climb.eip.climb-2/base.apk:classes3.dex)
                                                                       at android.support.design.widget.FloatingActionButton.getSizeDimension(FloatingActionButton.java:442)
                                                                       at android.support.design.widget.FloatingActionButton.getSizeDimension(FloatingActionButton.java:434)
                                                                       at android.support.design.widget.FloatingActionButton.onMeasure(FloatingActionButton.java:189)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                                                                       at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:714)
                                                                       at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:786)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                                                                       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                                                                       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
                                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
                                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                                                                       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
                                                                       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
                                                                       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
                                                                       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                                                                       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:687)
                                                                       at android.view.View.measure(View.java:19734)
                                                                       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2271)
                                                                       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1358)
                                                                       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1607)
                                                                       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
                                                                       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
                                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
                                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:683)
                                                                       at android.view.Choreographer.doFrame(Choreographer.java:619)
                                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
                                                                       at android.os.Handler.handleCallback(Handler.java:751)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                       at android.os.Looper.loop(Looper.java:154)
                                                                       at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
01-14 20:29:40.130 2584-3852/com.climb.eip.climb V/FA: Connection attempt already in progress
01-14 20:29:40.147 2584-3872/com.climb.eip.climb W/System.err: java.io.FileNotFoundException: http://api.climb.ovh/api
01-14 20:29:40.158 2584-3872/com.climb.eip.climb W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:250)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at com.climb.eip.climb.activities.FollowersActivity.readURL(FollowersActivity.java:80)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at com.climb.eip.climb.activities.FollowersActivity.access$000(FollowersActivity.java:24)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at com.climb.eip.climb.activities.FollowersActivity$READJSON.doInBackground(FollowersActivity.java:49)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at com.climb.eip.climb.activities.FollowersActivity$READJSON.doInBackground(FollowersActivity.java:46)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:304)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
01-14 20:29:40.159 2584-3872/com.climb.eip.climb W/System.err:     at java.lang.Thread.run(Thread.java:761)
01-14 20:32:59.037 2584-2604/com.climb.eip.climb I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
01-14 20:32:59.037 2584-2604/com.climb.eip.climb I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation

这是我的代码:

public class FollowersActivity extends AppCompatActivity {

private static final String TAG = "FollowersActivity";

ArrayList<Profile> arrayList;
ListView Followers;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_followers);
    arrayList = new ArrayList<>();
    Followers = findViewById(R.id.Followerslist);

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new READJSON().execute("http://api.climb.ovh/api");
        }
    });
}

class READJSON extends AsyncTask<String, String, String>{
    @Override
    protected String doInBackground (String... params){
        return readURL(params[0]);
    }

    @Override
    protected void onPostExecute(String content) {
        super.onPostExecute(content);
        try {
            JSONObject jsonObject = new JSONObject(content);
            JSONArray jsonArray = jsonObject.getJSONArray("profile");
            for (int i = 0; i < jsonArray.length(); i++){
                JSONObject profileObject = jsonArray.getJSONObject(i);
                arrayList.add(new Profile(
                        profileObject.getString("pictureURL"),
                        profileObject.getString("Username"),
                        profileObject.getBoolean("Follow")
                        ));
                Log.d(TAG, "List successful");
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        ProfileListAdapter adapter = new ProfileListAdapter(getApplicationContext(), R.layout.list_view_custom, arrayList);
        Followers.setAdapter(adapter);
    }
}

private static String readURL(String theUrl){
    StringBuilder content = new StringBuilder();
    try {
        URL url = new URL(theUrl);
        URLConnection urlConnection = url.openConnection();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        String line;
        line = null;
        while ((line == bufferedReader.readLine())!= false){
            content.append(line + "\n");
        }
        bufferedReader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return content.toString();
}

}

我的Gradle有最新版本:

android {
compileSdkVersion 26
buildToolsVersion '26.0.2'

defaultConfig {
    applicationId "com.climb.eip.climb"
    minSdkVersion 19
    targetSdkVersion 26
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.volley:volley:1.0.0'

compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'

compile 'com.aurelhubert:ahbottomnavigation:2.0.6'

compile 'com.squareup:otto:1.3.8'

compile 'com.mikhaellopez:circularimageview:3.0.2'

compile 'com.jakewharton:butterknife:8.8.1'

compile 'com.google.android.exoplayer:exoplayer:r2.5.2'
compile 'com.google.gms:google-services:3.1.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.apis:google-api-services-oauth2:v1-rev134-1.22.0'
compile 'com.facebook.android:facebook-android-sdk:4.29.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile('com.afollestad.material-dialogs:core:0.8.5.9@aar') { transitive = true }
annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

1 个答案:

答案 0 :(得分:0)

尝试更新所有支持库。我有同样的问题,我就这样解决了。