android - Android Studio-错误:程序包java.awt.geom不存在

标签 android eclipse android-studio gradle android-gradle-plugin

我正在将应用程序从Eclipse迁移到Android Studio。当我编译代码时:

import java.awt.geom.Area;

我得到

error: package java.awt.geom does not exist



建立gradle
apply plugin: 'com.android.application'

android {
    //compileSdkVersion 'Google Inc.:Google APIs:8'
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.me.droider"
        minSdkVersion 13
        targetSdkVersion 23
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            debuggable true
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    //compile files('libs/osmdroid-android-4.2.jar')
    compile files('libs/osmdroid-android-4.3.jar')
    compile 'javax.annotation:jsr250-api:1.0'
}

关于如何解决这个问题有什么建议吗?这是gradle问题吗?我应该包括文件并用作库吗?

最佳答案

@CommonsWare建议我不要使用java.awt库,这可能是长期建议。

另一方面,要解决当前的问题,请downloaded the library解压缩文件,然后将jar文件(java-rt-jar-stubs-1.5.0.jar)放在libs文件夹中。

然后,我右键单击jar文件,然后选择Add as library

问题解决了。

关于android - Android Studio-错误:程序包java.awt.geom不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36769851/

相关文章:

android - 为什么 fragment 与操作栏重叠?

android - 使用 jitpack 构建的库中的错误 : Unable to resolve dependency for ':app@debug/compileClasspath'

java - 如何使用 "LIKE"和 "%"检查 android 中变量的相似性(Java 代码)

Android Studio 找不到默认 Activity

android - 是否有可能在 Android Studio 中构建一个带有 .so 作为输出的 native 模块

android - 如何使用 espresso android 测试一定范围内的 View 文本

android - 如何将 Picasso Library 与 MediaStore 一起使用

c - 在 C 编辑器中自动定义...为什么?

Ubuntu 上的 Eclipse 在使用文件系统工作目录设置运行配置时出现 "Update LCD"错误

database - 使用服务名称从 Eclipse 连接到 Oracle Enterprise 11