简体   繁体   中英

Why is applet not found on Android studio?

I'm trying to make an applet in android studio that worked in the past on previous installs on different computers. Right now though I am getting an error on import java.applet.Applet; saying cannot resolve symbol Applet . when i look at the project settings its pointing to the JRE8 that comes with android studio so i figured it might be becausue its using jre instead of jdk and installed openjdk8 and pointed to that but still no luck. I also changed my java_home to point to this new openjdk8 but when restarting android studio java_home is still pointing to its own jre. I`m using ubuntu linux.

Any help is appreciated

Thank you

Temp.java

package com.example.myapplication;

import java.applet.Applet;

public class Temp extends Applet {
}

Project build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Module build.gradle

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

Primarily, Android Studio is for creating Android apps. Android does not support applets (AFAIK, almost nothing supports applets, for security reasons).

You created an Android project in Android Studio. Android projects compile against the Android SDK, not a JDK, and the Android SDK does not have support for applets (or many other things from a JDK).

If you wish to build a Java applet in Android Studio, you will need to:

  • Create an Android Studio project
  • Add a Java library module to that project (File > New > New Module... from the main menu)
  • Develop your applet in that library module

You may be better served using another IDE (eg, IntelliJ IDEA) or not working on an applet.

Never mind. If you are wondering why you are getting errors in one of those tutorials be patient and finish it because they will probably replace the applet with something else down the line when they port it over to android.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM