简体   繁体   English

为什么aar导入在android studio中不满意?

[英]why aar importing not happy in android studio?

not duplicate of another question because the .gradle files was already configured as suggested.(Note, it's not that I can't build the project but the IDE fail to identify the importing) 不会重复另一个问题,因为.gradle文件已经按照建议进行了配置。(注意,这不是我无法构建项目,但IDE无法识别导入)


Newbie to android development Android新手开发

I am using the latest android studio (v3.1.3) 我正在使用最新的android studio(v3.1.3)

I have download source from a site and try to run that on an android device, which is successful, ie, I could build the apk but in android studio IDE, the import class shows error, the class seems imported from an aar file. 我从一个站点下载了源代码,并尝试在android设备上运行它,这是成功的,即,我可以构建apk,但是在android studio IDE中,导入类显示错误,该类似乎是从aar文件中导入的。

How to make the importing work(not showing error) in IDE? 如何在IDE中进行导入工作(不显示错误)?

在此处输入图片说明

And here is the build.gradle in app: 这是应用程序中的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    defaultConfig {
        applicationId "com.tencent.tmgp.yybtestsdk"
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile(name: 'YSDK_Android_1.3.9_917', ext: 'aar')
}

here is the build.gradle in 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.1.3'

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

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

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

Update your gradle.build (in the PROJECT level, not app level) like so. 像这样更新gradle.build (在PROJECT级别,而不是应用程序级别)。

        flatDir {
            dirs 'libs'
            dirs 'libs/app'
            dirs "../app/libs"
        }

Try changing 尝试改变

compile(name: 'YSDK_Android_1.3.9_917', ext: 'aar')

to

implementation(name: 'YSDK_Android_1.3.9_917', ext: 'aar')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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