com.android.volley.ServerError错误实例VolleyError

问题描述 投票:2回答:3

早上好

我有一个问题“com.android.volley.ServerError”

这是我的build.gradle文件'app'

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.azizsana.espacemembre2"
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation project(':volley')
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

文件:build.gradle项目:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在logcat中,我看到“

无法找到图层

(com.example.azizsana.espacemembre2/com.example.azizsana.espacemembre2.RegisterActivity#0) in layer parent (no-parent).

android android-gradle android-volley build.gradle
3个回答
0
投票

根据您的错误代码,您的后端可能存在问题。您可以查看更多表格https://www.w3.org/Protocols/HTTP/HTRESP.htmlhttp://www.restapitutorial.com/httpstatuscodes.html这些文件。

Unexpected response code 404 for http://192.168.3.101/android/tutoEspaceMembre/register.php

404状态代码的含义:

Not found 404
The server has not found anything matching the URI given

0
投票

删除这两行

implementation project(':volley')
implementation 'com.mcxiaoke.volley:library:1.0.19'

并添加Google排球

implementation 'com.android.volley:volley:1.1.0'

您收到404错误,表示api /端点不存在。

检查您要求的结束点

目前的终点是http://192.168.3.101/android/tutoEspaceMembre/register.php

如果你能够从你的笔记本电脑/台式机到达终点并且无法从Android那里击中它,那么,

这有多种原因。

如果您在系统中运行api并且Android应用程序在同一系统的模拟器中运行,则需要将IP地址更改为10.0.2.2(默认AVD使用10.0.2.2,genymotion使用10.0.3.2)。

第二种情况是,如果您在手机中运行应用程序并在任何其他计算机上运行api,请确保两者都连接到同一网络,因为您正在处理IP地址


0
投票

我想你应该删除这一行:

implementation project(':volley')

因为你在下面使用它:

implementation 'com.mcxiaoke.volley:library:1.0.19'

尝试更新gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.azizsana.espacemembre2"
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    //implementation project(':volley') <---- You dont need this line
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

和:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
© www.soinside.com 2019 - 2024. All rights reserved.