0

I get a compilation error after I add implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.2' under dependencies in build.grandle app. It's working fine when the project is syncing, but it fails while I try to compile the app.

This is the error I've got:

AndroidStudioProjects/Pari365/app/src/main/java/com/maunexus/MainActivity.java:
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details.

This is the MainActivity.java file:

package com.maunexus;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {

    private WebView webView;
    Activity activity;
    private ProgressDialog progDailog;


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

        activity = this;

        progDailog = ProgressDialog.show(activity, "Loading", "Please wait...", true);
        progDailog.setCancelable(false);


        webView = (WebView) findViewById(R.id.webviewid);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
        }
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
        webView.getSettings().setSupportMultipleWindows(false);
        webView.getSettings().setSupportZoom(false);
        webView.setVerticalScrollBarEnabled(false);
        webView.setHorizontalScrollBarEnabled(false);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.setWebViewClient(new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                progDailog.show();
                view.loadUrl(url);

                return true;
            }

            @Override
            public void onPageFinished(WebView view, final String url) {
                progDailog.dismiss();
            }
        });

        webView.loadUrl("https://pari365.mg");

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.super_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }


    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_back:
                onBackPressed();
                break;

            case R.id.menu_forward:
                onForwardPressed();
                break;

            case R.id.menu_refresh:
                webView.reload();
                Toast.makeText(this, "Reloading... Please Wait!", Toast.LENGTH_SHORT).show();
                break;


        }
        return super.onOptionsItemSelected(item);
    }


    private void onForwardPressed() {
        if (webView.canGoForward()) {
            webView.goForward();
        } else {
            Toast.makeText(this, "Already there! ;)", Toast.LENGTH_SHORT).show();
        }
    }

    public void onBackPressed() {
        if (webView.canGoBack()) {
            webView.goBack();
        }
    }
}

And, this is the AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.maunexus">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Please help me to fix the error. Thank You ;)

UPDATE: I replaced the ProgressDialog with ProgressBar, but the error still persists.

com/maunexus/MainActivity.java  
uses or overrides a deprecated API. 
com.android.tools.r8.CompilationFailedException: Compilation failed to complete 
com.android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in a single dex file (# methods: 100707 > 65536)   
null    
Cannot fit requested classes in a single dex file (# methods: 100707 > 65536)   
  • 1
    this seems more like a warning than it does an error. It will run, it is just informing you that some of the code you use might later on not be there anymore. It is outdated and replaced by a new method of working. – Stultuske Dec 12 '19 at 08:20
  • To see all the deprecations run `./gradlew app:compileLint ` in your project's root folder – Muhammed Yalçın Kuru Dec 12 '19 at 08:38

1 Answers1

0

This is a warning, and the deprecated class is ProgressDialog, from the docs:

This class was deprecated in API level 26.

ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.

https://developer.android.com/reference/android/app/ProgressDialog

You can use the ProgressBar instead of ProgressDialog.

Community
  • 1
  • 1
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • I've been replaced the ProgressDialog with Progress bar, but the error still persists. Please check the updated question above. –  Dec 12 '19 at 16:48
  • Check this for the error https://stackoverflow.com/questions/48249633/errorcannot-fit-requested-classes-in-a-single-dex-file-try-supplying-a-main-dex – Peter Haddad Dec 12 '19 at 16:56