Volley android mysql error

saya mencoba membuat aplikasi android dengan menggunakan volley mysql tapi aplikasinya crash, kalo menurut saya sih errornya ada di volleynya apakah benar ??

MainActivity.java

package com.example.recyclerviewvoley;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private String URL="http://pembuatanprogram.000webhostapp.com/produk.php";
    private RecyclerAdapter recyclerAdapter;
    private RecyclerView recyclerView;
    private ArrayList<Data> listdata;

    private GridLayoutManager layoutManager;

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

        recyclerView=(RecyclerView)findViewById(R.id.recyclerView);
        recyclerView.setHasFixedSize(true);
        layoutManager=new GridLayoutManager(this,2);
        layoutManager.setOrientation(GridLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);

        listdata=new ArrayList<Data>();
        AmbilData();
        recyclerAdapter=new RecyclerAdapter(this,listdata);
        recyclerView.setAdapter(recyclerAdapter);
        recyclerAdapter.notifyDataSetChanged();
    }

    public void AmbilData(){
        JsonArrayRequest arrayRequest=new JsonArrayRequest(URL + "/produk.php",
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        if (response.length() > 0) {
                            for (int i = 0; i < response.length(); i++) {
                                try {
                                    JSONObject data = response.getJSONObject(i);
                                    Data item = new Data();
                                    item.setId(data.getString("id"));
                                    item.setJudul(data.getString("judul"));
                                    item.setHarga(data.getString("Harga"));
                                    item.setThubnail(URL + "/img/" + data.getString("gambar"));
                                    listdata.add(item);
                                    recyclerAdapter.notifyDataSetChanged();
                                } catch (JSONException e) {

                                }
                            }
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                }){

        };
        Volley.newRequestQueue(this).add(arrayRequest);
    }
}

Data.java

package com.example.recyclerviewvoley;

public class Data {
    private String id;
    private String judul;
    private String harga;
    private String thubnail;

    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }

    public String getJudul() {
        return judul;
    }
    public void setJudul(String judul) {
        this.judul = judul;
    }

    public String getHarga() {
        return harga;
    }
    public void setHarga(String harga) {
        this.harga = harga;
    }

    public String getThubnail() {
        return thubnail;
    }
    public void setThubnail(String thubnail) {
        this.thubnail = thubnail;
    }

}

RecyclerAdapter.java

package com.example.recyclerviewvoley;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {
    private ArrayList<Data> listdata;
    private Activity activity;
    private Context context;

    public RecyclerAdapter(Activity activity, ArrayList<Data> listdata) {
        this.listdata = listdata;
        this.activity = activity;
    }

    @Override
    public RecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.list, parent, false);
        ViewHolder vh = new ViewHolder(v);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        //holder.mImage.setImageResource(listdata.get(position).getThubnail());
        holder.id.setText(listdata.get(position).getId());
        holder.judul.setText(listdata.get(position).getJudul());
        holder.harga.setText(listdata.get(position).getHarga());
        final ViewHolder x=holder;
        Glide.with(activity)
                .load(listdata.get(position).getThubnail())
                .into(holder.thumbnail);
        holder.id.setVisibility(View.GONE);
    }
    @Override
    public int getItemCount() {
        return listdata.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        private CardView cardview;
        private TextView id,judul,harga;
        private ImageView thumbnail;

        public ViewHolder(View v) {
            super(v);
            cardview=(CardView)v.findViewById(R.id.card_view);
            id=(TextView)v.findViewById(R.id.id);
            judul=(TextView)v.findViewById(R.id.judul);
            harga=(TextView)v.findViewById(R.id.harga);
            thumbnail=(ImageView)v.findViewById(R.id.thumbnail);
        }
    }

}

gradle

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.mcxiaoke.volley:library-aar:1.0.1'
    implementation 'com.github.bumptech.glide:glide:3.7.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'
}

logcat error

2019-02-21 12:21:33.776 18261-18261/? I/cyclerviewvole: Late-enabling -Xcheck:jni
2019-02-21 12:21:33.911 18261-18261/com.example.recyclerviewvoley W/cyclerviewvole: JIT profile information will not be recorded: profile file does not exits.
2019-02-21 12:21:33.912 18261-18261/com.example.recyclerviewvoley I/chatty: uid=10463(com.example.recyclerviewvoley) identical 10 lines
2019-02-21 12:21:33.912 18261-18261/com.example.recyclerviewvoley W/cyclerviewvole: JIT profile information will not be recorded: profile file does not exits.
2019-02-21 12:21:33.921 18261-18261/com.example.recyclerviewvoley I/Perf: Connecting to perf service.
2019-02-21 12:21:33.928 18261-18261/com.example.recyclerviewvoley I/InstantRun: starting instant run server: is main process
2019-02-21 12:21:34.050 18261-18261/com.example.recyclerviewvoley W/cyclerviewvole: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
2019-02-21 12:21:34.050 18261-18261/com.example.recyclerviewvoley W/cyclerviewvole: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
2019-02-21 12:21:34.098 18261-18281/com.example.recyclerviewvoley D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2019-02-21 12:21:34.100 18261-18281/com.example.recyclerviewvoley E/AndroidRuntime: FATAL EXCEPTION: Thread-5
    Process: com.example.recyclerviewvoley, PID: 18261
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
        at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:108)
        at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)
        at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/base.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_resources_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:108)
        at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)
        at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
    	Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:358)
        at dalvik.system.DexFile.<init>(DexFile.java:101)
        at dalvik.system.DexFile.<init>(DexFile.java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:407)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:729)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:812)
        at android.app.LoadedApk.getResources(LoadedApk.java:1034)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2357)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5817)
        at android.app.ActivityThread.access$1200(ActivityThread.java:200)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6806)
2019-02-21 12:21:34.101 18261-18281/com.example.recyclerviewvoley E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
    	Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.recyclerviewvoley-81xp4HeLm2MmSdApNSCMWw==/split_lib_slice_5_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:358)
        at dalvik.system.DexFile.<init>(DexFile.java:101)
        at dalvik.system.DexFile.<init>(DexFile.java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:407)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:729)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:812)
        at android.app.LoadedApk.getResources(LoadedApk.java:1034)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2357)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5817)
        at android.app.ActivityThread.access$1200(ActivityThread.java:200)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6806)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Mohon Maaf kalo kepanjangan :)

avatar MissterMan
@MissterMan

6 Kontribusi 1 Poin

Dipost 5 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban