1
votes

Here is the new logcat of the error, I do not understand what it is about I can't seem to figure out this error

11-25 15:56:18.773 6776-6776/com.example.ghost.prochat E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ghost.prochat/com.example.ghost.prochat.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2204) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5069) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class at android.view.LayoutInflater.createView(LayoutInflater.java:613) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) at android.view.LayoutInflater.inflate(LayoutInflater.java:466) at android.view.LayoutInflater.inflate(LayoutInflater.java:396) at android.view.LayoutInflater.inflate(LayoutInflater.java:352) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.ghost.prochat.MainActivity.onCreate(MainActivity.java:56) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)  at android.app.ActivityThread.access$600(ActivityThread.java:141)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:137)  at android.app.ActivityThread.main(ActivityThread.java:5069)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:417) at android.view.LayoutInflater.createView(LayoutInflater.java:587) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.example.ghost.prochat.MainActivity.onCreate(MainActivity.java:56)  at android.app.Activity.performCreate(Activity.java:5104)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)  at android.app.ActivityThread.access$600(ActivityThread.java:141)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:137)  at android.app.ActivityThread.main(ActivityThread.java:5069)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)  at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1 at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463) at android.view.View.(View.java:3340) at android.view.ViewGroup.(ViewGroup.java:431) at android.widget.LinearLayout.(LinearLayout.java:176) at android.widget.LinearLayout.(LinearLayout.java:172) at java.lang.reflect.Constructor.constructNative(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)  at android.view.LayoutInflater.createView(LayoutInflater.java:587)  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)  at android.view.LayoutInflater.inflate(LayoutInflater.java:466)  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)  at com.example.ghost.prochat.MainActivity.onCreate(MainActivity.java:56)  at android.app.Activity.performCreate(Activity.java:5104)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)  at android.app.ActivityThread.access$600(ActivityThread.java:141)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:137)  at android.app.ActivityThread.main(ActivityThread.java:5069)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)  at dalvik.system.NativeStart.main(Native Method) 

my mainActivity is as follows

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    //defining view objects
    private EditText editTextEmail;
    private EditText displayUsername;
    private EditText editTextPassword;
    private Button buttonSignup;


    private TextView textViewSignin;

    private ProgressDialog progressDialog;


    //defining firebaseauth object
    private FirebaseAuth firebaseAuth;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

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

        //initializing firebase auth object
        firebaseAuth = FirebaseAuth.getInstance();

        //if getCurrentUser does not returns null
        if (firebaseAuth.getCurrentUser() != null) {
            //that means user is already logged in
            //so close this activity
            finish();

            //and open profile activity
            startActivity(new Intent(getApplicationContext(), ProfileActivity.class));
        }

        //initializing views
        editTextEmail = (EditText) findViewById(R.id.editTextEmail);
        displayUsername = (EditText) findViewById(R.id.displayUsername);
        editTextPassword = (EditText) findViewById(R.id.editTextPassword);
        textViewSignin = (TextView) findViewById(R.id.textViewSignin);

        buttonSignup = (Button) findViewById(R.id.buttonSignup);

        progressDialog = new ProgressDialog(this);

        //attaching listener to button
        buttonSignup.setOnClickListener(this);
        textViewSignin.setOnClickListener(this);
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    private void registerUser() {


        //getting email and password from edit texts
        String email = editTextEmail.getText().toString().trim();
        String password = editTextPassword.getText().toString().trim();

        //checking if email and passwords are empty
        if (TextUtils.isEmpty(email)) {
            Toast.makeText(this, "Please enter email", Toast.LENGTH_LONG).show();
            return;
        }

        if (TextUtils.isEmpty(password)) {
            Toast.makeText(this, "Please enter password", Toast.LENGTH_LONG).show();
            return;
        }

        //if the email and password are not empty
        //displaying a progress dialog

        progressDialog.setMessage("Registering Please Wait...");
        progressDialog.show();


        //creating a new user
        firebaseAuth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        //checking if success
                        if (task.isSuccessful()) {
                            finish();
                            final FirebaseUser user = task.getResult().getUser();
                            UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
                                    .setDisplayName(String.valueOf(displayUsername))
                                    .setPhotoUri(Uri.parse("https://example.com/jane-q-user/profile.png"))
                                    .build();
                            user.updateProfile(profileUpdates);

                            FirebaseDatabase.getInstance().getReference("users").child(user.getUid()).setValue(UserList.user);
                            startActivity(new Intent(getApplicationContext(), ProfileActivity.class));
                        } else {
                            //display some message here
                            Toast.makeText(MainActivity.this, "Registration Error", Toast.LENGTH_LONG).show();
                        }
                        progressDialog.dismiss();
                    }
                });

    }


    @Override
    public void onClick(View view) {

        if (view == buttonSignup) {
            registerUser();
        }

        if (view == textViewSignin) {
            //open login activity when user taps on the already registered textview
            startActivity(new Intent(this, LoginActivity.class));
        }

    }

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    public Action getIndexApiAction() {
        Thing object = new Thing.Builder()
                .setName("Main Page") // TODO: Define a title for the content shown.
                // TODO: Make sure this auto-generated URL is correct.
                .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
                .build();
        return new Action.Builder(Action.TYPE_VIEW)
                .setObject(object)
                .setActionStatus(Action.STATUS_TYPE_COMPLETED)
                .build();
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        AppIndex.AppIndexApi.start(client, getIndexApiAction());
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        AppIndex.AppIndexApi.end(client, getIndexApiAction());
        client.disconnect();
    }
}

my main.activity is here, i cant see any errors

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/head"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.ghost.prochat.MainActivity">




        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="User Registration"
            android:id="@+id/textView"
            android:layout_gravity="center_horizontal" />

        <EditText
            android:id="@+id/displayUsername"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:hint="Username"
            android:inputType="textEmailAddress" />

        <EditText
            android:id="@+id/editTextEmail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:hint="Enter email"
            android:inputType="textEmailAddress" />

        <EditText
            android:id="@+id/editTextPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:hint="Enter password"
            android:inputType="textPassword" />

        <Button
            android:id="@+id/buttonSignup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:text="Signup" />

        <TextView
            android:text="Already Registered? Signin Here"
            android:id="@+id/textViewSignin"
            android:textAlignment="center"
            android:layout_margin="15dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />



</RelativeLayout>
1
i have also tried to launch it with a different activity but it stil cant workSir George
@MaheraGunawardena any help over hereSir George
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1 at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463Umar Ata
You have an error in activity_main.xmlUmar Ata
i dont see any errors in my activity_main.xml @UmarAtaSir George

1 Answers

0
votes

Your crash is caused by the following:

Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1 at android.content.res.TypedArray.getDimensionPixelSize

So the problem is in one of your dimensions:

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

I can guess, that you used wrong dimension type, e.g. sp instead of dp

Here is how a right dimension should look:

<dimen name="activity_vertical_margin">36dp</dimen>

Also please ensure your dimension is defined in an xml in the valuesfolder as it mentioned in this answer