com.android.volley.ServerError error instance of VolleyError - PullRequest
0 голосов
/ 04 июня 2018

Доброе утро

У меня проблема " 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).

Ответы [ 3 ]

0 голосов
/ 04 июня 2018

Удалите эти две строки

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

и добавьте залп Google

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

Вы получаете ошибку 404, означающую, что точка доступа / конечная точка не завершена.

Проверьте конечную точку, которую вы запрашиваете

текущая конечная точка равна http://192.168.3.101/android/tutoEspaceMembre/register.php.

Если вы можете достичь конечной точки со своего ноутбука / настольного компьютера и не можете поразить ееот android тогда,

Это несколько причин для этого.

Если в вашей системе запущен API-интерфейс, а приложение Android запущено в симуляторе той же системы, вам нужно изменить IP-адрес на 10.0.2.2 (используйте 10.0.2.2 для AVD по умолчанию и 10.0.3.2 для гений.).

Второй случай: если вы используете приложение на своем телефоне и api на любом другом компьютере, убедитесь, что оба подключены к одной сети, поскольку вы работаете с IP-адресом

0 голосов
/ 04 июня 2018

Исходя из вашего кода ошибки, может быть проблема с вашей внутренней стороной.Вы можете проверить больше форм https://www.w3.org/Protocols/HTTP/HTRESP.html и http://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 голосов
/ 04 июня 2018

Я думаю, вам следует удалить эту строку:

implementation project(':volley')

Поскольку вы используете ее ниже:

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

Попробуйте обновить grandle:

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
}
...