2

I don't know why this error comes

where to miss add some code or remove the code.

i'll just try to JSon Object Request

i'll take a 2 class AppController AND LruBitmapCache

Screen Shot of Manifest.xml :

enter image description here

activity_main.xml :

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</LinearLayout>

Below code is a AppController.java class:

package com.example.volleyexample.app;

import android.app.Application;
import android.text.TextUtils;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
import com.example.volleyexample.utils.LruBitmapCache;

public class AppController extends Application{

    public static final String TAG = AppController.class.getSimpleName();

    private RequestQueue mRequestQueue;
    private ImageLoader mImageLoader;
    private static AppController mInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public static synchronized AppController getInstance() {
        return mInstance;
    }

    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }

        return mRequestQueue;
    }

    public ImageLoader getImageLoader() {
        getRequestQueue();
        if (mImageLoader == null) {
            mImageLoader = new ImageLoader(this.mRequestQueue,
                    new LruBitmapCache());
        }
        return this.mImageLoader;
    }

    public <T> void addToRequestQueue(Request<T> req, String tag) {
        // set the default tag if tag is empty
        req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
        getRequestQueue().add(req);
    }

    public <T> void addToRequestQueue(Request<T> req) {
        req.setTag(TAG);
        getRequestQueue().add(req);
    }

    public void cancelPendingRequests(Object tag) {
        if (mRequestQueue != null) {
            mRequestQueue.cancelAll(tag);
        }
    }
}

Thanks in advance :)

Ali
  • 3,346
  • 4
  • 21
  • 56

2 Answers2

1

You must add proper Package name with Activity name.

android:name

The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the element.

You should add Proper Package Name with Activity Name.

<activity android:name="yourPackageName.ActivityName

android:parentActivityName

The class name of the logical parent of the activity. The name here must match the class name given to the corresponding element's android:name attribute.

NOTE

Your AppController is a Application class, So it should be <application section.

Finally

<application
        android:name="com.example.volleyexample.app.AppController"
        android:allowBackup="true"
       >
        <activity
            android:name="
        >

Then Clean-Rebuild-Run.

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

It should be in Application tag of manifest. Something like below

<application
        android:name=".yourPackage.AppController"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

// Your activities, services... declared here

</application>
Arshad
  • 1,262
  • 16
  • 25