1

I created an application with the webview element. In short, the app should connect to the website on startup. In any case, this does not. Crashes on startup. Here are the files Manifest, and Activity. Where is the problem?

Manifest:

package="(name of package Don't Look this

)">

<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" android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>``
</application>
Activity
package (name); // Don't Look this
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("https://www.website.com");
    }
}

What's the problem?

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.miotvonline.website, PID: 4535
        java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
            in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)
        at androidx.activity.ComponentActivity.(ComponentActivity.java:138)
        at androidx.fragment.app.FragmentActivity.(FragmentActivity.java:103)
        at androidx.appcompat.app.AppCompatActivity.(AppCompatActivity.java:94)
        at com.miotvonline.website.MainActivity.(MainActivity.java:8)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
        at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1243)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3182)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
zapl
  • 63,179
  • 10
  • 123
  • 154
  • whats the error you get? Should be in either logcat or the output window shown at the bottom of Android Studio. See https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – zapl Sep 27 '22 at 19:18
  • From looking at the code it could be https://stackoverflow.com/questions/6130216/do-i-need-to-set-internet-permission-for-opening-a-website-in-android but that's just a guess – zapl Sep 27 '22 at 19:24
  • I can't configure the emulator, just weird thing before it worked now it doesn't ... also the activity.main seems to me to be fine – Mark_Revans Sep 27 '22 at 20:42
  • I think something in your build process went wrong, it's not finding some Java 8 lambda compatibility code. Try "File -> Invalidate Caches / Restart" in Android Studio and rebuild the app. – zapl Sep 27 '22 at 21:39

0 Answers0